Skip to content
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

kubectl --force deletion is breaking upgrade tests #37117

Closed
krousey opened this issue Nov 18, 2016 · 26 comments
Closed

kubectl --force deletion is breaking upgrade tests #37117

krousey opened this issue Nov 18, 2016 · 26 comments
Assignees
Labels
area/kubectl area/test priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-blocker
Milestone

Comments

@krousey
Copy link
Contributor

krousey commented Nov 18, 2016

In 1.5, kubectl now requires --force when --grace-period=0 for deletion. This is causing 1.3 e2e tests to fail when running with a 1.5 kubectl in the upgrade tests. This was added in #35484. See https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/logs/kubernetes-e2e-gke-container_vm-1.3-container_vm-1.5-upgrade-cluster/143?log

Expected error:
    <*errors.errorString | 0xc820019820>: {
        s: "Error running &{/workspace/kubernetes_skew/cluster/kubectl.sh [/workspace/kubernetes_skew/cluster/kubectl.sh --server=https://199.223.235.243 --kubeconfig=/workspace/.kube/config delete --grace-period=0 -f - --namespace=e2e-tests-kubectl-up6nc] []  0xc8207b9b60  error: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. You must pass --force to delete with grace period 0.\n [] <nil> 0xc8206fe440 exit status 1 <nil> true [0xc820ea4718 0xc820ea4740 0xc820ea4750] [0xc820ea4718 0xc820ea4740 0xc820ea4750] [0xc820ea4720 0xc820ea4738 0xc820ea4748] [0xa97840 0xa979a0 0xa979a0] 0xc82027b800}:\nCommand stdout:\n\nstderr:\nerror: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. You must pass --force to delete with grace period 0.\n\nerror:\nexit status 1\n",
    }
    Error running &{/workspace/kubernetes_skew/cluster/kubectl.sh [/workspace/kubernetes_skew/cluster/kubectl.sh --server=https://199.223.235.243 --kubeconfig=/workspace/.kube/config delete --grace-period=0 -f - --namespace=e2e-tests-kubectl-up6nc] []  0xc8207b9b60  error: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. You must pass --force to delete with grace period 0.
     [] <nil> 0xc8206fe440 exit status 1 <nil> true [0xc820ea4718 0xc820ea4740 0xc820ea4750] [0xc820ea4718 0xc820ea4740 0xc820ea4750] [0xc820ea4720 0xc820ea4738 0xc820ea4748] [0xa97840 0xa979a0 0xa979a0] 0xc82027b800}:
    Command stdout:
    
    stderr:
    error: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. You must pass --force to delete with grace period 0.
    
    error:
    exit status 1
    
not to have occurred
@krousey krousey added area/test area/kubectl priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Nov 18, 2016
@krousey krousey added this to the v1.5 milestone Nov 18, 2016
@krousey
Copy link
Contributor Author

krousey commented Nov 18, 2016

cc @saad-ali

@saad-ali
Copy link
Member

The new kubectl behavior introduced in PR #35484 is causing automated upgrade tests to fail.

@krousey
Copy link
Contributor Author

krousey commented Nov 18, 2016

@foxish I wish it was as easy as just back-porting the addition of --force to the 1.4 and 1.3 e2e tests, but as far as I can tell, the 1.3 kubectl delete didn't have a --force option, so that would just break all the normal 1.3 e2es.

@bgrant0607
Copy link
Member

@krousey Why are we running 1.3 upgrade tests on 1.5? kubectl officially only supports 1 minor release of version skew.

@krousey
Copy link
Contributor Author

krousey commented Nov 18, 2016

@bgrant0607 My understanding from the test description

Deploys a cluster at v{version-old} at {image-old}, upgrades the master to v{version-new} at {image-new}, and runs the v{version-old} tests.

Is that this is 1.3 e2e tests shelling out to a 1.5 kubectl communicating with a 1.5 master. There shouldn't be a version skew between kubectl and master.

@smarterclayton
Copy link
Contributor

So the new behavior was intentional because the old behavior can result in data loss in stateful sets (or data loss in any component like a DB running on Kube). The problem with continuing to allow the behavior of existing scripts is because they are doing something very dangerous, and that's not ok.

@smarterclayton
Copy link
Contributor

The alternatives discussed are:

  1. No change - let hard coded scripts with grace-period 0 continue to lead to split brain and data loss on the cluster
  2. Have --grace-period=0 actually set grace period 1, which would break any script that assumes that they can call delete and the resource is immediately gone (so also breaking, but more subtly).

Grace-period=0 is not something people should be doing. If we recognize they should not be doing it, breaking scripts deliberately to force this behavior is appropriate.

@smarterclayton
Copy link
Contributor

1.3 kubectl with 1.5 server would continue to behave without change.

@krousey
Copy link
Contributor Author

krousey commented Nov 18, 2016

@smarterclayton I'm fine with this breaking change if it's preventing bad behavior. This broke a script (in the form of 1.3 e2e tests). This somehow needs to be fixed so that it can work with a 1.3, 1.4, and 1.5 kubectl.

@smarterclayton
Copy link
Contributor

One option is grep "--force" on the help text as an if block (I think we did that somewhere else).

I really believe that we have to consciously break this one scripting experience because it has such dramatic impact on clusters.

@smarterclayton
Copy link
Contributor

if kubectl delete -h | grep -q force; then
  kubectl delete --force ...
else
  kubectl delete ...
fi
``

is one option

@pwittrock
Copy link
Member

The release notes typically have a "Known behavior changes" section where we can add this.

@smarterclayton
Copy link
Contributor

The release note from the mentioned PR definitely addresses the change - agree it would be in the behavior change section.

@krousey
Copy link
Contributor Author

krousey commented Nov 18, 2016

@smarterclayton or @foxish could one of you take the time to implement a fix for the e2es?

@smarterclayton
Copy link
Contributor

I will. Want Brian's agreement or disagreement on the statement that data
integrity overrides back compat.

On Nov 18, 2016, at 6:36 PM, krousey notifications@github.com wrote:

@smarterclayton https://github.com/smarterclayton or @foxish
https://github.com/foxish could one of you take the time to implement a
fix for the e2es?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#37117 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pwGEaj1knLAhqreAn0fNUNaQ5UI7ks5q_jZ9gaJpZM4K22Za
.

@foxish
Copy link
Contributor

foxish commented Nov 18, 2016

ping @bgrant0607

@bgrant0607
Copy link
Member

@smarterclayton The proposal was #34160?

A better solution would be to only enforce this requirement upon pods that really need this behavior, so that existing acceptable uses wouldn't break.

Somewhat related: #10179.

I don't really like the proposed alternatives, but it's too late to implement a proper solution in the API.

Assuming that we have no choice but to go forward with --force, in addition to an action-required release note, please also ensure user docs are updated, and also relevant stackoverflow posts, such as:

http://stackoverflow.com/questions/35453792/pods-stuck-at-terminated-status

@saad-ali
Copy link
Member

saad-ali commented Nov 19, 2016

1.5 known issues are being tracked here: #37134

Assuming this behavior is kept for 1.5 it should be added there.

@smarterclayton
Copy link
Contributor

smarterclayton commented Nov 19, 2016

I don't think we should leave it up to the user to opt out of split brain
and data loss.

Another alternative is to make --grace-period=0 send grace period 1 but
wait until the pod is deleted to continue. If you think forcing users to
understand that grace-period=0 is dangerous is too far (even given safety
first), that would potentially reduce the impact.

@smarterclayton
Copy link
Contributor

Proposal was #34160 but discussion in #29033 covers the guarantees for users.

@bgrant0607
Copy link
Member

@smarterclayton I like your latest suggestion: "Another alternative is to make --grace-period=0 send grace period 1 but wait until the pod is deleted to continue."

@smarterclayton
Copy link
Contributor

I'll look at what that takes. We could wait forever, which is surprising
(and still a behavior change), so it's not a perfect fix.

On Nov 19, 2016, at 1:19 AM, Brian Grant notifications@github.com wrote:

@smarterclayton https://github.com/smarterclayton I like your latest
suggestion: "Another alternative is to make --grace-period=0 send grace
period 1 but wait until the pod is deleted to continue."


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#37117 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p2_-k8Tq3jiw2YD_H-SKupbVJOr9ks5q_pTvgaJpZM4K22Za
.

@bgrant0607
Copy link
Member

@smarterclayton If the command timed out and failed in the "forever" case, it would be less surprising to the user when they tried to create another resource with the same name and failed.

@smarterclayton
Copy link
Contributor

#37263 contains the second proposal. I didn't realize what bad shape delete was in (we don't respect grace-period when cascade is false), so the low risk fix doesn't cover all the possible scenarios. Also, we don't have access to the existing object so we can't do UID checks (which means we may end up waiting forever if someone recreates the same resource).

@smarterclayton
Copy link
Contributor

Folks with an opinion, please review the attached PR.

@dims
Copy link
Member

dims commented Nov 23, 2016

Thanks for the update @smarterclayton !

k8s-github-robot pushed a commit that referenced this issue Nov 30, 2016
Automatic merge from submit-queue

When --grace-period=0 is provided, wait for deletion

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.

```release-note
When deleting an object with `--grace-period=0`, the client will begin a graceful deletion and wait until the resource is fully deleted.  To force deletion, use the `--force` flag.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl area/test priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-blocker
Projects
None yet
Development

No branches or pull requests

7 participants