Skip to content

Commit

Permalink
Revert "Backport of sentinel: add support for Nomad ACL Token and Nam…
Browse files Browse the repository at this point in the history
…espace into release/1.2.x (#14239)" (#14245)

This reverts commit 39adc3c.
  • Loading branch information
DerekStrickland committed Aug 23, 2022
1 parent 39adc3c commit ef1540d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
3 changes: 0 additions & 3 deletions .changelog/14171.txt

This file was deleted.

34 changes: 11 additions & 23 deletions nomad/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis

// Attach the Nomad token's accessor ID so that deploymentwatcher
// can reference the token later
nomadACLToken, err := j.srv.ResolveSecretToken(args.AuthToken)
tokenID, err := j.srv.ResolveSecretToken(args.AuthToken)
if err != nil {
return err
}
if nomadACLToken != nil {
args.Job.NomadTokenID = nomadACLToken.AccessorID
if tokenID != nil {
args.Job.NomadTokenID = tokenID.AccessorID
}

// Set the warning message
Expand Down Expand Up @@ -315,11 +315,7 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis

// Enforce Sentinel policies. Pass a copy of the job to prevent
// sentinel from altering it.
ns, err := snap.NamespaceByName(nil, args.RequestNamespace())
if err != nil {
return err
}
policyWarnings, err := j.enforceSubmitJob(args.PolicyOverride, args.Job.Copy(), nomadACLToken, ns)
policyWarnings, err := j.enforceSubmitJob(args.PolicyOverride, args.Job.Copy())
if err != nil {
return err
}
Expand Down Expand Up @@ -1706,22 +1702,8 @@ func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse)
}
}

// Acquire a snapshot of the state
snap, err := j.srv.fsm.State().Snapshot()
if err != nil {
return err
}

// Enforce Sentinel policies
nomadACLToken, err := snap.ACLTokenBySecretID(nil, args.AuthToken)
if err != nil && !strings.Contains(err.Error(), "missing secret id") {
return err
}
ns, err := snap.NamespaceByName(nil, args.RequestNamespace())
if err != nil {
return err
}
policyWarnings, err := j.enforceSubmitJob(args.PolicyOverride, args.Job, nomadACLToken, ns)
policyWarnings, err := j.enforceSubmitJob(args.PolicyOverride, args.Job)
if err != nil {
return err
}
Expand All @@ -1730,6 +1712,12 @@ func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse)
reply.Warnings = structs.MergeMultierrorWarnings(warnings...)
}

// Acquire a snapshot of the state
snap, err := j.srv.fsm.State().Snapshot()
if err != nil {
return err
}

// Interpolate the job for this region
err = j.interpolateMultiregionFields(args)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nomad/job_endpoint_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// enforceSubmitJob is used to check any Sentinel policies for the submit-job scope
func (j *Job) enforceSubmitJob(override bool, job *structs.Job, nomadACLToken *structs.ACLToken, ns *structs.Namespace) (error, error) {
func (j *Job) enforceSubmitJob(override bool, job *structs.Job) (error, error) {
return nil, nil
}

Expand Down

0 comments on commit ef1540d

Please sign in to comment.