Bug 2038930 - oc set data --dry-run=server makes persistent changes to configmaps and secrets
Summary: oc set data --dry-run=server makes persistent changes to configmaps and secrets
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.9
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 4.9.z
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On: 2035393
Blocks: 2038931
TreeView+ depends on / blocked
 
Reported: 2022-01-10 15:09 UTC by Maciej Szulik
Modified: 2022-01-31 18:23 UTC (History)
4 users (show)

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.
Clone Of: 2035393
: 2038931 (view as bug list)
Environment:
Last Closed: 2022-01-31 18:23:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift oc pull 1016 0 None open Bug 2038930: properly handle --dry-run=server 2022-01-10 15:17:06 UTC
Red Hat Product Errata RHBA-2022:0279 0 None None None 2022-01-31 18:23:21 UTC

Comment 1 zhou ying 2022-01-20 15:00:57 UTC
Tested with build oc with fixed pr: 

[root@localhost oc]# oc create configmap my-config --from-literal=key1=abc
configmap/my-config created
[root@localhost oc]# oc get cm my-config -o yaml 
apiVersion: v1
data:
  key1: abc
kind: ConfigMap
metadata:
  creationTimestamp: "2022-01-20T14:57:15Z"
  name: my-config
  namespace: testoc
  resourceVersion: "381715"
  uid: 66835470-242c-4613-bf02-5db9791783e7
[root@localhost oc]# ./oc set data cm/myconfig --from-literal=name=def --dry-run=server
Error from server (NotFound): configmaps "myconfig" not found
[root@localhost oc]# ./oc set data cm/my-config --from-literal=name=def --dry-run=server
configmap/my-config data updated (server dry run)
[root@localhost oc]# oc get cm my-config -o yaml 
apiVersion: v1
data:
  key1: abc
kind: ConfigMap
metadata:
  creationTimestamp: "2022-01-20T14:57:15Z"
  name: my-config
  namespace: testoc
  resourceVersion: "381715"
  uid: 66835470-242c-4613-bf02-5db9791783e7

[root@localhost oc]# oc create secret generic my-secret --from-literal=key1=supersecret
secret/my-secret created
[root@localhost oc]# oc get secret my-secret -o yaml 
apiVersion: v1
data:
  key1: c3VwZXJzZWNyZXQ=
kind: Secret
metadata:
  creationTimestamp: "2022-01-20T14:59:30Z"
  name: my-secret
  namespace: testoc
  resourceVersion: "382698"
  uid: 9e5a8717-571b-49c4-8982-437c2119c016
type: Opaque
[root@localhost oc]# ./oc  set data secret/my-secret --from-literal=key1=testset  --dry-run='server' 
secret/my-secret data updated (server dry run)
[root@localhost oc]# oc get secret my-secret -o yaml 
apiVersion: v1
data:
  key1: c3VwZXJzZWNyZXQ=
kind: Secret
metadata:
  creationTimestamp: "2022-01-20T14:59:30Z"
  name: my-secret
  namespace: testoc
  resourceVersion: "382698"
  uid: 9e5a8717-571b-49c4-8982-437c2119c016
type: Opaque

Can't reproduce the issue now.

Comment 6 errata-xmlrpc 2022-01-31 18:23:01 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.9.18 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:0279


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