Bug 1294063 - Can't use --force when replace resource
Summary: Can't use --force when replace resource
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Node
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: ---
: ---
Assignee: Derek Carr
QA Contact: Jianwei Hou
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-24 11:05 UTC by XiuJuan Wang
Modified: 2019-07-03 15:08 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-03 15:08:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1285702 0 medium CLOSED "--grace-period" option does not take effect for oc replace 2023-09-14 03:13:51 UTC

Internal Links: 1285702

Description XiuJuan Wang 2015-12-24 11:05:58 UTC
Description of problem:
When replace resource with --force option,will delete resource, but not re-create with error 'the resource exists'.

$oc replace -h

   --force=false: Delete and re-create the specified resource

Version-Release number of selected component (if applicable):
devenv-fedora_2940
oc v1.1-428-ged29520
kubernetes v1.1.0-origin-1107-g4c8e6f4

How reproducible:
always

Steps to Reproduce:
1.Create a hello-openshift  pod
2.Output pod to a json file
$oc get pod hello-openshift -o json > pod.json
3.Replace resource with --force after modify label info in pod.json 
$oc replace -f pod.json --force
$oc get pod

Actual results:
$oc  replace -f pod.json  --force
pod "hello-openshift" deleted
Error from server: pods "hello-openshift" already exists
$ oc get pods
$

Expected results:
Should delete and re-create resource

Additional info:

Comment 1 Fabiano Franz 2016-01-04 20:04:39 UTC
Reassigning, the 'replace' cmd comes from upstream.

Comment 2 Andy Goldstein 2016-01-05 14:02:25 UTC
Not a 3.1.1 blocker. There is a workaround: 'oc delete' your resource, use 'oc get' to confirm it's deleted, then 'oc create' it. Alternatively, you can try specifying both --cascade=true and --grace-period=0 (cascade should not be required, but there is a bug in the replace code that makes it required right now).

The appropriate fix is to modify the replace code to:

- set the grace period to 0 by default when force=true
- not require cascade=true when using grace period w/pods
- pass grace period to the delete request when cascade=false

Comment 3 Derek Carr 2016-02-03 14:45:41 UTC
I will look to put together an upstream PR.

Comment 4 Derek Carr 2016-02-03 20:28:00 UTC
Modifying severity to low as its not a blocker for the release.

Comment 5 Xingxing Xia 2016-04-01 02:57:04 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=1285702 relevant

Comment 6 Greg Blomquist 2019-07-03 15:08:30 UTC
Old bug with a workaround discussed in comment #2.  If there are any related issues in 4.x, please open a new bug.


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