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
Make delete actually stop resources by default. #7210
Conversation
@deads2k too for good measure ;) |
And cc @jlowdermilk We could put a deprecated message on the stop command, like we did for rollingupdate. |
err := r.Visit(func(info *resource.Info) error { | ||
found++ | ||
reaper, err := f.Reaper(info.Mapping) | ||
cmdutil.CheckErr(err) |
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.
Probably don't want to fatal
in here. Can you return the error instead?
Oh, sorry for the dupe. PR versus commit.
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.
Comments addressed. I'm not convinced we should deprecate We should alias them together, though. |
8f583bb
to
aeba3ad
Compare
Without reading the PR, SGTM. How do we do a "delete and abandon" ? On Thu, Apr 23, 2015 at 3:01 PM, Brendan Burns notifications@github.com
|
Delete and abandon is delete --recursive=false. I'm fine with aliasing stop and delete, though we should document that: #5370. |
LGTM. +1 to keeping stop as an alias for delete --recursive=true |
What happens if you |
@@ -86,3 +63,24 @@ func NewCmdStop(f *cmdutil.Factory, out io.Writer) *cobra.Command { | |||
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources") | |||
return cmd | |||
} | |||
|
|||
func DoStop(f *cmdutil.Factory, cmd *cobra.Command, args []string, filenames util.StringList, out io.Writer) error { |
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... I think it's usually Run*, so RunStop.
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.
Is |
If the outcome of this PR is that delete == stop, does it just make sense to make stop an alias to delete in this PR? |
--cascade ? On Thu, Apr 23, 2015 at 8:49 PM, Sam Ghods notifications@github.com wrote:
|
+1 for --cascade Sent from my iPhone
|
Aren't options like "--delete-only=true" or "--graceful=false" more appropriate? --cascade still sounds like there are more objects to deal with, whereas that's not true with pods, or other objects we introduce that exclusive to themselves have a graceful and non-graceful way to stop. |
I think "graceful" and "cascade" are orthogonal ideas, and even though they On Thu, Apr 23, 2015 at 11:31 PM, Sam Ghods notifications@github.com
|
f663c3c
to
56d0ebe
Compare
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
CLAs look good, thanks! |
Switched to I will add the alias in a different PR. Please take another look. Thanks! |
@@ -50,6 +50,7 @@ func TestDeleteObjectByTuple(t *testing.T) { | |||
|
|||
cmd := NewCmdDelete(f, buf) | |||
cmd.Flags().Set("namespace", "test") | |||
cmd.Flags().Set("recursive", "false") |
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.
Should be change to cascade (everywhere).
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.
Comments addressed, please re-check. Thanks! |
Friendly ping on this. Thanks! |
reaper, err := f.Reaper(info.Mapping) | ||
if err != nil { | ||
// If the error is "not found" and the user didn't explicitly set "cascade" just delete. | ||
if kubectl.IsNoSuchReaperError(err) && !cmd.Flags().Lookup("cascade").Changed { |
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 will crash (nil deref I think) if you call it from kubectl/cmd/stop, because stop does not define a "cascade" flag. This error handling should be moved into RunDelete
.
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. (can't do it in RunDelete
because I do want to Stop those things that support stop, and not delete everything just because something else can't be stopped)
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.
Checking the flag for nil is kind of an ugly hack... How about this: change ReapResult
to take a boolean 'defaultToDelete' which if true, makes ReapResult do a standard delete on resources for which there is no reaper available. That way you don't have to pass in the command object, and you can do the check for an explicit --cascade in RunDelete
.
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.
Comment addressed, please re-check. --brendan |
reaper, err := f.Reaper(info.Mapping) | ||
if err != nil { | ||
// If the error is "not found" and the user didn't explicitly set "cascade" just delete. | ||
if kubectl.IsNoSuchReaperError(err) && cmd.Flags().Lookup("cascade") != nil && !cmd.Flags().Lookup("cascade").Changed { |
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.
Repeating since it may have been lost in outdated diff
Checking the flag for nil is kind of an ugly hack... How about this: change ReapResult to take a boolean defaultToDelete
instead of passing the Command object. If defaultToDelete
is true, do a standard delete on resources for which there is no reaper available. That way you can move the check for an explicit --cascade
into RunDelete, and we're not checking for nonexistent flags as a proxy for "which toplevel command is calling me".
rebased. |
There's an unresolved comment in the diff for pkg/kubectl/cmd/delete.go that seems to be getting attached to the outdated diff thread. Please take a look and let me know if you can't see it or object to suggested change. |
if r.Err() != nil { | ||
return r.Err() | ||
} | ||
return ReapResult(r, f, out, true) |
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.
Shouldn't this be false? By running stop
user is explicitly requesting reaper.
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.
lgtm aside from isDeleteDefault=false for RunStop. |
Refactor for shared code.
comment addressed, ptal. unit tests are manually determined to be clean. |
lgtm |
Make delete actually stop resources by default.
Refactor for shared code.
@bgrant0607 @ghodss @smarterclayton @eparis
This is a breaking change for
kubectl delete ...
behavior by default.