Description of problem: oc patch always return "x patched" even if it doesn't change anything. Version-Release number of selected component (if applicable): oc v3.5.5.26 kubernetes v1.5.2+43a9be4 features: Basic-Auth GSSAPI Kerberos SPNEGO Server https://emingueztst.eastus2.cloudapp.azure.com:8443 openshift v3.5.5.26 kubernetes v1.5.2+43a9be4 How reproducible: Create new project, new app, try to patch it and it always return 0 and "patched" It happens too when trying to patch anything wrong. Steps to Reproduce: 1. oc new-project test 2. oc new-app kubernetes/guestbook 3. oc get dc guestbook -o json | jq '.spec.template.metadata.annotations' { "openshift.io/generated-by": "OpenShiftNewApp" } 4. oc patch dc guestbook -p '{"spec":{"template":{"metadata":{"annotations":{"mylabel":"myvalue"}}}}}' "guestbook" patched 5. oc get dc guestbook -o json | jq '.spec.template.metadata.annotations' { "mylabel": "myvalue", "openshift.io/generated-by": "OpenShiftNewApp" } 6. oc patch dc guestbook -p '{"spec":{"template":{"metadata":{"annotations":{"mylabel":"myvalue"}}}}}' "guestbook" patched 7. echo $? 0 8. oc get dc guestbook -o json | jq '.spec.template.metadata.annotations' { "mylabel": "myvalue", "openshift.io/generated-by": "OpenShiftNewApp" } Something wrong: $ oc get dc guestbook -o json | jq '.spec.template.spec.containers[].imagePullPolicy' "Always" $ oc get dc guestbook -o yaml | grep -i always imagePullPolicy: Always restartPolicy: Always Now, try to patch in some other level (it should be containers[].template...) $ oc patch dc guestbook -p '{"spec":{"template":{"spec":{"imagePullPolicy":"Always"}}}}' "guestbook" patched $ echo $? 0 $ oc get dc guestbook -o yaml | grep -i always imagePullPolicy: Always restartPolicy: Always Actual results: It always returns 0 and patched Expected results: If the patch is not applied, it should return an error code and some message about why it wasn't been able to patch it Additional info:
1. Please check if patched field's name/level is correct. See https://bugzilla.redhat.com/show_bug.cgi?id=1409225#c3 2. > $ oc patch dc guestbook -p '{"spec":{"template":{"spec":{"imagePullPolicy":"Always"}}}}' > "guestbook" patched If user knows about how to use the merge key (said below), seems user will not be confused about this :) For "containers" field which is array, should use "a merge key" in oc patch. See `kubectl patch -h` which explains more detailed help info (e.g. about usage of merge key) than `oc patch -h`. (The oc help info issue is tracked in bug 1352453)
(In reply to Xingxing Xia from comment #1) > 1. Please check if patched field's name/level is correct. > See https://bugzilla.redhat.com/show_bug.cgi?id=1409225#c3 > > 2. > > $ oc patch dc guestbook -p '{"spec":{"template":{"spec":{"imagePullPolicy":"Always"}}}}' > > "guestbook" patched > If user knows about how to use the merge key (said below), seems user will > not be confused about this :) > For "containers" field which is array, should use "a merge key" in oc patch. > See `kubectl patch -h` which explains more detailed help info (e.g. about > usage of merge key) than `oc patch -h`. (The oc help info issue is tracked > in bug 1352453) This was intentional. The problem is not the missing containers[] or whatever, the thing is if I create a non valid patch (as the one I've provided), it should say "patch not valid" or something similar, so, this works: $ oc patch dc guestbook -p '{"icantypewhatever":"yes"}' But it shouldn't.
*** Bug 1466664 has been marked as a duplicate of this bug. ***
Fixed in 3.6.
Thank you Checked in v3.6.133, now it shows: $ oc patch dc database -p '{"spec":{"template":{"spec":{"imagePullPolicy":"Always"}}}}' deploymentconfig "database" not patched $ oc patch dc database -p '{"icantypewhatever":"yes"}' deploymentconfig "database" not patched This fixes original issue reported, so moving to VERIFIED (QE is checking many Modified bugs that if they're verifiable. Because fixed, moving to Verified. If have extra concern, pls correct me, thx) But it is better to have additional prompt such as "please check if the patch field's name/level is correct", this may help user self troubleshoot question such as: once ever a non-UI QE patches with singular "container" and wondered why not taking effect: '{"spec":{"template":{"spec":"container":... Then the guy asked me and I told should use plural "containers" WDYT?
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2017:3188