Skip to content

Commit

Permalink
ASOAPI: truncate expected node label values at max length
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Aug 5, 2024
1 parent 4e461eb commit a243992
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/azureasomanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/utils/ptr"
infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1"
"sigs.k8s.io/cluster-api-provider-azure/pkg/mutators"
Expand Down Expand Up @@ -285,6 +286,12 @@ func (r *AzureASOManagedMachinePoolReconciler) reconcileNormal(ctx context.Conte
}

func expectedNodeLabels(poolName, nodeRG string) map[string]string {
if len(poolName) > validation.LabelValueMaxLength {
poolName = poolName[:validation.LabelValueMaxLength]
}
if len(nodeRG) > validation.LabelValueMaxLength {
nodeRG = nodeRG[:validation.LabelValueMaxLength]
}
return map[string]string{
"kubernetes.azure.com/agentpool": poolName,
"kubernetes.azure.com/cluster": nodeRG,
Expand Down

0 comments on commit a243992

Please sign in to comment.