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

plan: inform user if a deployment will be created #24646

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

schmichael
Copy link
Member

Description

Just a proof of concept because the plan output when deployments are involved is a bit non-obvious. When updating a job with count=3, the plan will only show the first step of the deployment (as determined by update.max_parallel):

+/- Job: "sleeper"
+/- Task Group: "sleeper" (1 create/destroy update, 2 ignore)
  +/- Task: "sleeper" (forces create/destroy update)
      +/- Config {

This hack plumbs through whether a deployment was attached to the plan. Obviously the output and field names need improving. For backward compatibility we probably shouldn't output anything if there isn't a deployment, but this PoC includes a message for either case for ease of testing/demonstration.

Testing & Reproduction steps

  1. nomad job run -var dur=60 sleeper.nomad.hcl
  2. nomad job plan -var dur=900 sleeper.nomad.hcl

sleep.nomad.hcl

variable "dur" {
  type = string
}

job "sleeper" {
  group "sleeper" {
    count = 3

    task "sleeper" {
      driver = "raw_exec"

      config {
        command = "sleep"
        args = [var.dur]
      }
    }
  }
}

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad website documentation to reflect this. Refer to
    the website README for docs guidelines. Please also consider whether the
    change requires notes within the upgrade guide.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.

Just a proof of concept because the plan output when deployments are
involved is a bit non-obvious. When updating a job with count=3, the
plan will only show the first step of the deployment (as determined by
update.max_parallel):

```
+/- Job: "sleeper"
+/- Task Group: "sleeper" (1 create/destroy update, 2 ignore)
  +/- Task: "sleeper" (forces create/destroy update)
      +/- Config {
```

This hack plumbs through whether a deployment was attached to the plan.
Obviously the output and field names need improving. For backward
compatibility we probably shouldn't output _anything_ if there isn't a
deployment, but this PoC includes a message for either case for ease of
testing/demonstration.
Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

I like this overall idea. I'd probably return some kind of object rather than a boolean here, because once you have this information you pretty much always want to add to it (ex. "this will create a deployment with X and Y attributes").

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.

2 participants