Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git branches ending in a - results in no deployments #3410

Open
seanhamlin opened this issue Mar 15, 2023 · 3 comments
Open

Git branches ending in a - results in no deployments #3410

seanhamlin opened this issue Mar 15, 2023 · 3 comments
Labels
2-build-deploy Build & Deploy subsystem bug

Comments

@seanhamlin
Copy link
Contributor

Describe the bug

If you create a branch that ends with a - and get Lagoon to build that, it currently does not work.

To Reproduce

Steps to reproduce the behavior:

  1. Create branch that ends in -
  2. Push branch
  3. Notice Lagoon will never build it, the deployment will be stuck in new forever until being cancelled

Expected behavior

Lagoon should make the deployment work irrespective of the characters in a branch name. If it is a valid git branch name, then it should work.

Logs

Seen in lagoon-remote-insights-remote

1.6788638738456466e+09	ERROR	Reconciler error	{"controller": "lagoonbuild", "controllerGroup": "crd.lagoon.sh", "controllerKind": "LagoonBuild", "LagoonBuild": {"name":"lagoon-build-b7jgtf","namespace":"lagoon"}, "namespace": "lagoon", "name": "lagoon-build-b7jgtf", "reconcileID": "efad296e-cbe1-4eb1-b87f-e3c2fa017a30", "error": "There was an error creating the namespace. Error was: Namespace \"example-feature-fixed-css-\" is invalid: [metadata.name: Invalid value: \"example-feature-fixed-css-\": a lowercase RFC 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.labels: Invalid value: \"feature-fixed-css-\": 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])?'), metadata.labels: Invalid value: \"example-feature-fixed-css-\": 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])?')]"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:326
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:273
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:234

Add any other context about the problem here.

@seanhamlin seanhamlin added bug 2-build-deploy Build & Deploy subsystem labels Mar 15, 2023
@tobybellwood
Copy link
Member

hmm, in order to handle this, we'd have to append/remove a character to the branch name where it's used as a label (and potentially anywhere else RFC1123 kicks in)

@shreddedbacon
Copy link
Member

hmm, in order to handle this, we'd have to append/remove a character to the branch name where it's used as a label (and potentially anywhere else RFC1123 kicks in)

https://github.com/uselagoon/lagoon/blob/main/node-packages/commons/src/tasks.ts#L365 we make safe the environment name here, we need to just do a RFC1123 validation too

Other issues are that we do similar makesafe-ing in other code bases that we need to consider. The remote-controller has the final say in what namespace is created though

@shreddedbacon
Copy link
Member

This needs quite a bit of thought before we implement a solution, for now change the branch name to not end in a - is the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-build-deploy Build & Deploy subsystem bug
Projects
None yet
Development

No branches or pull requests

3 participants