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
--force
only takes effect when --grace-period=0
#61378
Conversation
/assign @smarterclayton @janetkuo |
pkg/kubectl/cmd/delete.go
Outdated
@@ -218,6 +218,10 @@ func (o *DeleteOptions) Validate(cmd *cobra.Command) error { | |||
o.WaitForDeletion = true | |||
o.GracePeriod = 1 | |||
} | |||
} else { | |||
if o.ForceDeletion { | |||
return fmt.Errorf("--force should be specified with --grace-period=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.
I'd prefer to print warnings instead of errors.
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.
@dixudx Done.
pkg/kubectl/cmd/delete.go
Outdated
@@ -218,6 +218,10 @@ func (o *DeleteOptions) Validate(cmd *cobra.Command) error { | |||
o.WaitForDeletion = true | |||
o.GracePeriod = 1 | |||
} | |||
} else { | |||
if o.ForceDeletion { |
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: just use else if
/ok-to-test |
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'd prefer to update the command description, flag description and examples with information about the need for using both rather than throwing a warning at user.
@soltysh I will update the description part, but the warning seems necessary as well. |
ok |
Suggest changing flag description as follows:
cc @smarterclayton to review the flag description. I also agree that a warning is necessary, since |
pkg/kubectl/cmd/delete.go
Outdated
@@ -218,6 +218,8 @@ func (o *DeleteOptions) Validate(cmd *cobra.Command) error { | |||
o.WaitForDeletion = true | |||
o.GracePeriod = 1 | |||
} | |||
} else if o.ForceDeletion { | |||
fmt.Fprintf(o.ErrOut, "warning: --force should be specified with --grace-period=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.
warning: --force is ignored because --grace-period is not 0.\n
To make it clear that --force
doesn't do anything here and a normal delete operation is sent.
@@ -218,6 +218,8 @@ func (o *DeleteOptions) Validate(cmd *cobra.Command) error { | |||
o.WaitForDeletion = true | |||
o.GracePeriod = 1 | |||
} | |||
} else if o.ForceDeletion { |
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.
There's a function printDeletion
that prints "resource foo deleted" after deletion operation is sent successfully.
Would you change the operation string to "force deleted" when o.GracePeriod == 0
? So that kubectl delete pod foo --grace-period=0 --force
prints pod "foo" force 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.
9c237cf
to
4e6a430
Compare
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.
lgtm, I'll leave it for Janet or Clayton for final approval
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: charrywanganthony, janetkuo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Automatic merge from submit-queue (batch tested with PRs 61378, 60915, 61499, 61507, 61478). If you want to cherry-pick this change to another branch, please follow the instructions here. |
kubectl delete
should warn whenforce
is specified without--grace-period=0
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #61374
Release note: