mastodon / chart

Helm chart for Mastodon deployment in Kubernetes
GNU Affero General Public License v3.0
152 stars 90 forks source link

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

Open jessebot opened 1 year ago

jessebot commented 1 year ago

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:

https://github.com/mastodon/chart/blob/4b6fd9f7e6273cb2708e5f8e16b87b1d07114eb8/templates/job-db-migrate.yaml#L7-L10

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: ...

  1. After some verification, the library renders the foo templates
  2. The library prepares to execute the pre-install hooks (loading hook resources into Kubernetes)
  3. The library sorts hooks by weight (assigning a weight of 0 by default), by resource kind and finally by name in ascending order.
  4. The library then loads the hook with the lowest weight first (negative to positive)
  5. The library waits until the hook is "Ready" (except for CRDs)
  6. 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.
  7. The library executes the post-install hook (loading hook resources)
  8. The library waits until the hook is "Ready"

But the config map doesn't have anything similar: https://github.com/mastodon/chart/blob/4b6fd9f7e6273cb2708e5f8e16b87b1d07114eb8/templates/configmap-env.yaml#L3-L7

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 https://github.com/mastodon/chart/issues/18 because the job has highest priority and is executed before the configMap would be available.

jessebot commented 1 year ago

Further discussion is taking place in #74