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

Track ownership of scale subresource #98377

Merged

Conversation

nodo
Copy link
Contributor

@nodo nodo commented Jan 25, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

Track ownership of scale subresource for all scalable resources i.e. Deployment, ReplicaSet, StatefulSet, ReplicationController, and Custom Resources.

Which issue(s) this PR fixes:
Fixes #82046
Fixes #94585

Special notes for your reviewer:
I opened #95921 as an initial attempt to solve the problem. As this PR follows a different approach, I decided to open a new PR for clarity.

Does this PR introduce a user-facing change?:

Track ownership of scale subresource for all scalable resources i.e. Deployment, ReplicaSet, StatefulSet, ReplicationController, and Custom Resources.

@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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 Jan 25, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @nodo. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/apiserver labels Jan 25, 2021
@k8s-ci-robot k8s-ci-robot added area/test 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. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 25, 2021
@nodo
Copy link
Contributor Author

nodo commented Jan 25, 2021

/cc @apelisse @kwiesmueller

@apelisse
Copy link
Member

/assign
/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 Jan 25, 2021
@kwiesmueller
Copy link
Member

/wg api-expression

@k8s-ci-robot k8s-ci-robot added the wg/api-expression Categorizes an issue or PR as relevant to WG API Expression. label Jan 25, 2021
@apelisse
Copy link
Member

It's very encouraging that we're finally on the right track for this bug! I think there are a lot of improvements we can make to the code so that we don't fall into various traps (and most, if not all, my comments are related to that), but it's great that we're going the right direction!

@apelisse
Copy link
Member

I think the only question left is the conversion! Thank you :-)

@lavalamp
Copy link
Member

I don't think registry should be importing the client, if you have to can you at least change the package name (add "_test") so that the import graph isn't weird?

lgtm other than that.

@nodo
Copy link
Contributor Author

nodo commented Apr 20, 2021

/retest

@@ -58,7 +58,7 @@ type DeploymentStorage struct {
}

// maps a group version to the replicas path in a deployment object
var replicasPathInDeployment = fieldmanager.ResourcePathMappings{
var ReplicasPathInDeployment = fieldmanager.ResourcePathMappings{
Copy link
Member

Choose a reason for hiding this comment

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

Making it public is fine, but it should be returned by a function so that people can't modify it. And let's move the test to integration, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will amend the commit

@nodo nodo force-pushed the scale-ownership-tracking-deployment branch from f8a6ee7 to 41312b7 Compare April 21, 2021 16:42
@nodo
Copy link
Contributor Author

nodo commented Apr 21, 2021

The last commit is still WIP, I will squash it with a previous one.

- Test all versions to make sure each resource version is in the
  mappings
- Fail when request info contains an unrecognized version. We have tests
  that guarantee that all known versions are in the mappings. If we
  get a version in request info that is not there we should fail fast to
  prevent inconsistent behaviour (e.g. for some reason the mappings is
  not up to date).

Ensure all known versions are in mappings
This happens when a request changes the .status.replicas but not
.spec.replicas
This is aligned to the behaviour of server-side apply on main resources.
This is to prevent the ScaleHandler to drop the entry. In this way
entries just get ignored.
@nodo nodo force-pushed the scale-ownership-tracking-deployment branch from 41312b7 to 5b666a6 Compare April 21, 2021 18:29
@nodo
Copy link
Contributor Author

nodo commented Apr 21, 2021

Squashed the commit and rebased.

Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

conversion change lgtm

@@ -165,6 +165,13 @@ func (c *crConverter) ConvertToVersion(in runtime.Object, target runtime.GroupVe
// TODO: should this be a typed error?
return nil, fmt.Errorf("%v is unstructured and is not suitable for converting to %q", fromGVK.String(), target)
}
// Special-case typed scale conversion if this custom resource supports a scale endpoint
Copy link
Member

Choose a reason for hiding this comment

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

lgtm

@apelisse
Copy link
Member

OK, Thanks @nodo!

/lgtm

Who wants to approve, @lavalamp @liggitt ?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 21, 2021
@liggitt
Copy link
Member

liggitt commented Apr 21, 2021

Who wants to approve, @lavalamp @liggitt ?

Daniel's approval still holds

@apelisse
Copy link
Member

Ah, I missed it, thank you :-)

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@apelisse
Copy link
Member

/retest

2 similar comments
@nodo
Copy link
Contributor Author

nodo commented Apr 22, 2021

/retest

@nodo
Copy link
Contributor Author

nodo commented Apr 22, 2021

/retest

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 area/code-generation area/dependency Issues or PRs related to dependency changes 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. wg/api-expression Categorizes an issue or PR as relevant to WG API Expression.
Projects
None yet