Skip to content

Commit 04d40b9

Browse files
committed
Fix node labels diff
1 parent e872852 commit 04d40b9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

azure/services/agentpools/spec.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
237237
normalizedProfile.Count = existingProfile.Count
238238
}
239239

240+
// We do a just-in-time merge of existent kubernetes.azure.com-prefixed labels
241+
// So that we don't unintentionally delete them
242+
// See https://github.com/Azure/AKS/issues/3152
243+
if normalizedProfile.NodeLabels != nil {
244+
nodeLabels = mergeSystemNodeLabels(normalizedProfile.NodeLabels, existingPool.NodeLabels)
245+
normalizedProfile.NodeLabels = nodeLabels
246+
}
247+
240248
// Compute a diff to check if we require an update
241249
diff := cmp.Diff(normalizedProfile, existingProfile)
242250
if diff == "" {
@@ -245,12 +253,6 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
245253
return nil, nil
246254
}
247255
log.V(4).Info("found a diff between the desired spec and the existing agentpool", "difference", diff)
248-
// We do a just-in-time merge of existent kubernetes.azure.com-prefixed labels
249-
// So that we don't unintentionally delete them
250-
// See https://github.com/Azure/AKS/issues/3152
251-
if normalizedProfile.NodeLabels != nil {
252-
nodeLabels = mergeSystemNodeLabels(normalizedProfile.NodeLabels, existingPool.NodeLabels)
253-
}
254256
}
255257

256258
var availabilityZones *[]string

0 commit comments

Comments
 (0)