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

helm install order of operations prioritizes db migrate job before env #73

Open
jessebot opened this issue Jul 6, 2023 · 1 comment

Comments

@jessebot
Copy link
Contributor

jessebot commented Jul 6, 2023

When installing this chart via ArgoCD, it always tries to create job-db-migreate.yaml first, but it can't run the job without the configmap-env.yaml being applied, but the config map can't be applied because the job is set to run before everything else via a helm hook:

annotations:
"helm.sh/hook": post-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-2"

According to the helm docs:

pre-install - Executes after templates are rendered, but before any resources are created in Kubernetes
post-install - Executes after all resources are loaded into Kubernetes

and the same docs further down:

Helm defines two hooks for the install lifecycle: pre-install and post-install. If the developer of the foo chart implements both hooks, the lifecycle is altered like this:
...
4. After some verification, the library renders the foo templates
5. The library prepares to execute the pre-install hooks (loading hook resources into Kubernetes)
6. The library sorts hooks by weight (assigning a weight of 0 by default), by resource kind and finally by name in ascending order.
7. The library then loads the hook with the lowest weight first (negative to positive)
8. The library waits until the hook is "Ready" (except for CRDs)
9. The library loads the resulting resources into Kubernetes. Note that if the --wait flag is set, the library will wait until all resources are in a ready state and will not run the post-install hook until they are ready.
10. The library executes the post-install hook (loading hook resources)
11. The library waits until the hook is "Ready"

But the config map doesn't have anything similar:

metadata:
name: {{ include "mastodon.fullname" . }}-env
labels:
{{- include "mastodon.labels" . | nindent 4 }}
data:

I can submit a PR to add the following to the configmap-env.yaml:

metadata:
  annotations: 
    "helm.sh/hook": pre-install
    "helm.sh/hook-weight": "-3"

I believe this might also affect #18 because the job has highest priority and is executed before the configMap would be available.

@jessebot
Copy link
Contributor Author

jessebot commented Jul 6, 2023

Further discussion is taking place in #74

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

No branches or pull requests

1 participant