From e2e44bcd0996357aa9ee04481ce9ef9ac7ed3ae6 Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Mon, 16 Feb 2026 23:38:38 +0100 Subject: [PATCH] Fix AnsibleEE job name collisions for long names Previously, when the combined service + deployment + nodeset name exceeded 63 characters (DNS1123 max), simple truncation could cause different jobs to end up with identical names, leading to collisions. Replace the arbitrary -10 prefix truncation with a hash-based approach: - Build the full execution name without premature truncation - If the name exceeds 63 characters, truncate to 54 characters and append an 8-character SHA256 hash suffix - This guarantees unique names even when truncation is required Closes: OSPRH-26041 Signed-off-by: Sergii Golovatiuk --- internal/dataplane/util/ansible_execution.go | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/internal/dataplane/util/ansible_execution.go b/internal/dataplane/util/ansible_execution.go index b9776cdb8..2c31f3556 100644 --- a/internal/dataplane/util/ansible_execution.go +++ b/internal/dataplane/util/ansible_execution.go @@ -19,6 +19,8 @@ package util //nolint:revive // util is an acceptable package name in this conte import ( "context" + "crypto/sha256" + "encoding/hex" "encoding/json" "fmt" "sort" @@ -167,29 +169,23 @@ func GetAnsibleExecution(ctx context.Context, return ansibleEE, nil } -// getAnsibleExecutionNamePrefix compute the name of the AnsibleEE -func getAnsibleExecutionNamePrefix(serviceName string) string { - AnsibleExecutionServiceNameLen := apimachineryvalidation.DNS1123LabelMaxLength - 10 - - if len(serviceName) > AnsibleExecutionServiceNameLen { - return serviceName[:AnsibleExecutionServiceNameLen] - } - - return serviceName -} - // GetAnsibleExecutionNameAndLabels Name and Labels of AnsibleEE func GetAnsibleExecutionNameAndLabels(service *dataplanev1.OpenStackDataPlaneService, deploymentName string, nodeSetName string, ) (string, map[string]string) { - executionName := fmt.Sprintf("%s-%s", getAnsibleExecutionNamePrefix(service.Name), deploymentName) + executionName := fmt.Sprintf("%s-%s", service.Name, deploymentName) if !service.Spec.DeployOnAllNodeSets { executionName = fmt.Sprintf("%s-%s", executionName, nodeSetName) } if len(executionName) > apimachineryvalidation.DNS1123LabelMaxLength { - executionName = strings.TrimRight(executionName[:apimachineryvalidation.DNS1123LabelMaxLength], "-.") + hash := sha256.Sum256([]byte(executionName)) + hashSuffix := hex.EncodeToString(hash[:])[:8] + // 9 = "-" + 8 char hash suffix + maxPrefix := apimachineryvalidation.DNS1123LabelMaxLength - 9 + prefix := strings.TrimRight(executionName[:maxPrefix], "-.") + executionName = fmt.Sprintf("%s-%s", prefix, hashSuffix) } labels := map[string]string{