-
Notifications
You must be signed in to change notification settings - Fork 387
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
STOR-2040: CLI command to display bound pvc filesystem usage percentage #1854
base: master
Are you sure you want to change the base?
Conversation
@gmeghnag: This pull request references STOR-2040 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Thank you for spending time on this nice and useful feature. But that requires a KEP first to sync on the feature and implementation. |
Hey @ardaguclu, what is a KEP? And how to create one? Thanks :) |
I think, you'd write an enhancement proposal under /~https://github.com/openshift/enhancements/tree/master/enhancements/oc and we'll discuss the design and align on it. Once it merges, we can return to this PR. |
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.
Thanks a lot @gmeghnag :) This is nice work, I just have a few suggestions.
/retest |
/test e2e-agnostic-ovn-cmd |
/retest |
DO NOT MERGE, I have to fix first https://issues.redhat.com/browse/OCPBUGS-44011 |
/retest |
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 still believe that this is a cool feature and thanks for spending time on this. I think it requires major code refactorings though.
/label tide/merge-method-squash
@@ -0,0 +1,382 @@ | |||
package top |
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.
Since you'll be the maintainer of this command, there should be a separate OWNERS file like this /~https://github.com/openshift/oc/blob/master/pkg/cli/admin/inspectalerts/OWNERS
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 comment is still valid. We need OWNERS file to maintain and triage the issues with respect to this comment.
@ardaguclu Thank you a lot for the code review! Before spending time answering your questions and proceeding with the code modifications I would like to ask @tsmetana if doing so will make this PR merged, because, from our last chat I understood that you (with the storage leads) chose to go upstream first with this functionality, and doing so will probably need a different approach since Prometheus is not provided by default in vanilla Kubernetes. In short, I don't want to spend time modifying the code if this PR will not be merged anyway. Thanks |
@gmeghnag labelling the feature as experimental is exactly what would make it merge even if we want to implement this also in upstream Thanks for the awesome work! |
@ardaguclu @tsmetana I've updated the PR, please let me know if anything else is needed! (: |
/retest-required |
Thank you. I quickly skimmed over the current code but we need to iterate a couple of times to be ready for merge. I think, it would be safer to defer this to 4.19 as unfortunately I don't have time for 4.18. |
for _, promOutputDataResult := range promOutput.Data.Result { | ||
namespaceName := promOutputDataResult.Metric["namespace"] | ||
pvcName := promOutputDataResult.Metric["persistentvolumeclaim"] | ||
usagePercentage := promOutputDataResult.Value[1] |
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.
How do we know promOutputDataResult.Value
's length is greater than 1 and we don't panic?
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.
Because this is a "dogma" from Prometheus output, see here [1][2]:
Instant vectors are returned as result type vector. The corresponding result property has the following format:
[
{
"metric": { "<label_name>": "<label_value>", ... },
"value": [ <unix_time>, "<sample_value>" ],
"histogram": [ <unix_time>, <histogram> ]
},
...
]
[1] https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries
[2] https://prometheus.io/docs/prometheus/latest/querying/api/#instant-vectors
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gmeghnag The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -0,0 +1,382 @@ | |||
package top |
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 comment is still valid. We need OWNERS file to maintain and triage the issues with respect to this comment.
|
||
const ( | ||
localhostRecoveryTokenSecret = "localhost-recovery-client-token" | ||
kubeApiserverNamespace = "openshift-kube-apiserver" |
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 don't think using an arbitrary namespace would be allowed (especially using the openshift-kube-apiserver
which is an important one). If there is no bearer tokens, it is better to return error?.
// RouteGetter is a function that gets a Route. | ||
type RouteGetter func(ctx context.Context, namespace string, name string, opts metav1.GetOptions) (*routev1.Route, error) | ||
|
||
type options struct { |
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.
options
is unexported which makes sense but why some of its fields are exported?
BearerToken string | ||
} | ||
|
||
func newOptions(streams genericiooptions.IOStreams) *options { |
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.
nit: Better to export
o.BearerToken = o.ClientConfig.BearerToken | ||
if len(o.ClientConfig.BearerToken) == 0 { | ||
klog.V(4).Info(fmt.Sprintf(`no token is currently in use for this session, attempting to retrieve token from secret "%s" in namespace "%s"`, localhostRecoveryTokenSecret, kubeApiserverNamespace)) | ||
secret, err := o.ClientSet.CoreV1().Secrets(kubeApiserverNamespace).Get(context.TODO(), localhostRecoveryTokenSecret, metav1.GetOptions{}) |
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 need to continue with whatever we have defined in kubeconfig and should not try to use any other secret, etc.
return body, nil | ||
} | ||
|
||
type PromOutput struct { |
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 can unexport this and the other nested ones.
|
||
reviewers: | ||
- gmeghnag | ||
- ardaguclu |
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.
It is better to add approvers and reviewers from which team will maintain this. I'd prefer not to be in here.
@@ -0,0 +1,8 @@ | |||
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md |
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.
pkg/cli/admin/top
command exists and it is maintained by workloads team. What about moving this command to pkg/cli/admin/toppvc
, etc. and have dedicated OWNERS?.
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.
It is also better to have an alias like this /~https://github.com/openshift/oc/blob/master/pkg/cli/admin/inspectalerts/OWNERS and
Line 9 in e005223
monitoring-approvers: |
|
||
func (o *options) Run(ctx context.Context, args []string) error { | ||
o.BearerToken = o.ClientConfig.BearerToken | ||
if len(o.ClientConfig.BearerToken) == 0 { |
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.
Also keep in mind that, kubeconfig has many fields to access cluster, not only bearer token. As a result, this command will not be usable if kubeconfig authentication mechanism is certificates, exec credential plugins, etc.
@gmeghnag: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
The code makes use of a Prometheus query to implement the
oc adm top persistentvolumeclaims
and show usage statistics for bound persistentvolumeclaims, as follows:It supports the following flags: