Bug 1294063

Summary: Can't use --force when replace resource
Product: OpenShift Container Platform Reporter: XiuJuan Wang <xiuwang>
Component: NodeAssignee: Derek Carr <decarr>
Status: CLOSED NOTABUG QA Contact: Jianwei Hou <jhou>
Severity: low Docs Contact:
Priority: medium    
Version: unspecifiedCC: aos-bugs, decarr, gblomqui, haowang, jokerman, mmccomas, xxia
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-07-03 15:08:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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.