Bug 2038931

Summary: oc set data --dry-run=server makes persistent changes to configmaps and secrets
Product: OpenShift Container Platform Reporter: Maciej Szulik <maszulik>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: high Docs Contact:
Priority: high    
Version: 4.8CC: aos-bugs, mfojtik, mmarkand, yinzhou
Target Milestone: ---   
Target Release: 4.8.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: --dry-run flag wasn't properly used for several oc set sub commands. Consequence: --dry-run=server was performing updates to resources. Fix: Properly wire --dry-run flag such that commands send that information to the server. Result: oc set sub commands are working as expected.
Story Points: ---
Clone Of: 2038930 Environment:
Last Closed: 2022-02-16 06:51:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2038930    
Bug Blocks:    

Comment 4 zhou ying 2022-02-09 11:54:38 UTC
Checked with latest oc , the issue has fixed:

./oc version --client
Client Version: 4.8.0-0.nightly-2022-02-07-190543

./oc create secret generic my-secret --from-literal=key1=supersecret
secret/my-secret created
[root@localhost ~]# ./oc get secret my-secret -o yaml
apiVersion: v1
data:
  key1: c3VwZXJzZWNyZXQ=
kind: Secret
metadata:
  creationTimestamp: "2022-02-09T11:48:02Z"
  name: my-secret
  namespace: zhouyt
  resourceVersion: "545086"
  uid: ce737d11-542d-40d1-a4d6-3d6e2710a521
type: Opaque
[root@localhost ~]# ./oc set data secret/my-secret --from-literal=key1=testset  --dry-run='server'
secret/my-secret data updated (server dry run)
[root@localhost ~]# ./oc get secret my-secret -o yaml
apiVersion: v1
data:
  key1: c3VwZXJzZWNyZXQ=
kind: Secret
metadata:
  creationTimestamp: "2022-02-09T11:48:02Z"
  name: my-secret
  namespace: zhouyt
  resourceVersion: "545086"
  uid: ce737d11-542d-40d1-a4d6-3d6e2710a521
type: Opaque


[root@localhost ~]# ./oc create configmap my-config --from-literal=key1=abc
configmap/my-config created
[root@localhost ~]# ./oc get cm/my-config -o yaml 
apiVersion: v1
data:
  key1: abc
kind: ConfigMap
metadata:
  creationTimestamp: "2022-02-09T11:50:04Z"
  name: my-config
  namespace: zhouyt
  resourceVersion: "545778"
  uid: 09574cd9-8fb5-4b31-bb40-79d1d859a8aa

[root@localhost ~]# ./oc set data cm/my-config --from-literal=key1=def  --dry-run=server
configmap/my-config data updated (server dry run)
[root@localhost ~]# ./oc get cm/my-config -o yaml 
apiVersion: v1
data:
  key1: abc
kind: ConfigMap
metadata:
  creationTimestamp: "2022-02-09T11:50:04Z"
  name: my-config
  namespace: zhouyt
  resourceVersion: "545778"
  uid: 09574cd9-8fb5-4b31-bb40-79d1d859a8aa

Comment 6 errata-xmlrpc 2022-02-16 06:51:42 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.8.31 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-2022:0484