-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Refactoring reorganize taints function in kubectl to expose operations #43171
Refactoring reorganize taints function in kubectl to expose operations #43171
Conversation
Hi @ravisantoshgudimetla. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with 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/test-infra repository. I understand the commands that are listed here. |
/cc @jayunit100. |
@smarterclayton PTAL. |
@k8s-bot ok to test |
@fabianofranz - As I not able to mention sig-cli and sig-cli-pr-reviewers. |
@kubernetes/sig-cli-pr-reviews |
@fabianofranz I just wanted to make sure if this PR can be reviewed as 1.6 code freeze has officially ended. |
pkg/kubectl/cmd/taint.go
Outdated
@@ -366,23 +382,20 @@ func validateNoTaintOverwrites(obj runtime.Object, taints []v1.Taint) error { | |||
} | |||
|
|||
// updateTaints updates taints of obj |
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.
can we improve this comment as part of this PR? the fact that its validating, and reorganizing, ... not sure what 'update' really is doing
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 am just reorganizing in this PR. I will create one more with some other modifications.
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.
Please update the comment here. There's no point of having separate PR for that - we want to keep review load as low as possible.
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.
Makes sense...
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.
Done.
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 don't see fixed comment...
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.
@ravisantoshgudimetla updateTaints applies taints to a node in a clusters and returns a human understandable description of the resulting operation.
pkg/kubectl/cmd/taint.go
Outdated
return allErrs, taintsBefore != len(*newTaints) | ||
} | ||
|
||
// AddTaints adds the newTaints list to existing ones and updates the newTaints List. |
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.
s/AddTaints/addTaints
for godoc . surprised this isnt caught by golint actually...
pkg/kubectl/cmd/taint.go
Outdated
allErrs := []error{} | ||
taintsBefore := len(*newTaints) | ||
for _, taintToRemove := range taintsToRemove { | ||
removed := false | ||
if len(taintToRemove.Effect) > 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.
Do you think we can make this taintToRemove.Effect != ""
? Otherwise seems to imply that there can be multiple effects....
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.
When can do that but the problem is Effect here is a type again. So this is the convention that others have been using in other locations as well.
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.
can you clarify Effect here is type again
? If !=
works it seems like a better comparison.
pkg/kubectl/cmd/taint.go
Outdated
} | ||
if !removed { | ||
allErrs = append(allErrs, fmt.Errorf("taint %q not found", taintToRemove.ToString())) | ||
} | ||
} | ||
return newTaints, utilerrors.NewAggregate(allErrs) | ||
return allErrs, taintsBefore != len(*newTaints) |
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.
is this redundant to saying return allErrs, len(allErrs) > 0
? if so i'd say just return []error
as the function header , rather then []error, 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.
So, here the errors are different and taints are different, we are returning errors as well as checking if the original length of taints list is equal to old length of taints to check if some of them got deleted.
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.
Isn't the latter equivalent to removed
, i.e. it's always true
if we reached this part of the code?
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 guess not, if we do not enter the loop in first place, we cannot return true and 'removed' variable is declared inside loop. So, if we have removed outside loop, then I guess we can.
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.
Fair point. I think such change would make the code cleaner.
lgtm but im not an owner for this section |
The above one seem a bit confusing as there might still be other taints left.
In general, I am wondering how these UI changes are going to be helpful? May be I am missing something? Also there are several possibilities I am not sure these UI changes cover all of them: On one or multiple nodes:
|
So the composite operations(which are complementary like adding taints and deleting them) in a single command will always result in "modified" output, if the composite operations are non-complementary(in this case addition of multiple taints or removal of them) will always result in either "tainted" or "untainted". If you have atleast one overwritten operation, the output will be "overwritten". This is something that I came up with but if you have other suggestions, I am more than happy to include. |
@aveshagarwal do you agree that we should provide more feedback ? or you think just saying 'tainted' is enough.
But
So
|
@kubernetes/sig-scheduling-pr-reviews |
pkg/kubectl/cmd/taint.go
Outdated
@@ -40,6 +40,13 @@ import ( | |||
utiltaints "k8s.io/kubernetes/pkg/util/taints" | |||
) | |||
|
|||
const ( | |||
MODIFIED = "modified" |
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 should not be here.
They should either be in a scheduling library or near the api itself.
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.
To decide where the right place is, we should decide: what is this describing .... I guess maybe we could satisfy tim's suggestion by making this more localized.
- localize the definitions If this is describing a kubelet result, then I guess putting them here and making them more descriptive is ok, i.e
MODIFICATION="taint was modified"
UNTAINTED="taint was removed"
... and so on, we can isolate the semantics unambiguously to kubectl
so that this doesn't blur the lines between API constants and UX constants.
- In addition, we should unexport these (i.e. s/MODIFIED/modified).
I think (1) + (2) might make this less 'sprawly'
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.
@timothysc These are the constants that are being used in output of kubectl, doesn't it make sense to have them here instead of API?
@jayunit100 This gets appended to 'node 'XYZ' from printSuccess at https://github.com/kubernetes/kubernetes/pull/43171/files#diff-92dd749c11309adffd4b2b2112b36303R364. I guess a better way would be to remove 'node 'XYZ' ' part when printing and tell if the taint was added or deleted. I guess that will be a different PR but if you want it, I can include it here.
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 we can all agree these constants shouldnt be exported , if they are going to be specific to kubectl result processing, then i think thats ok. as of now they are higher level then that , which is why tim has mentioned they shouldn't be here.
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.
Wherever we decide to put it, I think we should just use standard verbs: Added, Removed, Modified.
e896611
to
cd4dba8
Compare
56f7c17
to
2aeaaaa
Compare
@k82cn Apologies for the confusion. I was trying to access files from another machine and messed up my git history. There is no generated code in my case as I am touching a single file :). |
2aeaaaa
to
0a4bc34
Compare
0a4bc34
to
941a778
Compare
@ravisantoshgudimetla: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
941a778
to
148f109
Compare
pkg/kubectl/cmd/taint.go
Outdated
@@ -366,24 +379,21 @@ func validateNoTaintOverwrites(obj runtime.Object, taints []v1.Taint) error { | |||
return utilerrors.NewAggregate(allErrs) | |||
} | |||
|
|||
// updateTaints updates taints of obj | |||
func (o TaintOptions) updateTaints(obj runtime.Object) error { | |||
// updateTaints applies a taint option(o) to a node in cluster after validating conditions like overwriting of option and returns a human understandable description of the said option result. |
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.
+// updateTaints applies a taint option (o) to a node in the cluster, and after computing the net effect of the operation (i.e. does it result in an overwrite?), it reports the end result back in a way that a user can easily interpret.
148f109
to
5bdf79b
Compare
@gmarek @timothysc @adohe PTAL , LGTM on my end. |
bump :) |
/lgtm |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jayunit100, ravisantoshgudimetla
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Ping @sig-cli-maintainers this one is ready to merge now, reached consensus. |
Automatic merge from submit-queue |
What this PR does / why we need it:
This adds some UX functionality when specifying taints using kubectl.
For example:
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #43167Release note: