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

KEP-4222: Restrict supported media types for new apiservers. #121325

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

benluddy
Copy link
Contributor

@benluddy benluddy commented Oct 18, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Refuse to instantiate a generic apiserver if it is configured with support for data formats other than JSON, YAML, or Protobuf. The motivating use case is to prevent accidental enablement of CBOR in the early stages of phased implementation.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Updated the generic apiserver library to produce an error if a new API server is configured with support for a data format other than JSON, YAML, or Protobuf.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/blob/61a31ed7c7be459ab14dc5fe3132d3b4cd3aa00c/keps/sig-api-machinery/4222-cbor-serializer/README.md#phased-implementation

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 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. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 18, 2023
@benluddy
Copy link
Contributor Author

/sig api-machinery
/cc @deads2k

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 18, 2023
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 18, 2023
@deads2k
Copy link
Contributor

deads2k commented Oct 18, 2023

This looks reasonable to me. If a consumer is broken, we could add a direct code method to skip. But I doubt people wrote customer serializers before and this is very clear.

@benluddy benluddy marked this pull request as ready for review October 18, 2023 17:36
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 Oct 18, 2023
This is to prevent the enablement of new data formats (CBOR) in the early stages of phased
implementation.
@benluddy
Copy link
Contributor Author

Proof PR #121334 job https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/121334/pull-kubernetes-e2e-kind/1714750722723024896:

2023-10-18T21:27:55.596216356Z stderr F E1018 21:27:55.596086 1 run.go:74] "command failed" err="refusing to create new apiserver "apiextensions-apiserver" with support for media type "foo/bar" (allowed media types are: application/json, application/yaml, application/vnd.kubernetes.protobuf)"

@deads2k
Copy link
Contributor

deads2k commented Oct 19, 2023

Proof looks good.

/kind feature
/approve

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 19, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benluddy, deads2k

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 Oct 19, 2023
@benluddy
Copy link
Contributor Author

/cc @liggitt

@liggitt
Copy link
Member

liggitt commented Oct 19, 2023

not sure I have context to lgtm this, happy to defer to @deads2k's review.

is this guarding the --storage-media-type flag or something else?

@Jefftree
Copy link
Member

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 19, 2023
@deads2k
Copy link
Contributor

deads2k commented Oct 19, 2023

not sure I have context to lgtm this, happy to defer to @deads2k's review.

is this guarding the --storage-media-type flag or something else?

Added for the storage into etcd.

This starts gating all k8s.io/apiserver that uses our standard serialization flows, we could add a direct code method to skip. But I doubt people wrote customer serializers before and this is very clear.

@deads2k
Copy link
Contributor

deads2k commented Oct 23, 2023

Looks like good defense.

/lgtm

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

LGTM label has been added.

Git tree hash: 092741d7cf4cb0c163c2a8e7a8f08105b92a8175

@deads2k
Copy link
Contributor

deads2k commented Oct 23, 2023

/hold

for @jpbetz

@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 Oct 23, 2023
Copy link
Contributor

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

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

Minor nit then LGTM

@@ -724,13 +724,31 @@ func (c *RecommendedConfig) Complete() CompletedConfig {
return c.Config.Complete(c.SharedInformerFactory)
}

var allowedMediaTypes = []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Use a const here?

Copy link
Contributor

Choose a reason for hiding this comment

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

nvm, this can't be a const in Go

@@ -87,6 +88,12 @@ func NewEtcdOptions(backendConfig *storagebackend.Config) *EtcdOptions {
return options
}

var storageMediaTypes = sets.New(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Use a const here?

Copy link
Contributor

Choose a reason for hiding this comment

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

nvm, this can't be a const in Go

@jpbetz
Copy link
Contributor

jpbetz commented Oct 23, 2023

/lgtm

@jpbetz
Copy link
Contributor

jpbetz commented Oct 23, 2023

/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 Oct 23, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2014ce2 into kubernetes:master Oct 23, 2023
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 23, 2023
@sftim
Copy link
Contributor

sftim commented Oct 25, 2023

Changelog suggestion

Updated the generic apiserver library to produce an error if a new API server is configured with support for a data format other than JSON, YAML, or Protobuf.

@benluddy
Copy link
Contributor Author

Changelog suggestion

Updated the generic apiserver library to produce an error if a new API server is configured with support for a data format other than JSON, YAML, or Protobuf.

Adopted your suggestion, thank you!

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/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants