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 API encoding inconsistencies in KubeSchedulerConfig #91625

Merged
merged 1 commit into from
Jun 24, 2020

Conversation

pancernik
Copy link
Contributor

@pancernik pancernik commented Jun 1, 2020

What type of PR is this?
/kind api-change

What this PR does / why we need it:
v1 Scheduler Policy config includes Extender type with an inconsistent API encoding.

We fix it by Extender type with a correct API encoding in v1beta1 KubeSchedulerConfiguraton

Which issue(s) this PR fixes:

Fixes #65414

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`v1beta1` Scheduler `Extender` encoding is case-sensitive (`v1alpha1`/`v1alpha2` was case-insensitive), its `httpTimeout` field uses duration encoding (for example, one second is specified as `"1s"`), and the `enableHttps` field in `v1alpha1`/`v1alpha2` was renamed to `enableHTTPS`.

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/30bc12a2e26a06a1995c379df125fc6f6ae58e77/keps/sig-scheduling/785-scheduler-component-config-api

@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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 Jun 1, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @pancernik. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 1, 2020
@pancernik
Copy link
Contributor Author

/cc @alculquicondor

@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.

@Huang-Wei
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 2, 2020
@@ -102,7 +102,7 @@ type KubeSchedulerConfiguration struct {
// Extenders are the list of scheduler extenders, each holding the values of how to communicate
// with the extender. These extenders are shared by all scheduler profiles.
// +listType=set
Extenders []v1.Extender `json:"extenders,omitempty"`
Extenders []Extender `json:"extenders,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

So this means we currently have two Extenders copies in v1 and v1beta1, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Policy includes the old type. It will be removed once KubeSchedulerConfiguration fully replaces Policy.

Copy link
Member

Choose a reason for hiding this comment

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

Once we graduation KubeSchedulerConfiguration to GA, we can rename v1.Extender to v1.DeprecatedExtender.

Copy link
Member

Choose a reason for hiding this comment

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

this is super subtle... can we name this more clearly to make sure we don't use the wrong struct and flip encoding of the enableHttps field?

Copy link
Member

Choose a reason for hiding this comment

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

if we can rename the v1.Extender type later, then we can rename it now, if so, lets do it in this PR (perhaps we can using Legacy instead of Deprecated).

@pancernik
Copy link
Contributor Author

/test pull-kubernetes-kubemark-e2e-gce-big

@pancernik
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce-100-performance

@@ -102,7 +102,7 @@ type KubeSchedulerConfiguration struct {
// Extenders are the list of scheduler extenders, each holding the values of how to communicate
// with the extender. These extenders are shared by all scheduler profiles.
// +listType=set
Extenders []v1.Extender `json:"extenders,omitempty"`
Extenders []Extender `json:"extenders,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Once we graduation KubeSchedulerConfiguration to GA, we can rename v1.Extender to v1.DeprecatedExtender.

if err := autoConvert_config_Extender_To_v1beta1_Extender(in, out, s); err != nil {
return err
}
out.HTTPTimeout.Duration = in.HTTPTimeout
Copy link
Member

Choose a reason for hiding this comment

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

@liggitt why is this not handled by the generated conversion? Is it an anti-pattern to use time.Duration as the internal type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I had a feeling that it should be handled there.

Other parts of k8s use metav1.Duration in internal type which offers no advantages over time.Duration apart of autoconvert.

Copy link
Member

Choose a reason for hiding this comment

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

use metav1.Duration in API type fields

out.BindVerb = in.BindVerb
out.EnableHTTPS = in.EnableHTTPS
out.TLSConfig = (*config.ExtenderTLSConfig)(unsafe.Pointer(in.TLSConfig))
// WARNING: in.HTTPTimeout requires manual conversion: inconvertible types (k8s.io/apimachinery/pkg/apis/meta/v1.Duration vs time.Duration)
Copy link
Member

Choose a reason for hiding this comment

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

use meta/v1.Duration internally and avoid a manual conversion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will still need to do a manual conversion from v1.Extender.

Copy link
Member

Choose a reason for hiding this comment

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

duplicate the type in pkg/scheduler/apis/config/types.go renaming the existing one as LegacyExtender.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, that might not work, please check... but you can do the "manual" conversion in the type that will eventually go away in v1 folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we duplicated Extender as LegacyExtender, we would still have to maintain a translation between them as we would use only one internally. I think it's better to do the manual conversion from v1.LegacyExtender.

Copy link
Member

Choose a reason for hiding this comment

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

correct, only one internally and do manual conversion from the legacy one.

@alculquicondor
Copy link
Member

Please follow the suggestion here regarding release notes #91580 (comment)

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 5, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 10, 2020
@pancernik pancernik force-pushed the v1beta1-extender-encoding branch 2 times, most recently from bc1a62c to 4ef2c9c Compare June 10, 2020 21:07
@pancernik
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 23, 2020
@pancernik
Copy link
Contributor Author

/test pull-kubernetes-integration

if err := Convert_v1_ExtenderTLSConfig_To_config_ExtenderTLSConfig(in.TLSConfig, out.TLSConfig, s); err != nil {
return err
}
}
Copy link
Member

Choose a reason for hiding this comment

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

IIRC, generated code also adds:

else {
  out.TLSConfig = nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@pancernik
Copy link
Contributor Author

/test pull-kubernetes-integration

@pancernik
Copy link
Contributor Author

/retest

@alculquicondor
Copy link
Member

lgtm, but will stamp after @liggitt's approval and squash

@liggitt
Copy link
Member

liggitt commented Jun 24, 2020

/approve
/retest

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, liggitt, pancernik

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 Jun 24, 2020
@pancernik
Copy link
Contributor Author

/test pull-kubernetes-e2e-kind-ipv6

@alculquicondor
Copy link
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
@pancernik
Copy link
Contributor Author

/sig scheduling

@alculquicondor
Copy link
Member

/remove-sig scheduling

@k8s-ci-robot k8s-ci-robot removed the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Jun 24, 2020
@alculquicondor
Copy link
Member

/sig scheduling

clearly, there is a bug in the bot

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 24, 2020
@k8s-ci-robot k8s-ci-robot merged commit 67afc8e into kubernetes:master Jun 24, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Jun 24, 2020
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. 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. 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/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scheduler: fix API inconsistencies and test compatibility
8 participants