origin: oc apply does not work on objects created with a resourceVersion field

Related comment: https://github.com/openshift/release/pull/901#issuecomment-393963467

When creating an object via oc apply -f resource.yaml, subsequent patches to that object fail if the initial object in resource.yaml contained a metadata.resourceVersion field.

Example:

# given the following dc with a metadata.resourceVersion field, I will create it via oc apply
$ cat simpledc.yaml
---
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: simple-dc
  creationTimestamp: null
  resourceVersion: "111"
  labels:
    name: test-deployment
spec:
  replicas: 1
  selector:
    name: test-deployment
  template:
    metadata:
      labels:
        name: test-deployment
    spec:
      containers:
      - image: openshift/origin-ruby-sample
        name: helloworld

$ oc apply -f simpledc.yaml
deploymentconfig.apps.openshift.io "simple-dc" created

# modify the original dc, removing the resourceVersion field
$ cat simpledc_modified.yaml
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: simple-dc
  creationTimestamp: null
  labels:
    name: test-deployment
spec:
  replicas: 2
  selector:
    name: test-deployment
  template:
    metadata:
      labels:
        name: test-deployment
    spec:
      containers:
      - image: openshift/origin-ruby-sample
        name: helloworld

# attempt to run oc apply again
$ oc apply -f simpledc_modified.yaml
The deploymentconfigs "simple-dc" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update

If I run the steps above without setting a metadata.resourceVersion field when I create the dc via oc apply, I do not get the error seen, and the operation succeeds as expected.

Is this a bug, or an expected behavior of apply?

cc @stevekuznetsov @soltysh @liggitt

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 21 (11 by maintainers)

Most upvoted comments

I have the same error “metadata.resourceVersion: Invalid value: 0x0: must be specified for an update”
but in my case the dc does not contain resourceVersion parm at all!

Any update on this issue please?

Same problem. Any workarounds?