diff --git a/controllers/argocd/route.go b/controllers/argocd/route.go index e7cc53ce9..3aa2aae60 100644 --- a/controllers/argocd/route.go +++ b/controllers/argocd/route.go @@ -382,6 +382,12 @@ func (r *ReconcileArgoCD) reconcileApplicationSetControllerWebhookRoute(cr *argo return r.Client.Update(context.TODO(), route) } +// The algorithm used by this function is: +// - If the FIRST label ("console-openshift-console" in the above case) is longer than 63 characters, shorten (truncate the end) it to 63. +// - If any other label is longer than 63 characters, return an error +// - After all the labels are 63 characters or less, check the length of the overall hostname: +// - If the overall hostname is > 255, then shorten the FIRST label until the host name is < 255 +// - After the FIRST label has been shortened, if it is < 20, then return an error (this is a sanity test to ensure the label is likely to be unique) func shortenHostname(hostname string) (string, error) { if hostname == "" { return "", nil