Bug 1285702 - "--grace-period" option does not take effect for oc replace [NEEDINFO]
"--grace-period" option does not take effect for oc replace
Status: POST
Product: OpenShift Origin
Classification: Red Hat
Component: Pod (Show other bugs)
3.x
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Jan Chaloupka
Jianwei Hou
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-26 05:09 EST by Xingxing Xia
Modified: 2016-10-18 06:40 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
agoldste: needinfo? (ccoleman)


Attachments (Terms of Use)

  None (edit)
Description Xingxing Xia 2015-11-26 05:09:49 EST
Description of problem:
Seems "--grace-period" is ignored and does not take effect.

Version-Release number of selected component (if applicable):
openshift/oc v1.1-218-g42c0867
kubernetes v1.1.0-origin-1107-g4c8e6f4


How reproducible:
Always

Steps to Reproduce:
1. Create a pod
$ oc run mypod --image=yapei/hello-openshift  --generator=run-pod/v1
2. Prepare a pod .json file
$ oc export pod mypod -o json > mypod.json
3. oc replace with "--grace-period", set the time as 100 seconds
$ oc replace -f mypod.json --force --grace-period=100
pod "mypod" deleted
Error from server: pods "mypod" already exists

Actual results:
3. Error from server: pods "mypod" already exists

Expected results:
3. The "--grace-period" should take effect.


Additional info:
Although the output says 'pod "mypod" deleted', in fact, the pod "mypod" is being terminated. 
For more info, see "oc replace -h"
Comment 1 Andy Goldstein 2016-05-18 12:32:34 EDT
Is your expectation that 'oc replace' should wait for the deleted resource to actually be deleted (respecting grace period) before it should attempt to create the replacement resource?

Is this still happening in the latest version of Origin?
Comment 2 Xingxing Xia 2016-05-19 04:10:04 EDT
(In reply to Andy Goldstein from comment #1)
> Is your expectation that 'oc replace' should wait for the deleted resource
> to actually be deleted (respecting grace period) before it should attempt to
> create the replacement resource?
> 
> Is this still happening in the latest version of Origin?

Yes, that is my expectation.
This bug still reproduces when testing with:
$ openshift version
openshift v1.3.0-alpha.0-586-gcd9ea84
kubernetes v1.3.0-alpha.1-331-g0522e63
etcd 2.3.0
Comment 3 Andy Goldstein 2016-05-27 09:41:17 EDT
Clayton, any insight on the behavior here?
Comment 4 Jan Chaloupka 2016-06-27 08:53:58 EDT
# oc version
oc v1.3.0-alpha.2-260-g1b04cb2
kubernetes v1.3.0-alpha.3-599-g2746284

Still reproducible with. On debugging.
Comment 5 Jan Chaloupka 2016-06-27 09:55:42 EDT
Will have to dig more into the request builder. However,

1) the replace first deletes the pod
2) the replace does not wait for pod to be deleted (if the grace-period is set)
3) the replace wants to create a pod with the same name which is not possible is the name is still used

Still, what should be the default behaviour of the replace command? If you set the grace period to 5s, the replace command can wait for 5 second and then request for a pod to be created. However, if you choose the period 1h, the replace command will hang for an hour before it sends a request for a new pod.

I don't think the replace command was designed to work with grace period.

Any thoughts?
Comment 6 Jan Chaloupka 2016-06-27 10:15:16 EDT
IIRC, in the earlier times of k8s, the pod was deleted right away (just guessing). Anyway, the is not related to --grace-period at all. You will end up in the same situation just with ``oc replace -f mypod.json --force``.
Comment 7 Jan Chaloupka 2016-06-27 10:28:56 EDT
pod "mypod" deleted
Error from server: pods "mypod" already exists

occurs only when you use the --force option.
Comment 8 Jan Chaloupka 2016-06-27 10:35:40 EDT
Reproducible in the master HEAD of kubernetes as well.
Comment 9 Jan Chaloupka 2016-06-27 10:44:46 EDT
Upstream issue reported [1]. This bug consists of two parts:

1). make the --force option work again
2). make the --force option work with --grace-period

[1] https://github.com/kubernetes/kubernetes/issues/28115
Comment 10 Jan Chaloupka 2016-10-18 06:38:41 EDT
Fixed upstream.
Comment 11 Jan Chaloupka 2016-10-18 06:40:37 EDT
https://github.com/kubernetes/kubernetes/pull/31841

Note You need to log in before you can comment on or make changes to this bug.