Bug 1403134

Summary: 'oc edit istag' failed with 'unable to find api field in struct RawExtension'
Product: OpenShift Container Platform Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: low    
Version: 3.4.0CC: aos-bugs, ffranz, jokerman, jvallejo, maszulik, mkargaki, mmccomas, tdawson
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: .spec.dockerImageMetadata was unnecessarily used when patching ImageStreamTag. Consequence: As a consequence oc edit couldn't succeed. Fix: Patch mechanism used in oc edit was modified in such a way to always replace the contents of .spec.dockerImageMetadata field. Result: User should be able to invoke oc edit on any ImageStreamTag.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-12 19:18:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Xingxing Xia 2016-12-09 07:34:33 UTC
Description of problem:
'oc edit istag' failed with:
error: unable to find api field in struct RawExtension for the json field "Config"

Version-Release number of selected component (if applicable):
oc v3.4.0.33

How reproducible:
Always

Steps to Reproduce:
1. Create project. Create imagestream
$ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/image-streams/image-streams-centos7.json

2. Edit imagestreamtag ruby:2.2 to add "hidden" tag in .metadata.annotations.tags
$ oc edit istag ruby:2.2

3. As comparison, use 'oc patch' to add "hidden" tag
$ oc patch istag ruby:2.2 -p '{ "metadata": { "annotations": { "tags": "hidden,builder,ruby" } } }'

Actual results:
2. Failed with:
A copy of your changes has been stored to "/tmp/oc-edit-zxxo2.yaml"
error: unable to find api field in struct RawExtension for the json field "Config"

3. 'oc patch' can successfully update istag.

Expected results:
2. 'oc edit' should succeed updating istag.

Additional info:

Comment 2 Juan Vallejo 2017-01-30 21:11:37 UTC
Looks like this might be fixed in a future update to strategic merge patch that allows it to deal with fields without a schema (RawExtension in this case)

Comment 3 Maciej Szulik 2017-01-31 12:43:16 UTC
Juan, it doesn't look like it's fixed in newer versions. The logic is still pretty much the same and it'll trip over in the same place when comparing two different dockerImageMetadata part of an Image. My proposed solution [1] allows setting patchStrategy for struct objects. Looking for input on the PR.


[1] https://github.com/openshift/origin/pull/12731

Comment 4 Juan Vallejo 2017-01-31 15:09:51 UTC
> Juan, it doesn't look like it's fixed in newer versions. The logic is still pretty much the same and it'll trip over in the same place when comparing two different dockerImageMetadata part of an Image.

Apologies for the confusion in #c2. I meant that this was part of a list of proposed changes to make generic kubectl cmds work with unstructured objects. See https://github.com/kubernetes/kubernetes/pull/40260

> My proposed solution [1] allows setting patchStrategy for struct objects. Looking for input on the PR.

Sounds good, will take a look. Thanks!

Comment 5 Maciej Szulik 2017-01-31 15:49:39 UTC
>Apologies for the confusion in #c2. I meant that this was part of a list of proposed changes to make generic kubectl cmds work with unstructured objects. See https://github.com/kubernetes/kubernetes/pull/40260

I've looked into k8s master which already had that changes and it didn't occur to me that this addresses the problem in any way, thus my proposed fix.

Comment 6 openshift-github-bot 2017-02-15 23:24:18 UTC
Commit pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/2a248fb46d6153d2b359d8bf5234a48a7e492b42
Merge pull request #12731 from soltysh/bug1403134

Merged by openshift-bot

Comment 7 Xingxing Xia 2017-02-20 01:57:51 UTC
Verified in openshift/oc v3.5.0.31-1. Now 'oc edit istag' succeeds in comment 0 steps

Comment 9 errata-xmlrpc 2017-04-12 19:18:12 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, 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-2017:0884