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

Prestart / Init task continues to render templates #15419

Open
joliver opened this issue Nov 30, 2022 · 1 comment · May be fixed by #15436
Open

Prestart / Init task continues to render templates #15419

joliver opened this issue Nov 30, 2022 · 1 comment · May be fixed by #15436
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/task lifecycle type/bug

Comments

@joliver
Copy link

joliver commented Nov 30, 2022

  • Nomad v1.4.3
  • Ubuntu 22.04.1 LTS (Linux 5.15.0-53-generic)

When a given init/prestart task completes successfully, it appears that any template defintions for that task with Vault secrets are continually updated--even beyond the lifetime of the prestart task.

The expected behavior is that, once a task concludes, all templates associated with it are no longer updated.

Here's an example job file that demonstrates the issue:

job "my-job" {
  datacenters = ["default"]

  group "primary" {
    count = 1

    task "main" {
      driver = "exec"

      config {
        command = "sleep"
        args    = ["infinity"]
      }
    }

    task "init" {
      driver = "exec"

      lifecycle { hook = "prestart" } # init task, once it exits, the template shouldn't be re-rendered

      vault { policies = [ "vault-policy-here" ] }

      config {
        command = "echo" # arbitrary command; typically much more happening here
        args    = ["done"]
      }

      # new secret.txt file is re-rendered every few minutes even after completion of init (prestart) task
      template {
        change_mode = "noop"
        destination = "${NOMAD_SECRETS_DIR}/secret.txt"
        data        = <<-EOT
          {{- with secret "gcp/my-service-account/my-reader/token" -}}
          {{ .Data.token }}
          {{- end -}}
        EOT
      }
    }
  }
}
@lgfa29
Copy link
Contributor

lgfa29 commented Nov 30, 2022

Thanks for the report @joliver!

#14127 refactored how tasks with lifecycle run, preventing them from fully stopping to allow restarting all tasks in the allocation. This left to some of the background work that tasks do (such as updating templates) alive unnecessarily.

I opened #15436 to address this issue.

@lgfa29 lgfa29 added theme/task lifecycle stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Nov 30, 2022
@tgross tgross added this to Needs Triage in Nomad - Community Issues Triage via automation Feb 13, 2023
@tgross tgross moved this from Needs Triage to Needs Roadmapping in Nomad - Community Issues Triage Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/task lifecycle type/bug
Projects
Status: Needs Roadmapping
Development

Successfully merging a pull request may close this issue.

2 participants