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

resource/job: set namespace on register #386

Merged
merged 3 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ IMPROVEMENTS:
BUG FIXES:
* resource/nomad_acl_policy: fixed a bug where the namespace would be incorrectly calculated from a job identity ([#396](https://github.com/hashicorp/terraform-provider-nomad/pull/396))
* resource/nomad_csi_volume_registration: fixed a bug that cause an import operation to not load all of the volume attributes ([#402](https://github.com/hashicorp/terraform-provider-nomad/pull/402))
* resource/nomad_job: fixed a bug that could cause jobs to be registered in the incorrect namespace if the `NOMAD_NAMESPACE` environment variable is set ([#386](https://github.com/hashicorp/terraform-provider-nomad/pull/386))
* resource/nomad_volume: fixed a bug that cause an import operation to not load all of the volume attributes ([#402](https://github.com/hashicorp/terraform-provider-nomad/pull/402))

## 2.0.0 (August 28th, 2023)
Expand Down
9 changes: 6 additions & 3 deletions nomad/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,12 @@ func resourceJobRegister(d *schema.ResourceData, meta interface{}) error {
if err != nil {
wantModifyIndex = 0
}

resp, _, err := client.Jobs().RegisterOpts(job, &api.RegisterOptions{
PolicyOverride: d.Get("policy_override").(bool),
ModifyIndex: wantModifyIndex,
}, nil)
}, &api.WriteOptions{
Namespace: *job.Namespace,
})
if err != nil {
return fmt.Errorf("error applying jobspec: %s", err)
}
Expand Down Expand Up @@ -695,7 +696,9 @@ func resourceJobCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta in
resp, _, err := client.Jobs().PlanOpts(job, &api.PlanOptions{
Diff: false,
PolicyOverride: d.Get("policy_override").(bool),
}, nil)
}, &api.WriteOptions{
Namespace: *job.Namespace,
})
if err != nil {
log.Printf("[WARN] failed to validate Nomad plan: %s", err)
}
Expand Down