up icon indicating copy to clipboard operation
up copied to clipboard

Invalid labels cause install to fail partially completed

Open plumbis opened this issue 3 years ago • 1 comments

What happened?

When applying a custom configuration file using up uxp install -f with an invalid label the UXP install fails but some components are still created. The error is caught when k8s is trying to create serviceaccount resources.

$ up uxp install -f config.yml
up: error: ServiceAccount "rbac-manager" is invalid: metadata.labels: Invalid value: "@upbound": 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])?')

$ kubectl get serviceaccounts -n upbound-system
NAME                   SECRETS   AGE
default                0         32m
upbound-agent          0         4s
upbound-bootstrapper   0         4s
xgql                   0         4s

The main problem here is that we've crated some resources and failed. Correcting the problem and trying again with up uxp install -f will fail since the chart is installed.

$ up uxp install
up: error: chart already installed with version 1.8.1-up.2

The issue can be worked around with up uxp uninstall and then up uxp install -f with a corrected file.

$ up uxp uninstall

$ kubectl get serviceaccounts -n upbound-system
NAME      SECRETS   AGE
default   0         38m

$ up uxp install

How can we reproduce it?

Create a configuration file that is invalid, for example

customLabels:
  app.kubernetes.io/created-by: "@upbound"

Provide this install file to up uxp install -f

What environment did it happen in?

up --version
v0.12.0

plumbis avatar Jul 27 '22 19:07 plumbis