Skip to content

Add deprecated, deprecationWarning fields to CRDs#92329

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
liggitt:crd-deprecation
Jul 2, 2020
Merged

Add deprecated, deprecationWarning fields to CRDs#92329
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
liggitt:crd-deprecation

Conversation

@liggitt
Copy link
Copy Markdown
Member

@liggitt liggitt commented Jun 20, 2020

What type of PR is this?
/kind feature

What this PR does / why we need it:
Implements CRD warnings portion of https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1693-warnings / kubernetes/enhancements#1693

Does this PR introduce a user-facing change?:

CustomResourceDefinitions added support for marking versions as deprecated by setting `spec.versions[*].deprecated` to `true`, and for optionally overriding the default deprecation warning with a `spec.versions[*].deprecationWarning` field.

/sig api-machinery
/cc @deads2k
/area custom-resources

@k8s-ci-robot k8s-ci-robot requested a review from deads2k June 20, 2020 01:04
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/custom-resources cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 20, 2020
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt

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

@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 20, 2020
@fejta-bot
Copy link
Copy Markdown

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@liggitt liggitt force-pushed the crd-deprecation branch 2 times, most recently from 3b12241 to a8e56e7 Compare June 20, 2020 03:41
@liggitt liggitt added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Jun 20, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jun 20, 2020
@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 20, 2020

/retest

1 similar comment
@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 20, 2020

/retest

@fedebongio
Copy link
Copy Markdown
Contributor

/cc @roycaihw

@k8s-ci-robot k8s-ci-robot requested a review from roycaihw June 23, 2020 20:08
Copy link
Copy Markdown
Member

@roycaihw roycaihw left a comment

Choose a reason for hiding this comment

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

Some nits. LGTM overall

Comment thread staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1/types.go Outdated
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 24, 2020
@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 24, 2020

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 24, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 24, 2020
@roycaihw
Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 24, 2020
@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 25, 2020

/retest

1 similar comment
@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 25, 2020

/retest

@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jun 29, 2020

/assign @lavalamp
for API review

@liggitt liggitt added this to the v1.19 milestone Jun 29, 2020
@liggitt liggitt assigned smarterclayton and unassigned lavalamp Jun 29, 2020
// deprecated indicates this version of the custom resource API is deprecated.
// When set to true, API requests to this version receive a warning header in the server response.
// Defaults to false.
Deprecated bool
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.

Why don't we simply require someone to write their own DeprecationWarning and avoid having a bool? I haven't read all the way down, but I doubt we have a very good stock message on these since versions don't follow kube versions.

Copy link
Copy Markdown
Member Author

@liggitt liggitt Jul 1, 2020

Choose a reason for hiding this comment

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

The normal case of "X is deprecated" or "X is deprecated; use Y instead" is easy for us to automatically construct, and seemed valuable for consistency with built-in API deprecation warnings in the absence of specific additional information about removal timeframes.

CRD authors indicating a version is deprecated without knowledge of the cadence at which consumers plan to deploy the revision of the CRD which stops serving the deprecated version would not be able to provide a much better message than the one we're generating by default.

return ret, nil
}

func defaultDeprecationWarning(deprecatedVersion string, crd apiextensionsv1.CustomResourceDefinitionSpec) string {
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.

versions for CRDs mapping to kube versions somehow seems weird. I'd rather avoid this entire method by requiring the deprecation string.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is following the same rules we already follow when determining the order we present the CRD versions in discovery

@deads2k
Copy link
Copy Markdown
Contributor

deads2k commented Jul 1, 2020

/lgtm
/hold in case you have someone else you'd like to take a look.

@liggitt
Copy link
Copy Markdown
Member Author

liggitt commented Jul 2, 2020

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit da37b7f into kubernetes:master Jul 2, 2020
@liggitt liggitt deleted the crd-deprecation branch July 6, 2020 14:37
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. area/custom-resources cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: API review completed, 1.19

Development

Successfully merging this pull request may close these issues.

8 participants