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

Deployment scaler to use the scale subresource #51093

Closed
wants to merge 1 commit into from

Conversation

foxish
Copy link
Contributor

@foxish foxish commented Aug 22, 2017

What this PR does / why we need it: This PR sets the deployment scaler to use the scale subresource.

Partially fixes #29698

Special notes for your reviewer:

Release note:

kubectl scale now uses the scale sub-resource when scaling deployments.

cc @kubernetes/sig-cli-pr-reviews

@foxish foxish requested review from mengqiy and caesarxuchao August 22, 2017 09:19
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 22, 2017
@foxish foxish self-assigned this Aug 22, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: foxish
We suggest the following additional approver: deads2k

Assign the PR to them by writing /assign @deads2k in a comment when ready.

Associated issue: 29698

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Aug 22, 2017
@foxish
Copy link
Contributor Author

foxish commented Aug 22, 2017

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot k8s-github-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 23, 2017
@@ -61,7 +61,7 @@ func ScalerFor(kind schema.GroupKind, c internalclientset.Interface) (Scaler, er
case apps.Kind("StatefulSet"):
return &StatefulSetScaler{c.Apps()}, nil
case extensions.Kind("Deployment"), apps.Kind("Deployment"):
return &DeploymentScaler{c.Extensions()}, nil
return &DeploymentScaler{c.Extensions(), c.Extensions()}, nil
Copy link
Member

Choose a reason for hiding this comment

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

Why change this?

}
return nil
}

type DeploymentScaler struct {
c extensionsclient.DeploymentsGetter
d extensionsclient.ScalesGetter
}

// ScaleSimple is responsible for updating a deployment's desired replicas
// count. It returns the resourceVersion of the deployment if the update is
// successful.
func (scaler *DeploymentScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to keep both ScaleSimple() and Scale()?

deployment.Spec.Replicas = int32(newSize)
updatedDeployment, err := scaler.c.Deployments(namespace).Update(deployment)
scale.Spec.Replicas = int32(newSize)
updatedDeployment, err := scaler.d.Scales(namespace).Update("deployment", scale)
if err != nil {
if errors.IsConflict(err) {
Copy link
Member

Choose a reason for hiding this comment

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

When using scale to update, it should never have conflict.
Is it correct? @caesarxuchao

@wanghaoran1988
Copy link
Contributor

xref: #32523 (comment)

@mengqiy
Copy link
Member

mengqiy commented Aug 23, 2017

@foxish Do we plan to scale all workload to use scale subresource?

@@ -69,6 +69,9 @@ func ObjectReaction(tracker ObjectTracker) ReactionFunc {
return func(action Action) (bool, runtime.Object, error) {
ns := action.GetNamespace()
gvr := action.GetResource()
if action.GetSubresource() == "scale" {
gvr = schema.GroupVersionResource{Group: "extensions", Version: "", Resource: "scales"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't right. The group cannot be assumed to be extensions. See RCs and stateful sets as examples.

@deads2k
Copy link
Contributor

deads2k commented Aug 24, 2017

@foxish Do we plan to scale all workload to use scale subresource?

Yes, and eventually it should all be discovered and negotiated how to speak to them. Requires #49971 to negotiate/discover.

@k8s-github-robot
Copy link

This PR hasn't been active in 90 days. Closing this PR. Please reopen if you would like to work towards merging this change, if/when the PR is ready for the next round of review.

cc @deads2k @foxish

You can add 'keep-open' label to prevent this from happening again, or add a comment to keep it open another 90 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl scale should use the scale subresource
6 participants