Bug 1845798 - 'oc diff' Applies Changes to the Cluster
Summary: 'oc diff' Applies Changes to the Cluster
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.z
Assignee: Maciej Szulik
QA Contact: RamaKasturi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-10 05:34 UTC by Michael Washer
Modified: 2023-10-06 20:32 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-09-14 14:54:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Log of OC Diff with OC Version 4.5.0 and Cluster Version 4.5.0 (4.27 KB, text/plain)
2020-06-11 03:45 UTC, Michael Washer
no flags Details
Log of OC Diff with OC Version 4.3.3 and Cluster Version 4.5.0 (1.94 KB, text/plain)
2020-06-11 03:46 UTC, Michael Washer
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:3618 0 None None None 2020-09-14 14:55:00 UTC

Description Michael Washer 2020-06-10 05:34:11 UTC
Description of problem:
Running "oc diff" on a non-existent project results in the project being created within the cluster.

Version-Release number of selected component (if applicable):
4.3.21

How reproducible:
Every time following the steps below

Steps to Reproduce:
1. Show that the project is not present in the cluster
	`$ oc get project test-project`
2. Perform ‘oc diff’ on project
```
$ cat <<EOF | oc diff -f -
apiVersion: project.openshift.io/v1
kind: Project
metadata:
  name: test-project
EOF
```
3. Show that the project is not present in the cluster
	`$ oc get project test-project`

Actual results:
Project is present in the cluster

Expected results:
Project is not present in the cluster

Additional info:
Issue is present in all versions listed below:
Server Version: 4.2.18
Server Version: 4.3.21
Server Version: 4.4.3

Comment 2 Stefan Schimanski 2020-06-10 06:57:28 UTC
Looks like this is an oc bug, i.e. client side in 1.18, i.e. 4.5.

Please confirm that you tried with the 4.5 oc, but different servers.

Comment 3 Stefan Schimanski 2020-06-10 07:29:06 UTC
With latest oc on master I cannot reproduce this:

openshift/oc ❯ cat <<EOF | oc diff -f -                                                                                                                                                                                                
apiVersion: project.openshift.io/v1
kind: Project
metadata:
  name: test-project
EOF
diff -u -N /var/folders/gg/zn9yfdld21j7xg5jnj5zz5d80000gn/T/LIVE-494696447/project.openshift.io.v1.Project..test-project /var/folders/gg/zn9yfdld21j7xg5jnj5zz5d80000gn/T/MERGED-192390482/project.openshift.io.v1.Project..test-project
--- /var/folders/gg/zn9yfdld21j7xg5jnj5zz5d80000gn/T/LIVE-494696447/project.openshift.io.v1.Project..test-project	2020-06-10 09:28:17.521242573 +0200
+++ /var/folders/gg/zn9yfdld21j7xg5jnj5zz5d80000gn/T/MERGED-192390482/project.openshift.io.v1.Project..test-project	2020-06-10 09:28:17.701790378 +0200
@@ -0,0 +1,30 @@
+apiVersion: project.openshift.io/v1
+kind: Project
+metadata:
+  annotations:
+    openshift.io/display-name: ""
+  creationTimestamp: "2020-06-10T07:28:17Z"
+  managedFields:
+  - apiVersion: v1
+    fieldsType: FieldsV1
+    fieldsV1:
+      f:metadata:
+        f:annotations:
+          .: {}
+          f:openshift.io/display-name: {}
+      f:spec:
+        f:finalizers: {}
+      f:status:
+        f:phase: {}
+    manager: openshift-apiserver
+    operation: Update
+    time: "2020-06-10T07:28:17Z"
+  name: test-project
+  selfLink: /apis/project.openshift.io/v1/projects/test-project
+  uid: 03e4e852-94df-453f-b33e-27f47cd24f2a
+spec:
+  finalizers:
+  - openshift.io/origin
+  - kubernetes
+status:
+  phase: Active
openshift/oc ❯ oc get projects test-project                                                                                                                                                                                           
Error from server (NotFound): namespaces "test-project" not found

Comment 4 Michael Washer 2020-06-11 02:20:08 UTC
Can confirm that the issue is still present in the OCP 4.5 OC client rc.
Trying with current 4.5 rc from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.5.0-rc.1/openshift-client-mac.tar.gz

""""
openshift-client-mac|⇒ ls
README.md kubectl   oc
openshift-client-mac|⇒ ./oc version
Client Version: 4.5.0-rc.1
Server Version: 4.2.18
Kubernetes Version: v1.14.6+f0fa3b6
openshift-client-mac|⇒ ./oc get project test-project9 -oyaml
Error from server (NotFound): namespaces "test-project9" not found
openshift-client-mac|⇒ cat <<EOF | ./oc diff -f -           
apiVersion: project.openshift.io/v1
kind: Project
metadata:
  name: test-project9
EOF
diff -u -N /var/folders/6w/f77mmf5145v9dtqgk8b7h2t00000gp/T/LIVE-551168287/project.openshift.io.v1.Project..test-project9 /var/folders/6w/f77mmf5145v9dtqgk8b7h2t00000gp/T/MERGED-536160754/project.openshift.io.v1.Project..test-project9
--- /var/folders/6w/f77mmf5145v9dtqgk8b7h2t00000gp/T/LIVE-551168287/project.openshift.io.v1.Project..test-project9      2020-06-11 14:17:21.612770012 +1200
+++ /var/folders/6w/f77mmf5145v9dtqgk8b7h2t00000gp/T/MERGED-536160754/project.openshift.io.v1.Project..test-project9    2020-06-11 14:17:21.826835988 +1200
@@ -0,0 +1,16 @@
+apiVersion: project.openshift.io/v1
+kind: Project
+metadata:
+  annotations:
+    openshift.io/display-name: ""
+  creationTimestamp: "2020-06-11T02:17:21Z"
+  name: test-project9
+  resourceVersion: "437449"
+  selfLink: /apis/project.openshift.io/v1/projects/test-project9
+  uid: aea5ec14-ab89-11ea-b8de-42010a000003
+spec:
+  finalizers:
+  - openshift.io/origin
+  - kubernetes
+status:
+  phase: Active
openshift-client-mac|⇒ ./oc get project test-project9 -oyaml                                                                                                                                                                               <<<
apiVersion: project.openshift.io/v1
kind: Project
metadata:
  annotations:
    openshift.io/display-name: ""
    openshift.io/sa.scc.mcs: s0:c24,c9
    openshift.io/sa.scc.supplemental-groups: 1000570000/10000
    openshift.io/sa.scc.uid-range: 1000570000/10000
  creationTimestamp: "2020-06-11T02:17:21Z"
  name: test-project9
  resourceVersion: "437469"
  selfLink: /apis/project.openshift.io/v1/projects/test-project9
  uid: aea5ec14-ab89-11ea-b8de-42010a000003
spec:
  finalizers:
  - kubernetes
status:
  phase: Active
openshift-client-mac|⇒ 
""""

Comment 5 Michael Washer 2020-06-11 03:44:14 UTC
Hi Team, 

I can confirm that the issues are resolved with the OCP 4.5, but appears to be on the server side not OC. (see attachments)

Will this be back-ported to the older versions of OCP?

Comment 6 Michael Washer 2020-06-11 03:45:35 UTC
Created attachment 1696651 [details]
Log of OC Diff with OC Version 4.5.0 and Cluster Version 4.5.0

Comment 7 Michael Washer 2020-06-11 03:46:15 UTC
Created attachment 1696652 [details]
Log of OC Diff with OC Version 4.3.3 and Cluster Version 4.5.0

Comment 8 Maciej Szulik 2020-06-15 14:16:34 UTC
Based on both the logs you've attached oc 4.3 and 4.5 are working as expected, iow. they DO NOT modify data on the server. 
I just also tried 4.3 client and it's working as expected. Can we then close this bug?

Comment 12 Maciej Szulik 2020-06-18 09:32:41 UTC
I need to check this locally where exactly the problem was, the server should not be affected by this since that was only client-side change.

Comment 14 Maciej Szulik 2020-07-09 11:07:51 UTC
I’m adding UpcomingSprint, because I was occupied by fixing bugs with higher priority/severity, developing new features with higher priority, or developing new features to improve stability at a macro level. I will revisit this bug next sprint.

Comment 16 Michael Washer 2020-08-06 04:29:59 UTC
Any new updates on this ?

Comment 17 Maciej Szulik 2020-08-21 13:51:36 UTC
Michael, sorry, I was out at the break of July/August. I'm hoping to return to this one soon. 

I’m adding UpcomingSprint, because I was occupied by fixing bugs with higher priority/severity, developing new features with higher priority, or developing new features to improve stability at a macro level. I will revisit this bug next sprint.

Comment 18 RamaKasturi 2020-09-07 13:20:59 UTC
Tried with latest payload of 4.6 and see that it works fine. Below are the steps which i have used to perform this.

[ramakasturinarra@dhcp35-60 openshift-client-linux-4.6.0-0.nightly-2020-09-05-015624]$ ./oc version
Client Version: 4.6.0-0.nightly-2020-09-05-015624
Server Version: 4.6.0-0.nightly-2020-09-05-015624
Kubernetes Version: v1.19.0-rc.2+068702d


[ramakasturinarra@dhcp35-60 openshift-client-linux-4.6.0-0.nightly-2020-09-05-015624]$ ./oc get project test-project
Error from server (NotFound): namespaces "test-project" not found
[ramakasturinarra@dhcp35-60 openshift-client-linux-4.6.0-0.nightly-2020-09-05-015624]$ cat <<EOF | ./oc diff -f -
> apiVersion: project.openshift.io/v1
> kind: Project
> metadata:
>   name: test-project
> EOF
diff -u -N /tmp/LIVE-245355092/project.openshift.io.v1.Project..test-project /tmp/MERGED-848173475/project.openshift.io.v1.Project..test-project
--- /tmp/LIVE-245355092/project.openshift.io.v1.Project..test-project	2020-09-07 18:49:30.058764744 +0530
+++ /tmp/MERGED-848173475/project.openshift.io.v1.Project..test-project	2020-09-07 18:49:30.478759959 +0530
@@ -0,0 +1,30 @@
+apiVersion: project.openshift.io/v1
+kind: Project
+metadata:
+  annotations:
+    openshift.io/display-name: ""
+  creationTimestamp: "2020-09-07T13:19:30Z"
+  managedFields:
+  - apiVersion: v1
+    fieldsType: FieldsV1
+    fieldsV1:
+      f:metadata:
+        f:annotations:
+          .: {}
+          f:openshift.io/display-name: {}
+      f:spec:
+        f:finalizers: {}
+      f:status:
+        f:phase: {}
+    manager: kubectl-client-side-apply
+    operation: Update
+    time: "2020-09-07T13:19:30Z"
+  name: test-project
+  selfLink: /apis/project.openshift.io/v1/projects/test-project
+  uid: 30ffa5db-02e8-4a64-9cfa-9aa5a4661d3e
+spec:
+  finalizers:
+  - openshift.io/origin
+  - kubernetes
+status:
+  phase: Active
[ramakasturinarra@dhcp35-60 openshift-client-linux-4.6.0-0.nightly-2020-09-05-015624]$ ./oc get project test-project
Error from server (NotFound): namespaces "test-project" not found

Comment 19 Maciej Szulik 2020-09-08 11:17:52 UTC
I've verified this on a 4.5.7 cluster and it works as expected, moving to qa to confirm.

Comment 20 Michael Washer 2020-09-09 01:13:50 UTC
Works fine for me in 4.5.7. Appears to be resolved

Comment 23 RamaKasturi 2020-09-09 09:46:00 UTC
Verified the bug in the payload below and i see that it works fine.

[ramakasturinarra@dhcp35-60 openshift-client-linux-4.5.8]$ ./oc version
Client Version: 4.5.8
Server Version: 4.5.8
Kubernetes Version: v1.18.3+6c42de8

[ramakasturinarra@dhcp35-60 openshift-client-linux-4.5.8]$ ./oc get project test-project
Error from server (NotFound): namespaces "test-project" not found
[ramakasturinarra@dhcp35-60 openshift-client-linux-4.5.8]$ cat <<EOF | ./oc diff -f -
> apiVersion: project.openshift.io/v1
> kind: Project
> metadata:
>   name: test-project
> EOF
diff -u -N /tmp/LIVE-337203150/project.openshift.io.v1.Project..test-project /tmp/MERGED-789582037/project.openshift.io.v1.Project..test-project
--- /tmp/LIVE-337203150/project.openshift.io.v1.Project..test-project	2020-09-09 15:14:29.645951934 +0530
+++ /tmp/MERGED-789582037/project.openshift.io.v1.Project..test-project	2020-09-09 15:14:30.064947384 +0530
@@ -0,0 +1,30 @@
+apiVersion: project.openshift.io/v1
+kind: Project
+metadata:
+  annotations:
+    openshift.io/display-name: ""
+  creationTimestamp: "2020-09-09T09:44:29Z"
+  managedFields:
+  - apiVersion: v1
+    fieldsType: FieldsV1
+    fieldsV1:
+      f:metadata:
+        f:annotations:
+          .: {}
+          f:openshift.io/display-name: {}
+      f:spec:
+        f:finalizers: {}
+      f:status:
+        f:phase: {}
+    manager: openshift-apiserver
+    operation: Update
+    time: "2020-09-09T09:44:29Z"
+  name: test-project
+  selfLink: /apis/project.openshift.io/v1/projects/test-project
+  uid: a9486fa5-ab49-41ab-a719-baf2c935f188
+spec:
+  finalizers:
+  - openshift.io/origin
+  - kubernetes
+status:
+  phase: Active
[ramakasturinarra@dhcp35-60 openshift-client-linux-4.5.8]$ ./oc get project test-project
Error from server (NotFound): namespaces "test-project" not found

Based on the above moving the bug to verified state.

Comment 25 errata-xmlrpc 2020-09-14 14:54:26 UTC
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 (OpenShift Container Platform 4.5.9 bug fix update), 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/RHBA-2020:3618


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