Skip to content

Commit

Permalink
tproxy: add implicit constraint on client version (hashicorp#20623)
Browse files Browse the repository at this point in the history
The new transparent proxy feature already has an implicity constraint on the
presence of the CNI plugin. But if the CNI plugin is installed on an older
version of Nomad, this isn't sufficient to protect against placing tproxy
workloads on clients that can't support it. Add a Nomad version constraint as
well.

Fixes: hashicorp#20614
  • Loading branch information
tgross authored May 17, 2024
1 parent b5bca27 commit 5a6262d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nomad/job_endpoint_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ var (
RTarget: ">= 1.4.2",
Operand: structs.ConstraintSemver,
}

// tproxyConstraint is an implicit constraint added to jobs making use of
// transparent proxy mode
tproxyConstraint = &structs.Constraint{
LTarget: attrNomadVersion,
RTarget: ">= 1.8.0-dev",
Operand: structs.ConstraintSemver,
}
)

type admissionController interface {
Expand Down Expand Up @@ -335,6 +343,7 @@ func (jobImpliedConstraints) Mutate(j *structs.Job) (*structs.Job, []error, erro

if transparentProxyTaskGroups.Contains(tg.Name) {
mutateConstraint(constraintMatcherLeft, tg, cniConsulConstraint)
mutateConstraint(constraintMatcherLeft, tg, tproxyConstraint)
}
}

Expand Down
1 change: 1 addition & 0 deletions nomad/job_endpoint_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ func Test_jobImpliedConstraints_Mutate(t *testing.T) {
cniLoopbackConstraint,
cniPortMapConstraint,
cniConsulConstraint,
tproxyConstraint,
},
},
},
Expand Down

0 comments on commit 5a6262d

Please sign in to comment.