Skip to content

Commit

Permalink
Kubernetes name length fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alok87 committed May 17, 2021
1 parent f8c34cb commit 0be3d5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/batcher_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func NewBatcher(
if err != nil {
return nil, err
}
objectName := fmt.Sprintf("%s-%s", name, hash)
objectName := applyKubernetesNameLength(name, hash)
labels := getDefaultLabels(
BatcherLabelInstance, sinkGroup, objectName, rsk.Name,
)
Expand Down
2 changes: 1 addition & 1 deletion controllers/loader_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func NewLoader(
if err != nil {
return nil, err
}
objectName := fmt.Sprintf("%s-%s", name, hash)
objectName := applyKubernetesNameLength(name, hash)
labels := getDefaultLabels(
LoaderLabelInstance, sinkGroup, objectName, rsk.Name,
)
Expand Down
8 changes: 8 additions & 0 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ func sortStringSlice(t []string) {
sort.Sort(sort.StringSlice(t))
}

func applyKubernetesNameLength(name, hash string) string {
if len(name) <= 55 {
return fmt.Sprintf("%s-%s", name, hash)
}

return fmt.Sprintf("%s-%s", name[:55], hash)
}

// getDefaultLabels gives back the default labels for the crd resources
func getDefaultLabels(
instance, sinkGroup, objectName string,
Expand Down

0 comments on commit 0be3d5d

Please sign in to comment.