EmbarkStudios / k8s-buildkite-plugin

Run any buildkite build step as a Kubernetes Job
https://embark.dev
Apache License 2.0
49 stars 19 forks source link

Fix k8s labels ending in invalid characters #40

Closed keith closed 3 years ago

keith commented 3 years ago

If your branch was > 63 characters long, we would truncate it, if the truncation ended in a non-alpha numeric character, k8s fails.

This removes those characters entirely from these labels, which theoretically increases the chances of collisions, but I think it's unlikely enough that this is fine. Alternatively we can be smarter about it just starting with or ending with the other characters, but that's just a bit more logic to deal with.

* spec.template.labels: Invalid value: “transittripui-include-questions-debug-description-to-assertion-“: 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])?’)

The other case of sanitization like this should be less likely to be impacted since it only includes the pipeline name and build number