Skip to content

Conversation

@dminnear-rh
Copy link
Contributor

Fixes validatedpatterns/clustergroup-chart#61 by ensuring that we fail before install if the length of the names will cause invalid DNS problems.

Also, will fix validatedpatterns/pattern-install-chart#18. In addition to the validation added, this PR reads the pattern name from the values-global.yaml file rather than just taking the basename of whatever directory the git repo is cloned into locally.

A failed validation looks like:

Validating that the pattern and clustergroup names don't exceed DNS limits after the pattern is installed.

Checking file: values-group-one.yaml
  -> FAILED: Length of clustergroup 'group-one' and pattern 'validated-patterns-multicloud-gitops' will exceed DNS limits in clustergroup chart. Please shorten one or both.

Checking file: values-hub.yaml
  -> PASSED: Length of clustergroup 'hub' and pattern 'validated-patterns-multicloud-gitops' are within clustergroup chart limits.

Checking file: values-standalone.yaml
  -> FAILED: Length of clustergroup 'standalone' and pattern 'validated-patterns-multicloud-gitops' will exceed DNS limits in clustergroup chart. Please shorten one or both.

One or more cluster group names failed the length validation.
--------------------------------------------------------------------------------
Validation Explanation:
This script ensures that generated Kubernetes resource names do not exceed the 63-character limit.
A DNS-compatible name is constructed in the 'clustergroup' Helm chart using the following pattern:
  -> {{ .Values.clusterGroup.name }}-gitops-server-{{ .Values.global.pattern }}-{{ .Values.clusterGroup.name }}

The total length is calculated as:
  (2 * length of 'clusterGroup.name') + length of 'global.pattern' + 15 (for '-gitops-server-') + 1 (for the namespace separator '-')

To stay under the 63-character limit, the variable part of the name must be less than 47 characters:
  (2 * length of 'clusterGroup.name') + length of 'global.pattern' < 47
--------------------------------------------------------------------------------

A passed validation looks like:

Validating that the pattern and clustergroup names don't exceed DNS limits after the pattern is installed.

Checking file: values-group-one.yaml
  -> PASSED: Length of clustergroup 'group-one' and pattern 'multicloud-gitops' are within clustergroup chart limits.

Checking file: values-hub.yaml
  -> PASSED: Length of clustergroup 'hub' and pattern 'multicloud-gitops' are within clustergroup chart limits.

Checking file: values-standalone.yaml
  -> PASSED: Length of clustergroup 'standalone' and pattern 'multicloud-gitops' are within clustergroup chart limits.

All names are within clustergroup chart limits.

@dminnear-rh dminnear-rh force-pushed the limit-pattern-group-names branch from 4e539b8 to a1b23c8 Compare October 7, 2025 17:37
@@ -1,4 +1,4 @@
NAME ?= $(shell basename "`pwd`")
NAME ?= $(shell yq .global.pattern values-global.yaml)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a fallback to the old ways here? I am just not remembering when we introduced the .global.pattern. Unless you're sure we have it set everywhere that is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it is set everywhere (although it probably should be). What if we use yq --exit-status .global.pattern values-global.yaml to enforce that it is set. Then, rather than falling back to the directory name, we enforce they have a proper value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we error out if it does not have it set? Yeah let's go for that! I suppose the pattern's that don't have it, probably won't update common much anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the check:

ifeq ($(NAME),)
$(error Pattern name MUST be set in values-global.yaml with the value .global.pattern)
endif
ifeq ($(NAME),null)
$(error Pattern name MUST be set in values-global.yaml with the value .global.pattern)
endif

so if it's not set (or if the pattern name is set to be an empty string) we'll error out:

❯ make show
make -f common/Makefile show
make[1]: Entering directory '/home/drewminnear/gh-repos/dminnear-rh/multicloud-gitops'
common/Makefile:7: *** Pattern name MUST be set in values-global.yaml with the value .global.pattern.  Stop.
make[1]: Leaving directory '/home/drewminnear/gh-repos/dminnear-rh/multicloud-gitops'
make: *** [Makefile:12: show] Error 2

@dminnear-rh dminnear-rh merged commit 7e92e29 into validatedpatterns:main Oct 9, 2025
4 checks passed
@dminnear-rh dminnear-rh deleted the limit-pattern-group-names branch October 9, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We need to truncate the names of things When the pattern name is too long we do not truncate the used name

2 participants