origin icon indicating copy to clipboard operation
origin copied to clipboard

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

Open juanvallejo opened this issue 8 years ago • 21 comments

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

juanvallejo avatar Jun 01 '18 21:06 juanvallejo

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

I wonder if it's worth the hassle now that there's work upstream towards server-side apply.

soltysh avatar Jun 05 '18 09:06 soltysh

apply should likely do something better here, but creating with a resourceVersion to begin with is suspect

liggitt avatar Jun 07 '18 21:06 liggitt

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Sep 06 '18 01:09 openshift-bot

/remove-lifecycle stale

soltysh avatar Sep 06 '18 09:09 soltysh

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Dec 11 '18 00:12 openshift-bot

/remove-lifecycle stale

soltysh avatar Dec 19 '18 13:12 soltysh

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?

aarthipa avatar Feb 21 '19 15:02 aarthipa

Same problem. Any workarounds?

Asgoret avatar Apr 11 '19 23:04 Asgoret

Having same issue.

HomemBravo avatar Apr 17 '19 13:04 HomemBravo

+1 for this issue

Avni-Sharma avatar May 16 '19 06:05 Avni-Sharma

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Aug 14 '19 11:08 openshift-bot

/remove-lifecycle stale

dariodsa avatar Aug 26 '19 07:08 dariodsa

It worked when I changed apply to replace, so you can try with it.

dariodsa avatar Aug 27 '19 10:08 dariodsa

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Nov 25 '19 12:11 openshift-bot

/remove-lifecycle stale

teamdefinex avatar Dec 25 '19 07:12 teamdefinex

It worked when I changed apply to replace, so you can try with it.

"The imperative replace command replaces the existing spec with the newly provided one, dropping all changes to the object missing from the configuration file. This approach should not be used with resource types whose specs are updated independently of the configuration file." It is not an alternative for apply. We are still having the same issue.

teamdefinex avatar Dec 25 '19 07:12 teamdefinex

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Mar 24 '20 11:03 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Apr 23 '20 13:04 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar May 23 '20 15:05 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci-robot avatar May 23 '20 15:05 openshift-ci-robot