Skip to content

Bug 1827600: Fix crd openAPI validation regression#1677

Merged
openshift-merge-robot merged 2 commits intoopenshift:masterfrom
LorbusChris:fix-crd-validation-regression
Apr 27, 2020
Merged

Bug 1827600: Fix crd openAPI validation regression#1677
openshift-merge-robot merged 2 commits intoopenshift:masterfrom
LorbusChris:fix-crd-validation-regression

Conversation

@LorbusChris
Copy link
Copy Markdown
Contributor

#1474 introduced a small regression on the openAPI validation scheme, this fixes that.

- What I did

  • mco: Use "github.com/clarketm/json" for marshaling Ignition configs
    Replaces "encoding/json" with dropin replacement "github.com/clarketm/json"
    that supports zero values of structs with omittempty when marshaling
    Ignition configs.
    In effect, this will exclude empty pointer struct fields from the
    marshaled data instead of inserting nil values into them which do not
    pass openAPI validation on fields that are supposed to contain strings.
    See proposal: encoding/json, encoding/xml: support zero values of structs with omitempty golang/go#11939 for more context.
  • manifests: Update machineconfig crd & bindata
    Reverts a regression on the openAPI validation scheme.
  • Update vendor

- How to verify it
CI

- Description for the changelog
Use "github.com/clarketm/json" for marshaling Ignition configs and revert a regression on the openAPI validation scheme.

@openshift/openshift-team-mco
Please let me know if you want this in 4.5 and therefore need a BZ.

Copy link
Copy Markdown
Contributor

@yuqi-zhang yuqi-zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against using a nullable json parser. Does this mean we can drop all nullable fields in general?

Also I'd prefer if Update vendor and mco: Use "github.com/clarketm/json" for marshaling Ignition configs were just one commit, so reverting is easier if we needed to. I assume this is likely cherry picked from FCOS, and that's how it was originally laid out?

Comment thread pkg/server/api_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this change originate from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the marshaled data is much smaller now due to leaving out all the empty/nulled fields - it's a nice side benefit of using this parser. As the number (114 before, 15 now) is specified a few times, I introdued this constant.

@LorbusChris
Copy link
Copy Markdown
Contributor Author

I'm not against using a nullable json parser. Does this mean we can drop all nullable fields in general?

I'm not entirely sure what you mean here, can you elaborate?

We use this code in fcos: 563275c
Unfortunately the history for this on the branch got lost during the latest big sync merge.

Replaces "encoding/json" with dropin replacement "github.com/clarketm/json"
that supports zero values of structs with omittempty when marshaling
Ignition configs.
In effect, this will exclude empty pointer struct fields from the
marshaled data instead of inserting nil values into them which do not
pass openAPI validation on fields that are supposed to contain strings.
See [1] for more context.

Also updates the vendor directory (with `make go-deps`).

[1]  golang/go#11939
Reverts a regression on the openAPI validation scheme.
@LorbusChris LorbusChris force-pushed the fix-crd-validation-regression branch from 5fd0b83 to 1793580 Compare April 24, 2020 09:10
@LorbusChris
Copy link
Copy Markdown
Contributor Author

LorbusChris commented Apr 24, 2020

@yuqi-zhang, I squashed the two commits.

Wrt above, I think what it means is that we can drop all fields labeled omitempty from the marshaled data (which is what this PR does, even if they're pointer structs). I'm not sure about the nullable part.

@LorbusChris LorbusChris changed the title Fix crd openAPI validation regression Bug 1827600: Fix crd openAPI validation regression Apr 24, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/unspecified bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Apr 24, 2020
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@LorbusChris: This pull request references Bugzilla bug 1827600, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1827600: Fix crd openAPI validation regression

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.

@LorbusChris
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@yuqi-zhang yuqi-zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will let others also take a look in case someone has a concern with the vendoring

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 24, 2020
@runcom
Copy link
Copy Markdown
Member

runcom commented Apr 26, 2020

/approve

@yuqi-zhang
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2020
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LorbusChris, runcom, yuqi-zhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit a8b6ec1 into openshift:master Apr 27, 2020
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@LorbusChris: All pull requests linked via external trackers have merged: openshift/machine-config-operator#1677. Bugzilla bug 1827600 has been moved to the MODIFIED state.

Details

In response to this:

Bug 1827600: Fix crd openAPI validation regression

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants