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

Promote APF API to v1 #121089

Merged
merged 15 commits into from Oct 31, 2023
Merged

Promote APF API to v1 #121089

merged 15 commits into from Oct 31, 2023

Conversation

tkashem
Copy link
Contributor

@tkashem tkashem commented Oct 9, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The flowcontrol.apiserver.k8s.io/v1beta3 FlowSchema and PriorityLevelConfiguration APIs has been promoted to flowcontrol.apiserver.k8s.io/v1, with the following changes:
* PriorityLevelConfiguration: the `.spec.limited.nominalConcurrencyShares` field defaults to `30` only if the field is omitted (v1beta3 also defaulted an explicit `0` value to `30`). Specifying an explicit `0` value is not allowed in the `v1` version in v1.29 to ensure compatibility with 1.28 API servers. In v1.30, explicit `0` values will be allowed in this field in the `v1` API.
The flowcontrol.apiserver.k8s.io/v1beta3 APIs are deprecated and will no longer be served in v1.32. All existing objects are available via the `v1` APIs. Transition clients and manifests to use the `v1` APIs before upgrading to v1.32.

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


@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. kind/feature Categorizes issue or PR as related to a new feature. 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. area/apiserver do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 9, 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 9, 2023
@tkashem tkashem changed the title Apf v1 Promote APF API to v1 Oct 9, 2023
@tkashem tkashem changed the title Promote APF API to v1 [WIP] Promote APF API to v1 Oct 9, 2023
@tkashem
Copy link
Contributor Author

tkashem commented Oct 9, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Oct 9, 2023
@tkashem tkashem force-pushed the apf-v1 branch 2 times, most recently from c787a3d to 61e067b Compare October 10, 2023 15:54
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. area/code-generation labels Oct 10, 2023
@tkashem
Copy link
Contributor Author

tkashem commented Oct 10, 2023

/ok-to-test

@tkashem
Copy link
Contributor Author

tkashem commented Oct 10, 2023

/ok-to-test

@tkashem
Copy link
Contributor Author

tkashem commented Oct 30, 2023

I had to rebase on top of #118886, the only change due to the rebase was:

diff --git a/staging/src/k8s.io/apiserver/pkg/server/options/feature.go b/staging/src/k8s.io/apiserver/pkg/server/options/feature.go
index 0f2ba362704..f484be0b570 100644
--- a/staging/src/k8s.io/apiserver/pkg/server/options/feature.go
+++ b/staging/src/k8s.io/apiserver/pkg/server/options/feature.go
@@ -79,7 +79,7 @@ func (o *FeatureOptions) ApplyTo(c *server.Config, clientset kubernetes.Interfac
                }
                c.FlowControl = utilflowcontrol.New(
                        informers,
-                       clientset.FlowcontrolV1beta3(),
+                       clientset.FlowcontrolV1(),
                        c.MaxRequestsInFlight+c.MaxMutatingRequestsInFlight,
                )
        }

@@ -86,8 +98,16 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
if errs := validateAPIPriorityAndFairness(options); len(errs) > 0 {
errMessageGot = errs[0].Error()
}
if !strings.Contains(errMessageGot, test.errShouldContain) {
t.Errorf("Expected error message to contain: %q, but got: %q", test.errShouldContain, errMessageGot)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test was always broken, strings.Contains(errMessageGot, "") is always true, it's fixed below.

@@ -419,6 +419,10 @@ type LimitedPriorityLevelConfiguration struct {
// Bigger numbers mean a larger nominal concurrency limit,
// at the expense of every other priority level.
// This field has a default value of 30.
//
// Setting this field to zero allows for the construction of a
Copy link
Member

Choose a reason for hiding this comment

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

can we say "supports" rather than "allows"? I think "allows" suggests that this is all that is needed to make that jail, and this is not true.

errExpected: nil,
},
{
name: "v1beta3, feature enabled, update, zero value, existing has non-zero, error expected",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo: it should be "no error expected"

@@ -340,10 +348,11 @@ func ValidateFlowSchemaCondition(condition *flowcontrol.FlowSchemaCondition, fld
}

// ValidatePriorityLevelConfiguration validates priority-level-configuration.
func ValidatePriorityLevelConfiguration(pl *flowcontrol.PriorityLevelConfiguration, requestGV schema.GroupVersion) field.ErrorList {
func ValidatePriorityLevelConfiguration(pl *flowcontrol.PriorityLevelConfiguration, requestGV schema.GroupVersion, opts PriorityLevelValidationOptions) field.ErrorList {
Copy link
Member

Choose a reason for hiding this comment

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

We want to make sure the annotation used to indicate a zero value that should not be defaulted in v1beta3 never makes it through conversion to any other versions. To do that, check for and forbid the annotation here.

// set the annotation to an empty string:
// "flowcontrol.k8s.io/concurrency-shares-defaults-to-zero": ""
//
PriorityLevelConcurrencyShareDefaultKey = "flowcontrol.k8s.io/concurrency-shares-defaults-to-zero"
Copy link
Member

Choose a reason for hiding this comment

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

This annotation is specific to v1beta3... we no longer serve or store in v1beta1 or v1beta2, so we don't have to worry about round-tripping zero values to those, and we don't want this annotation to be used in v1 (see comment about forbidding it in validation after we've converted to the internal version). I'd suggest putting v1beta3 in the annotation key and documenting it is only for use in v1beta3.

Also, "defaults-to-zero" isn't quite right, when this annotation is present we don't default zero.

I'd suggest flowcontrol.k8s.io/v1beta3-preserve-zero-concurrency-shares

@liggitt
Copy link
Member

liggitt commented Oct 30, 2023

API bits are really close. One comment on the name of the conversion annotation, and making sure the annotation doesn't escape conversion in validation.

As a fast follow to this PR (e.g. ~tomorrow), an e2e test for each type that walks through exercising discovery and CRUD of every verb / endpoint for both APIs is needed. All GA APIs are expected to be exercised by conformance tests by default unless there is a compelling reason they should not be included in conformance. https://apisnoop.cncf.io/conformance-progress shows the progress of adding conformance tests for existing GA APIs. An example that runs through verbs / operations for PV / PVC is at https://github.com/kubernetes/kubernetes/blob/master/test/e2e/storage/persistent_volumes.go#L417-L655

Getting that written / merged ~tomorrow would let it soak and get promoted to conformance by test freeze November 15th.

@tkashem
Copy link
Contributor Author

tkashem commented Oct 30, 2023

API bits are really close. One comment on the name of the conversion annotation, and making sure the annotation doesn't escape conversion in validation.

The changes are in this commit - b8cd792

@tkashem
Copy link
Contributor Author

tkashem commented Oct 30, 2023

2/7426 Tests Failed. | expand_less
-- | --
Kubernetes e2e suite: [It] [sig-cli] Kubectl client Simple pod should contain last line of the log [sig-cli] expand_less26s{ failed [FAILED] Expected     <string>: failed to create fsnotify watcher: too many open files to contain substring     <string>: EOF In [It] at: test/e2e/kubectl/kubectl.go:877 @ 10/30/23 23:11:12.88 } | Kubernetes e2e suite: [It] [sig-cli] Kubectl client Simple pod should contain last line of the log [sig-cli] expand_less | 26s | { failed [FAILED] Expected     <string>: failed to create fsnotify watcher: too many open files to contain substring     <string>: EOF In [It] at: test/e2e/kubectl/kubectl.go:877 @ 10/30/23 23:11:12.88 }
Kubernetes e2e suite: [It] [sig-cli] Kubectl client Simple pod should contain last line of the log [sig-cli] expand_less | 26s
{ failed [FAILED] Expected     <string>: failed to create fsnotify watcher: too many open files to contain substring     <string>: EOF In [It] at: test/e2e/kubectl/kubectl.go:877 @ 10/30/23 23:11:12.88 }

/test pull-kubernetes-e2e-gce

@liggitt
Copy link
Member

liggitt commented Oct 31, 2023

/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 Oct 31, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0e03c5ccb9f8b7b1555618569059ab31d2309e2b

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 31, 2023
@MikeSpreitzer
Copy link
Member

Thanks, @tkashem and @liggitt !

@k8s-ci-robot k8s-ci-robot merged commit f5a5d83 into kubernetes:master Oct 31, 2023
17 checks passed
@sftim
Copy link
Contributor

sftim commented Nov 18, 2023

Changelog suggestion

-The flowcontrol.apiserver.k8s.io/v1beta3 FlowSchema and PriorityLevelConfiguration APIs has been promoted to flowcontrol.apiserver.k8s.io/v1, with the following changes:
-* PriorityLevelConfiguration: the `.spec.limited.nominalConcurrencyShares` field defaults to `30` only if the field is omitted (v1beta3 also defaulted an explicit `0` value to `30`). Specifying an explicit `0` value is not allowed in the `v1` version in v1.29 to ensure compatibility with 1.28 API servers. In v1.30, explicit `0` values will be allowed in this field in the `v1` API.
-The flowcontrol.apiserver.k8s.io/v1beta3 APIs are deprecated and will no longer be served in v1.32. All existing objects are available via the `v1` APIs. Transition clients and manifests to use the `v1` APIs before upgrading to v1.32.
+The flowcontrol.apiserver.k8s.io/v1beta3 FlowSchema and PriorityLevelConfiguration APIs have been promoted to flowcontrol.apiserver.k8s.io/v1, with the following changes:
+* PriorityLevelConfiguration: the `.spec.limited.nominalConcurrencyShares` field defaults to `30` only if the field is omitted (v1beta3 also defaulted an explicit `0` value to `30`). Specifying an explicit `0` value is not allowed in the `v1` version in v1.29 to ensure compatibility with 1.28 API servers. In v1.30, explicit `0` values will be admitted.
+
+Deprecated the flowcontrol.apiserver.k8s.io/v1beta3 API group. These deprecated APIs will no longer be served in Kubernetes v1.32. All existing API priority and fairness objects are available via the `v1` APIs. Transition clients and manifests to use the `v1` APIs before upgrading to v1.32.

How does that sound? (please see following text for context)

Do we need to support someone dumping a PriorityLevelConfiguration to YAML using flowcontrol.apiserver.k8s.io/v1beta3 and then to round-trip that object back to the API server? If we do, v1.30 would need to allow explicit 0 values for .spec.limited.nominalConcurrencyShares even if the beta API is used.
I've assumed a Yes and the diff above reflects that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/code-generation area/test 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: API review completed, 1.29
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants