Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix incompatible CRDs #203

Merged

Conversation

DirectXMan12
Copy link
Contributor

@DirectXMan12 DirectXMan12 commented May 7, 2019

This introduces two fixes for generated CRDs:

  • populate the status slices so that they don't fail client-side validation
  • allow producing a "trivially versioned" CRD that's compatible with Kubernetes 1.11+ instead of 1.13+
  • make the printcolumn fields optional when appropriate

The CRD status field doesn't have omitempty on its fields, which means
that they get serialized as null.  However, the fields aren't marked
as optional or nullable in the OpenAPI schema, which means they fail
the client-side OpenAPI validation.  This populates the known ones so
that this doesn't happen.  In the long term, we should figure out a
better solution.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2019
@DirectXMan12 DirectXMan12 added this to the 0.2.0 milestone May 7, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 7, 2019
@DirectXMan12 DirectXMan12 force-pushed the bug/incompatible-crds branch 2 times, most recently from e310df3 to 192b99d Compare May 7, 2019 20:07
Copy link
Member

@mengqiy mengqiy left a comment

Choose a reason for hiding this comment

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

one nit

pkg/crd/gen.go Outdated Show resolved Hide resolved
This adds a flag to CRD gen (`trivialVersions=<bool>`), which, when
enabled, moves the storage schema into the root CRD, and wipes all
version-level schemas.  This makes generated CRDs compatible with
pre-Kubernetes-1.13 clusters.
the printcolumn marker had some fields that are optional in kubernetes
which were not marked as optional in the marker.  This fixes that.
@mengqiy
Copy link
Member

mengqiy commented May 7, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 7, 2019
@k8s-ci-robot k8s-ci-robot merged commit 89f6323 into kubernetes-sigs:master May 7, 2019
@DirectXMan12 DirectXMan12 deleted the bug/incompatible-crds branch May 7, 2019 21:57
// NB(directxman12): CRD's status doesn't have omitempty markers, which means things
// get serialized as null, which causes the validator to freak out. Manually set
// these to empty till we get a better solution.
crd.Status.Conditions = []apiext.CustomResourceDefinitionCondition{}
Copy link
Contributor

Choose a reason for hiding this comment

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

An upstream PR would be helpful.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants