@@ -1207,7 +1207,7 @@ func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string
1207
1207
klog .Errorf ("failed to get subnet %s, %v" , subnetName , err )
1208
1208
return err
1209
1209
}
1210
- vpc , err := c .vpcsLister .Get (vpcName )
1210
+ cachedVpc , err := c .vpcsLister .Get (vpcName )
1211
1211
if err != nil {
1212
1212
if k8serrors .IsNotFound (err ) {
1213
1213
return nil
@@ -1227,6 +1227,7 @@ func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string
1227
1227
klog .Error (err )
1228
1228
return err
1229
1229
}
1230
+ vpc := cachedVpc .DeepCopy ()
1230
1231
for _ , eip := range ovnEips {
1231
1232
if ! eip .Status .Ready || eip .Status .V4Ip == "" {
1232
1233
err := fmt .Errorf ("ovn eip %q not ready" , eip .Name )
@@ -1266,7 +1267,7 @@ func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string
1266
1267
}
1267
1268
}
1268
1269
if needUpdate {
1269
- if vpc , err = c .config .KubeOvnClient .KubeovnV1 ().Vpcs ().Update (context .Background (), vpc , metav1.UpdateOptions {}); err != nil {
1270
+ if _ , err = c .config .KubeOvnClient .KubeovnV1 ().Vpcs ().Update (context .Background (), vpc , metav1.UpdateOptions {}); err != nil {
1270
1271
klog .Errorf ("failed to update vpc spec static route %s, %v" , vpc .Name , err )
1271
1272
return err
1272
1273
}
@@ -1298,9 +1299,9 @@ func (c *Controller) reconcileCustomVpcAddNormalStaticRoute(vpcName string) erro
1298
1299
klog .Errorf ("failed to get vpc %s, %v" , vpcName , err )
1299
1300
return err
1300
1301
}
1301
- vpc := cachedVpc . DeepCopy ()
1302
- rtbs := c .getRouteTablesByVpc (vpc )
1303
- routeTotal := len (vpc .Spec .StaticRoutes ) + len (rtbs )* 2
1302
+
1303
+ rtbs := c .getRouteTablesByVpc (cachedVpc )
1304
+ routeTotal := len (cachedVpc .Spec .StaticRoutes ) + len (rtbs )* 2
1304
1305
routes := make ([]* kubeovnv1.StaticRoute , 0 , routeTotal )
1305
1306
v4Exist , v6Exist := false , false
1306
1307
for _ , staticRoutes := range rtbs {
@@ -1348,8 +1349,9 @@ func (c *Controller) reconcileCustomVpcAddNormalStaticRoute(vpcName string) erro
1348
1349
}
1349
1350
1350
1351
if needUpdate {
1352
+ vpc := cachedVpc .DeepCopy ()
1351
1353
vpc .Spec .StaticRoutes = routes
1352
- if vpc , err = c .config .KubeOvnClient .KubeovnV1 ().Vpcs ().Update (context .Background (), vpc , metav1.UpdateOptions {}); err != nil {
1354
+ if _ , err = c .config .KubeOvnClient .KubeovnV1 ().Vpcs ().Update (context .Background (), vpc , metav1.UpdateOptions {}); err != nil {
1353
1355
klog .Errorf ("failed to update vpc spec static route %s, %v" , vpc .Name , err )
1354
1356
return err
1355
1357
}
0 commit comments