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
Adding default StorageClass annotation printout for resource_printer and describer and some refactoring #34638
Conversation
Can a kubernetes member verify that this patch is reasonable to test? If so, please reply with "@k8s-bot ok to test" on its own line. Regular contributors should join the org to skip this step. |
@screeley44 This is very useful! +1 |
LGTM. @eparis Put you as reviewer since you are closer to the area. |
@k8s-bot ok to test |
@screeley44 @erinboyd I'm cc'ing sig-cli. My gut feeling is that customers are likely to have some number 2-10 StorageClasses and only 1 default. Multiple defaults, while possible, aren't likely to be the norm. Do we really want an entire column for this? Do we have any precedent for other ways to indicate something like this? Also, what does kubectl describe show? @kubernetes/sig-cli I will point out I'm not questioning the need to show this information. I'm questioning HOW to show this information. |
I would like not use an entire column for this, how about this:
|
@adohe - I like your suggestion much better, I updated the PR
|
@eparis - I handle the describe stuff in another PR #34495 for storageclass, pv and pvc ... some example output below
|
@@ -60,6 +60,9 @@ const ( | |||
loadBalancerWidth = 16 | |||
) | |||
|
|||
// This indicates that a particular StorageClass nominates itself as the system default. | |||
const betaAnnotation = "storageclass.beta.kubernetes.io/is-default-class" |
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 used the name default
as the default serviceaccount and that has worked reasonably well for us. It ensures nothing collides (can't have two defaults) and avoids special markings like this.
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.
that part has been all sorts of discussed between thockin and Jan. I'm more interested if its worth it to define something like isDefaultAnnotation
on the storage class object or something, instead of having the const
name twice...
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.
between plugin/pkg/admission/storageclass/default/admission.go this PR and 34495 we've now scattered the test across 3 places in the code. Lets find a way to determine this in a single place.
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.
@eparis - how about this, for now we can use exported const in the types.go from the storage package, that way we have a single place to maintain these and they are easily accessible...
closing #34495 and combining into this PR |
@@ -162,6 +162,25 @@ func init() { | |||
DefaultObjectDescriber = d | |||
} | |||
|
|||
func getStorageClassAnnotation(obj api.ObjectMeta) string { |
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.
Seems to me like we should be moving getVolumeClass
and getClaimClass
from controller/volume/persistentvolume/pv_controller_base.go
to pkg/api/helpers.go
.
We should also implement an IsDefaultStorageClass()
function in a new pkg/apis/storage/helpers.go
These helpers should be used everywhere. You missed the usages in controller/volume/persistentvolume/*
@@ -162,6 +162,25 @@ func init() { | |||
DefaultObjectDescriber = d | |||
} | |||
|
|||
func getStorageClassAnnotation(obj api.ObjectMeta) string { | |||
if obj.Annotations[storage.BetaStorageClassAnnotation] != "" { |
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 think this would be better as below so correctly handly the explicitly set to empty.
if class, ok := obj.Annotations[storage.BetaStorageClassAnnotation]; ok {
return class
}
return "" | ||
} | ||
|
||
func isDefaultAnnotation(obj api.ObjectMeta) string { |
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 function might be 'ok-ish' here, but since I want a generic function that one needs to return a bool
@@ -2078,8 +2078,16 @@ func printNetworkPolicyList(list *extensions.NetworkPolicyList, w io.Writer, opt | |||
return nil | |||
} | |||
|
|||
func hasDefaultAnnotation(obj api.ObjectMeta) bool { |
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 is basically a duplicate of the isDefaultAnnotation()
function above. So it should disappear when you move the generic function which returns a bool
@@ -121,7 +115,7 @@ func (c *claimDefaulterPlugin) Admit(a admission.Attributes) error { | |||
return nil | |||
} | |||
|
|||
_, found := pvc.Annotations[classAnnotation] | |||
_, found := pvc.Annotations[storage.BetaStorageClassAnnotation] |
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.
These will all move to your new generic GetClaimStorageClass()
function.
Jenkins GCE Node e2e failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins GCI GCE e2e failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins Kubemark GCE e2e failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE etcd3 e2e failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins GCE e2e failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins verification failed for commit ae569492631b117bf666750024e57be0d34faca1. Full PR test history. The magic incantation to run this job again is |
Jenkins unit/integration failed for commit 785d2228ecb8fd0d34c3f9abaccac8374d829173. Full PR test history. The magic incantation to run this job again is |
@eparis - not sure how to handle the smoke test failure, any tips? I couldn't find any flakes and there isn't a lot of info in the logs to help diagnose |
Jenkins GKE smoke e2e failed for commit 86f1a94. Full PR test history. The magic incantation to run this job again is |
@jsafrane this might conflict with some work you are doing. so whoever loses the race is likely to need to rebase. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Jenkins GCI GKE smoke e2e failed for commit 86f1a94. Full PR test history. The magic incantation to run this job again is |
Automatic merge from submit-queue |
adding ISDEFAULT for kubectl get storageclass output
@kubernetes/sig-storage
This change is