Skip to content

Commit cd8c6ee

Browse files
committed
fix: panic introduced by hashicorp#8453
Signed-off-by: Yoan Blanc <[email protected]>
1 parent cfe4f83 commit cd8c6ee

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

nomad/job_endpoint_oss.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
package nomad
44

55
import (
6+
"errors"
67
"fmt"
78
"strings"
89

910
"github.com/hashicorp/nomad/nomad/structs"
1011
vapi "github.com/hashicorp/vault/api"
1112
)
1213

14+
// MultipleNamespacesErr is send when multiple namespaces are used in the OSS setup
15+
var MultipleNamespacesErr = errors.New("multiple vault namespaces requires Nomad Enterprise")
16+
1317
// enforceSubmitJob is used to check any Sentinel policies for the submit-job scope
1418
func (j *Job) enforceSubmitJob(override bool, job *structs.Job) (error, error) {
1519
return nil, nil
@@ -51,7 +55,7 @@ func (j *Job) multiVaultNamespaceValidation(
5155
) error {
5256
requestedNamespaces := structs.VaultNamespaceSet(policies)
5357
if len(requestedNamespaces) > 0 {
54-
return fmt.Errorf("multiple vault namespaces requires Nomad Enterprise, Namespaces: %s", strings.Join(requestedNamespaces, ", "))
58+
return fmt.Errorf("%w, Namespaces: %s", MultipleNamespacesErr, strings.Join(requestedNamespaces, ", "))
5559
}
5660
return nil
5761
}

nomad/job_endpoint_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ func TestJobEndpoint_Register_Vault_MultiNamespaces(t *testing.T) {
17371737
err := msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp)
17381738
// OSS or Ent check
17391739
if s1.EnterpriseState.Features() == 0 {
1740-
require.Contains(t, err.Error(), "multiple vault namespaces requires Nomad Enterprise")
1740+
require.True(t, errors.Is(err, MultipleNamespacesErr))
17411741
} else {
17421742
require.NoError(t, err)
17431743
}

0 commit comments

Comments
 (0)