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

apiextensions: disallow metadata specs other than name and generateName #77653

Merged

Conversation

sttts
Copy link
Contributor

@sttts sttts commented May 9, 2019

Based on #77207.

Fixes #74620

CRDs should not restrict ObjectMeta fields other than name and generateName. Restricting other metadata values is considered breaking the API conventions. We better don't allow schemas which do that.

With structural schema introduction we have the chance to enforce this.

We do not care about x-kubernetes-embedded-resource:true and metadata there as those objects are not yet Kubernetes objects and the API server is not aware of them as resources.

CRD validation schemas should not specify `metadata` fields other than `name` and `generateName`. A schema will not be considered structural (and therefore ready for future features) if `metadata` is specified in any other way.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 9, 2019
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 9, 2019
@sttts sttts added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label May 9, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label May 9, 2019
@sttts sttts added this to the v1.15 milestone May 9, 2019
@sttts sttts force-pushed the sttts-structural-schema-metadata branch 2 times, most recently from 63925bf to f2754f4 Compare May 9, 2019 12:09
@fejta-bot
Copy link

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.

@jennybuckley
Copy link

/assign @jpbetz

@liggitt liggitt added this to Required for GA, in progress in Custom Resource Definitions May 9, 2019
@DirectXMan12
Copy link
Contributor

cc @droot @mengqiy fyi -- we'll need an override for object meta in CT now

@sttts sttts force-pushed the sttts-structural-schema-metadata branch from f2754f4 to 2e187e1 Compare May 10, 2019 07:33
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 10, 2019
@sttts
Copy link
Contributor Author

sttts commented May 10, 2019

/assign @liggitt @munnerz @DirectXMan12

@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 10, 2019
@sttts
Copy link
Contributor Author

sttts commented May 10, 2019

/cc @ingvagabund

@sttts
Copy link
Contributor Author

sttts commented May 10, 2019

@apelisse this will also answer the question of specifying managedFields.

@sttts sttts force-pushed the sttts-structural-schema-metadata branch from 2e187e1 to d74a9a9 Compare May 10, 2019 08:55
@sttts
Copy link
Contributor Author

sttts commented May 10, 2019

/retest

@liggitt
Copy link
Member

liggitt commented May 14, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 14, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, sttts

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

@Frankkkkk
Copy link

Hi @sttts , with this MR, any idea of how we can add description to "custom" metadata.annotations fields ?

Cheers

@sttts
Copy link
Contributor Author

sttts commented Jan 5, 2021

Hi @sttts , with this MR, any idea of how we can add description to "custom" metadata.annotations fields ?

You cannot. ObjectMeta has – technically – generic semantics indpendently from the object at hand. But I see the use-case.

For the moment, you can only put that documentation in some other field.

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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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.
Development

Successfully merging this pull request may close these issues.

Metadata validation for CustomResources
9 participants