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

remove null env lists #1781

Merged
merged 7 commits into from
Feb 9, 2021
Merged

remove null env lists #1781

merged 7 commits into from
Feb 9, 2021

Conversation

davejrt
Copy link
Contributor

@davejrt davejrt commented Feb 5, 2021

Also ensures each container record starts with the container name

Fixes https://github.com/sourcegraph/sourcegraph/issues/11754

Note: Open to suggestions on how we can avoid the number of merge conflicts this might cause for customers.

@davejrt davejrt requested a review from a team February 5, 2021 16:07
Copy link
Contributor

@uwedeportivo uwedeportivo left a comment

Choose a reason for hiding this comment

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

the only reason i can think of that the empty env keys are there is that we wanted to document in the YAML the place where customers should put env vars.

one way to try to avoid complicated merge conflicts would be to not delete the empty env vars and instead declare some DUMMY env var there. not sure if this is aesthetically acceptable or the merge is easier then. i actually wouldn't vote for it.

@pecigonzalo
Copy link
Contributor

It would be lovely to have some tool that does/validates this sorting

@davejrt
Copy link
Contributor Author

davejrt commented Feb 5, 2021

Yeah, I very much dislike that the stop of each container record isn't the name of the container when I browsing these files. Yaml is bad enough to read but then the title is like...some random arguments or env var it makes it worse.

But I see your point.

@daxmc99
Copy link
Contributor

daxmc99 commented Feb 5, 2021

Kube-linter is a linter that comes to mind here

@davejrt
Copy link
Contributor Author

davejrt commented Feb 5, 2021

kubelinter is nice, but it doesn't seem to specify the order of fields in lists like we do here or if a record as a null value.

running it over master results in this

dave@dave-surface-2:~/sourcegraph/deploy-sourcegraph (master)$ kube-linter lint base --exclude run-as-non-root,no-read-only-root-fs
base/backend.Service.yaml: (object: <no namespace>/backend /v1, Kind=Service) no pods found matching service labels (map[group:backend]) (check: dangling-service, remediation: Make sure your service's selector correctly matches the labels on one of your deployments.)

base/minio/minio.Deployment.yaml: (object: <no namespace>/minio apps/v1, Kind=Deployment) environment variable MINIO_SECRET_KEY in container "minio" found (check: env-var-secret, remediation: Don't use raw secrets in an environment variable. Instead, either mount the secret as a file or use a secretKeyRef. See https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets for more details.)

Error: found 2 lint errors
dave@dave-surface-2:~/sourcegraph/deploy-sourcegraph (master)$

@davejrt
Copy link
Contributor Author

davejrt commented Feb 8, 2021

How comfortable are you with me merging this @daxmc99 @pecigonzalo (ignoring the renovate merge conflicts right now) ? Are we happy to accept the hiccup for those customers not using kustomize here to upgrade to 3.25? Perhaps if anything it's an extra motivation for them to move in that direction?

@pecigonzalo
Copy link
Contributor

@davejrt I would go for it, and announce it in our changelog/release blog (no idea how to coordinate that sorry).

A bit out of scope, but as we are doing this, we might as well just sort all fields as well. Although maybe we can do that as a patch-release so its easier to diff/apply? Not sure, just throwing it out here, Im happy to merge as is to fix this issue and I much prefer the container name being the first item.

@pecigonzalo
Copy link
Contributor

Oh and let CE/CSE know if we do go ahead so they know its coming after release.

Copy link
Contributor

@daxmc99 daxmc99 left a comment

Choose a reason for hiding this comment

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

This change needs to be made eventually. I'm not sure if we should sort the keys in this same PR but the ds-to-dhall tool could provide that functionality.
Could you link a draft PR of the changelog update here as well so that we can coordinate for the release?

@davejrt
Copy link
Contributor Author

davejrt commented Feb 8, 2021

@daxmc99 changlog draft added merge conflicts sorted out. I did a trial with ds-to-dhall but we do lose the fact that name is always the top of the list...which frankly is a feature I really like. Perhaps there's something we can do later but I think for now this satisfies the immediate concern with this issue.

@davejrt davejrt merged commit d6ceb1e into master Feb 9, 2021
@davejrt davejrt deleted the dt/remove_nulls branch February 9, 2021 14:35
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.

upgrade prevented with obscure errors due to null env lists in k8s YAML / indention errors
4 participants