@@ -19,6 +19,8 @@ package util //nolint:revive // util is an acceptable package name in this conte
1919
2020import (
2121 "context"
22+ "crypto/sha256"
23+ "encoding/hex"
2224 "encoding/json"
2325 "fmt"
2426 "sort"
@@ -175,29 +177,23 @@ func GetAnsibleExecution(ctx context.Context,
175177 return ansibleEE , nil
176178}
177179
178- // getAnsibleExecutionNamePrefix compute the name of the AnsibleEE
179- func getAnsibleExecutionNamePrefix (serviceName string ) string {
180- AnsibleExecutionServiceNameLen := apimachineryvalidation .DNS1123LabelMaxLength - 10
181-
182- if len (serviceName ) > AnsibleExecutionServiceNameLen {
183- return serviceName [:AnsibleExecutionServiceNameLen ]
184- }
185-
186- return serviceName
187- }
188-
189180// GetAnsibleExecutionNameAndLabels Name and Labels of AnsibleEE
190181func GetAnsibleExecutionNameAndLabels (service * dataplanev1.OpenStackDataPlaneService ,
191182 deploymentName string ,
192183 nodeSetName string ,
193184) (string , map [string ]string ) {
194- executionName := fmt .Sprintf ("%s-%s" , getAnsibleExecutionNamePrefix ( service .Name ) , deploymentName )
185+ executionName := fmt .Sprintf ("%s-%s" , service .Name , deploymentName )
195186 if ! service .Spec .DeployOnAllNodeSets {
196187 executionName = fmt .Sprintf ("%s-%s" , executionName , nodeSetName )
197188 }
198189
199190 if len (executionName ) > apimachineryvalidation .DNS1123LabelMaxLength {
200- executionName = strings .TrimRight (executionName [:apimachineryvalidation .DNS1123LabelMaxLength ], "-." )
191+ hash := sha256 .Sum256 ([]byte (executionName ))
192+ hashSuffix := hex .EncodeToString (hash [:])[:8 ]
193+ // 9 = "-" + 8 char hash suffix
194+ maxPrefix := apimachineryvalidation .DNS1123LabelMaxLength - 9
195+ prefix := strings .TrimRight (executionName [:maxPrefix ], "-." )
196+ executionName = fmt .Sprintf ("%s-%s" , prefix , hashSuffix )
201197 }
202198
203199 labels := map [string ]string {
0 commit comments