uselagoon / build-deploy-tool

Tool to generate build resources
4 stars 7 forks source link

Long cronjob names can lead to issues on deplyoments #185

Open dasrecht opened 3 years ago

dasrecht commented 3 years ago

Describe the bug

A long cronjob name can lead to failing deployments

* metadata.name: Invalid value: "cronjob-cli-fastly-purge-queue-worker--flush-cache-tags-": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
* spec.jobTemplate.spec.template.labels: Invalid value: "fastly-purge-queue-worker--flush-cache-tags-": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
* spec.jobTemplate.spec.template.spec.containers[0].name: Invalid value: "cronjob-cli-fastly-purge-queue-worker--flush-cache-tags-": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
* metadata.name: Invalid value: "cronjob-cli-fastly-purge-queue-worker--flush-cache-tags-": must be no more than 52 characters
rocketeerbkw commented 1 year ago

We no longer support Openshift.

rocketeerbkw commented 1 year ago

This is also an issue on k8s after all https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/

The name of a CronJob must be a valid DNS subdomain value, but this can produce unexpected results for the Pod hostnames. For best compatibility, the name should follow the more restrictive rules for a DNS label. Even when the name is a DNS subdomain, the name must be no longer than 52 characters. This is because the CronJob controller will automatically append 11 characters to the name you provide and there is a constraint that the length of a Job name is no more than 63 characters.

sjerdo commented 9 months ago

We also experience this issue for long cronjob names:

The CronJob "cronjob-cli-cronjobName" is invalid: metadata.name: Invalid value: "cronjob-cli-cronjobName": must be no more than 52 characters

Can you cap these names to 52 characters? The length depends on the container and cronjob name

shreddedbacon commented 9 months ago

Can you cap these names to 52 characters? The length depends on the container and cronjob name

Yes, we can probably truncate them and add a hash so the names remain unique

shreddedbacon commented 9 months ago

I'm already looking at template generation functions, so I'll flag this as something to resolve in that part of work.

Obviously the short term workaround is to choose a shorter name, but obviously not ideal.