-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow setting spec.template.spec.automountServiceAccountToken in PodSpec #11723
Allow setting spec.template.spec.automountServiceAccountToken in PodSpec #11723
Conversation
Codecov Report
@@ Coverage Diff @@
## main #11723 +/- ##
==========================================
- Coverage 87.83% 87.81% -0.03%
==========================================
Files 196 196
Lines 9364 9365 +1
==========================================
- Hits 8225 8224 -1
- Misses 886 887 +1
- Partials 253 254 +1
Continue to review full report at Codecov.
|
pkg/apis/serving/fieldmask.go
Outdated
@@ -183,6 +183,7 @@ func PodSpecMask(ctx context.Context, in *corev1.PodSpec) *corev1.PodSpec { | |||
out.Volumes = in.Volumes | |||
out.ImagePullSecrets = in.ImagePullSecrets | |||
out.EnableServiceLinks = in.EnableServiceLinks | |||
out.AutomountServiceAccountToken = in.AutomountServiceAccountToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I remembered we were going to have this only allow false
, since true
could theoretically make things less secure (if an administrator had set AutomountServiceAccountToken
= false on the service account), but looks like that was never written on the issue 🤔. TBH maybe this is fine, though, interested in opinions @dprotaso @markusthoemmes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just allow setting this only to false for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
I think you're missing some updates to the schema file which is why verify is failing |
pkg/apis/serving/fieldmask.go
Outdated
@@ -183,6 +183,10 @@ func PodSpecMask(ctx context.Context, in *corev1.PodSpec) *corev1.PodSpec { | |||
out.Volumes = in.Volumes | |||
out.ImagePullSecrets = in.ImagePullSecrets | |||
out.EnableServiceLinks = in.EnableServiceLinks | |||
// Only allow setting AutomountServiceAccountToken to false | |||
if !*in.AutomountServiceAccountToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll panic because of a nil pointer deref, you'll want to do if in.AutomountServiceAccountToken != nil && !*in.AutomountServiceAccountToken
pkg/apis/serving/fieldmask.go
Outdated
@@ -183,6 +183,10 @@ func PodSpecMask(ctx context.Context, in *corev1.PodSpec) *corev1.PodSpec { | |||
out.Volumes = in.Volumes | |||
out.ImagePullSecrets = in.ImagePullSecrets | |||
out.EnableServiceLinks = in.EnableServiceLinks | |||
// Only allow setting AutomountServiceAccountToken to false | |||
if !*in.AutomountServiceAccountToken && in.AutomountServiceAccountToken != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's backwards, will still panic. The &&
short-circuits, so if you turn this around, the second !*in.AutomountServiceAccountToken
won't even be executed if in.AutomountServiceAccountToken != nil
is false.
}, { | ||
name: "with automountServiceAccountToken (ok)", | ||
ps: corev1.PodSpec{ | ||
AutomountServiceAccountToken: &falseValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a helper ptr.Bool(false)
pkg/apis/serving/fieldmask.go
Outdated
// Only allow setting AutomountServiceAccountToken to false | ||
if in.AutomountServiceAccountToken != nil { | ||
if *in.AutomountServiceAccountToken { | ||
out.AutomountServiceAccountToken = nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say just delete this block - it shouldn't be necessary
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, psschwei The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #9127
Proposed Changes
spec.template.spec.automountServiceAccountToken
in the PodSpec for a kserviceRelease Note