Skip to content

Commit

Permalink
backport of commit 81d87f1
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed May 24, 2024
1 parent f734d62 commit 8def8f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/22227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
config: Fixed a panic triggered by registering a job specifying a Vault cluster that has not been configured within the server
```
9 changes: 9 additions & 0 deletions nomad/job_endpoint_hook_vault_ce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ func TestJobEndpointHook_VaultCE(t *testing.T) {
warnings, err := hook.Validate(job)
must.Len(t, 0, warnings)
must.NoError(t, err)

// Attempt to validate a job which details a Vault cluster name which has
// no configuration mapping within the server config.
mockJob2 := mock.Job()
mockJob2.TaskGroups[0].Tasks[0].Vault = &structs.Vault{Cluster: "does-not-exist"}

warnings, err = hook.Validate(mockJob2)
must.Nil(t, warnings)
must.EqError(t, err, `Vault "does-not-exist" not enabled but used in the job`)
}
3 changes: 3 additions & 0 deletions nomad/structs/config/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func DefaultVaultConfig() *VaultConfig {

// IsEnabled returns whether the config enables Vault integration
func (c *VaultConfig) IsEnabled() bool {
if c == nil {
return false
}
return c.Enabled != nil && *c.Enabled
}

Expand Down

0 comments on commit 8def8f9

Please sign in to comment.