-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
When --grace-period=0 is provided, wait for deletion #37263
When --grace-period=0 is provided, wait for deletion #37263
Conversation
32a7c41
to
28a4d56
Compare
Proposed for 1.5 to avoid backwards compatibility. |
Jenkins Bazel Build failed for commit 28a4d56. Full PR test history. The magic incantation to run this job again is |
Jenkins GCI GKE smoke e2e failed for commit 32a7c417a81661f05a056334d0305e145d278375. Full PR test history. The magic incantation to run this job again is |
@k8s-bot bazel test this |
@smarterclayton so both |
// into --grace-period=1 and wait until the object is successfully deleted. Users may provide --force | ||
// to bypass this wait. | ||
wait = true | ||
gracePeriod = 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.
--grace-period=0
may now be mutually exclusive with --timeout
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's not, timeout is still respected.
To avoid breaking old scripts, --grace-period=0 continues to not return (waits) until the object is gone. --now continues to behave as it did before. |
LGTM |
@@ -818,10 +818,12 @@ func (r *Request) request(fn func(*http.Request, *http.Response)) error { | |||
// connection. | |||
defer func() { | |||
const maxBodySlurpSize = 2 << 10 | |||
if resp.ContentLength <= maxBodySlurpSize { | |||
io.Copy(ioutil.Discard, &io.LimitedReader{R: resp.Body, N: maxBodySlurpSize}) | |||
if resp.Body != nil { |
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 check should not be required.
// The http Client and Transport guarantee that Body is always
// non-nil, even on responses without a body or responses with
// a zero-length body.
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.
Test cases were passing nil in, and we guard against it in other places. I'll remove both guards and hunt down the bug.
case 1, 2, 3: | ||
return &http.Response{StatusCode: 200, Header: defaultHeader(), Body: objBody(codec, &pods.Items[0])}, nil | ||
default: | ||
return &http.Response{StatusCode: 404, Header: defaultHeader(), Body: nil}, nil |
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 should provide a non-nil body, even if it is empty.
"k8s.io/kubernetes/pkg/kubectl/resource" | ||
"time" |
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: import ordering.
The grace-period is automatically set to 1 unless --force is provided, and the client waits until the object is deleted. This preserves backwards compatibility with 1.4 and earlier. It does not handle scenarios where the object is deleted and a new object is created with the same name.
28a4d56
to
7cdb6b1
Compare
Updated with all comments. |
@k8s-bot test this |
Yes, that's fine with me. |
@k8s-bot gce node e2e test this |
@k8s-bot node e2e test this |
@foxish can you review. Let's get this merged ASAP, so we can unblock upgrade testing |
LGTM except for the couple of comments. |
// By default use a reaper to delete all related resources. | ||
if cmdutil.GetFlagBool(cmd, "cascade") { | ||
glog.Warningf("\"cascade\" is set, kubectl will delete and re-create all resources managed by this resource (e.g. Pods created by a ReplicationController). Consider using \"kubectl rolling-update\" if you want to update a ReplicationController together with its Pods.") | ||
err = ReapResult(r, f, out, cmdutil.GetFlagBool(cmd, "cascade"), ignoreNotFound, timeout, cmdutil.GetFlagInt(cmd, "grace-period"), shortOutput, mapper, false) | ||
err = ReapResult(r, f, out, cmdutil.GetFlagBool(cmd, "cascade"), ignoreNotFound, timeout, gracePeriod, waitForDeletion, shortOutput, mapper, false) | ||
} else { | ||
err = DeleteResult(r, out, ignoreNotFound, shortOutput, mapper) |
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 seems like this should go through ReapResult as well? Currently, we would print out "pod is deleted" prior to its actual deletion, and then eventually hit the timeout condition a few lines below. This is in the case where --cascade=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.
We don't actually even do graceful deletion in this code path (we use the server default) so it's not backwards incompatible. Definitely something we need to fix in the future, but not for 1.5
copied := *info | ||
info = &copied | ||
// TODO: refactor Reaper so that we can pass the "wait" option into it, and then check for UID change. | ||
return wait.PollImmediate(objectDeletionWaitInterval, timeout, func() (bool, 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.
I think in the timeout case, we should return a better error than "timed out waiting for the condition" because we surface
that error to the user.
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.
the error is going to be "error when stopping pod/foo: timed out waiting for the condition" which is pretty close. I think that's something we could improve in a follow up (there's basically a follow up here which is delete needs a better cleanup)
/lgtm |
Follow up issue opened as
#37637
…On Tue, Nov 29, 2016 at 11:59 AM, Kubernetes Submit Queue < ***@***.***> wrote:
@k8s-bot <https://github.com/k8s-bot> test this
Tests are more than 96 hours old. Re-running tests.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#37263 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p1MjqpuojUbmyGcoHXo4GfP_ZN4pks5rDFn9gaJpZM4K494f>
.
|
Jenkins GCE Node e2e failed for commit 7cdb6b1. Full PR test history. The magic incantation to run this job again is |
@k8s-bot node e2e test this |
@k8s-bot kops aws e2e test this |
@k8s-bot node e2e test this |
Automatic merge from submit-queue |
…63-upstream-release-1.5 Automated cherry pick of #37263 upstream release 1.5
The grace-period is automatically set to 1 unless --force is provided, and the client waits until the object is deleted.
This preserves backwards compatibility with 1.4 and earlier. It does not handle scenarios where the object is deleted and a new object is created with the same name because we don't have the initial object loaded (and that's a larger change for 1.5).
Fixes #37117 by relaxing the guarantees provided.
This change is