@@ -24,12 +24,14 @@ const (
2424 DefaultRefreshDelay = 1 * time .Second
2525 // DefaultMaxIPs default maximum allocatable IPs
2626 DefaultMaxIPs = 250
27+ // fieldManager is the field manager used when patching the NodeNetworkConfig.
28+ fieldManager = "azure-cns"
2729 // Subnet ARM ID /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/$(SUBNET)
2830 subnetARMIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s"
2931)
3032
3133type nodeNetworkConfigSpecUpdater interface {
32- UpdateSpec (context.Context , * v1alpha.NodeNetworkConfigSpec ) (* v1alpha.NodeNetworkConfig , error )
34+ PatchSpec (context.Context , * v1alpha.NodeNetworkConfigSpec , string ) (* v1alpha.NodeNetworkConfig , error )
3335}
3436
3537// metaState is the Monitor's configuration state for the IP pool.
@@ -281,7 +283,7 @@ func (pm *Monitor) increasePoolSize(ctx context.Context, meta metaState, state i
281283
282284 logger .Printf ("[ipam-pool-monitor] Increasing pool size, pool %+v, spec %+v" , state , tempNNCSpec )
283285
284- if _ , err := pm .nnccli .UpdateSpec (ctx , & tempNNCSpec ); err != nil {
286+ if _ , err := pm .nnccli .PatchSpec (ctx , & tempNNCSpec , fieldManager ); err != nil {
285287 // caller will retry to update the CRD again
286288 return errors .Wrap (err , "executing UpdateSpec with NNC client" )
287289 }
@@ -347,7 +349,7 @@ func (pm *Monitor) decreasePoolSize(ctx context.Context, meta metaState, state i
347349 attempts := 0
348350 if err := retry .Do (func () error {
349351 attempts ++
350- _ , err := pm .nnccli .UpdateSpec (ctx , & tempNNCSpec )
352+ _ , err := pm .nnccli .PatchSpec (ctx , & tempNNCSpec , fieldManager )
351353 if err != nil {
352354 // caller will retry to update the CRD again
353355 logger .Printf ("failed to update NNC spec attempt #%d, err: %v" , attempts , err )
@@ -378,7 +380,7 @@ func (pm *Monitor) decreasePoolSize(ctx context.Context, meta metaState, state i
378380func (pm * Monitor ) cleanPendingRelease (ctx context.Context ) error {
379381 tempNNCSpec := pm .createNNCSpecForCRD ()
380382
381- _ , err := pm .nnccli .UpdateSpec (ctx , & tempNNCSpec )
383+ _ , err := pm .nnccli .PatchSpec (ctx , & tempNNCSpec , fieldManager )
382384 if err != nil {
383385 // caller will retry to update the CRD again
384386 return errors .Wrap (err , "executing UpdateSpec with NNC client" )
0 commit comments