-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
Admission Controller example panics on objects with no name #942
Comments
Is this something you have ran into in the wild? I agree that it's not great (and I'd like to deprecate |
Yes, I ran into this on a shared development cluster at work. According to the docs, the |
Thanks for the report. I have reworked the EDIT: just |
By the way, what happens when you apply an object without either a |
I tried applying a Pod without a Also, I agree with renaming |
Current and expected behavior
If the admission controller example is given an object without a "name" attribute, it will panic on this line (or the similar line for when it rejects the object):
info!("accepted: {:?} on Foo {}", req.operation, obj.name());
This is because the
name()
method is only supposed to be used when you KNOW that the object has aname
set (which is not the case e.g. for Pods created by a ReplicaSet, which will have thegenerate_name
field set instead).I know it's just an example application, but the lack of name seems like a common enough condition to run into, so the example ought to start people off on the right foot in terms of how to use the
name()
method.Possible solution
Check whether a
name
is set, and if not, usegenerate_name
if that exists, or leave the name blank if there is none.Additional context
No response
Environment
Configuration and features
No response
Affected crates
No response
Would you like to work on fixing this bug?
yes
The text was updated successfully, but these errors were encountered: