Skip to content

Commit a243992

Browse files
committed
ASOAPI: truncate expected node label values at max length
1 parent 4e461eb commit a243992

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controllers/azureasomanagedmachinepool_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
corev1 "k8s.io/api/core/v1"
2626
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2727
"k8s.io/apimachinery/pkg/types"
28+
"k8s.io/apimachinery/pkg/util/validation"
2829
"k8s.io/utils/ptr"
2930
infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1"
3031
"sigs.k8s.io/cluster-api-provider-azure/pkg/mutators"
@@ -285,6 +286,12 @@ func (r *AzureASOManagedMachinePoolReconciler) reconcileNormal(ctx context.Conte
285286
}
286287

287288
func expectedNodeLabels(poolName, nodeRG string) map[string]string {
289+
if len(poolName) > validation.LabelValueMaxLength {
290+
poolName = poolName[:validation.LabelValueMaxLength]
291+
}
292+
if len(nodeRG) > validation.LabelValueMaxLength {
293+
nodeRG = nodeRG[:validation.LabelValueMaxLength]
294+
}
288295
return map[string]string{
289296
"kubernetes.azure.com/agentpool": poolName,
290297
"kubernetes.azure.com/cluster": nodeRG,

0 commit comments

Comments
 (0)