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 update deployment when there is a change in replicas #715

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

savitaashture
Copy link
Contributor

@savitaashture savitaashture commented Aug 17, 2020

Changes

The changes fix update deployment operation when there is a change in replicas number.
With current code whenever user updates replicas as part of eventlistener update success but no change in behavior.

Fix: #714

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

None

@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 17, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 72.5% 1.8

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2020
@@ -451,20 +454,20 @@ func Test_reconcileDeployment(t *testing.T) {
name: "deployment-replica-update",
startResources: test.Resources{
Namespaces: []*corev1.Namespace{namespaceResource},
EventListeners: []*v1alpha1.EventListener{eventListener1},
Deployments: []*appsv1.Deployment{deployment3},
EventListeners: []*v1alpha1.EventListener{eventListener3},
Copy link
Member

Choose a reason for hiding this comment

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

One issue here is that before we had spec.replicas in the EL itself, users had to manually update the replica on the deployment itself. And we had code and this test to verify that we do not overwrite any changes to the number of replicas on an EL. So, this is a change in our behavior. I am thinking we can either:

  1. Honor the old replica changes i.e. if someone changes the existing replica numbers in the deployment itself and spec.Replicas is not set on the EL, we should not set it back. This keeps the behavior backwards compatible

  2. Or we deprecate the existing behavior (not sure how many people depend on this behavior) and only honor EL's spec.replicas -- we just call this out in the release notes.

One thing I'm curious about (and don't know) is how this will work with Horizontal Pod Autoscalers. Do they change the deployment's spec.Replicas? In that case, if an HPA scales the deployment we do not want to inadvertently scale it back down.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have the behavior where if el.spec.Replicas is set, then we track changes only in el.spec.Replicas and don't care what user set in deployment.
If el.spec.Replicas isn't set, then we don't change deployment replica and let k8s controller take care of it?
HPA uses deployment's number as you surmised. So design 2 will break them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya this is something need to verify with HPA
Thanks for pointing it out i will try and update here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I'm curious about (and don't know) is how this will work with Horizontal Pod Autoscalers. Do they change the deployment's spec.Replicas? In that case, if an HPA scales the deployment we do not want to inadvertently scale it back down.

@dibyom Yes HPA uses deployment so with this PR change if HPA increases replicas on deployment whenever condition met But that will be again overridden by el.Spec.Replicas always

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about below opinion on supporting replicas

  1. Lets keep spec.replicas which can be set by the user and we will add a note in README that if user sets spec.replicas as part of eventlistener yaml then it will override replicas values if user manually set by kubectl edit deployment or by setting HPA
    Which means if spec.replicas set by event listener yaml then it won't respects replicas values edited by user manually or through any other mechanism (ex: HPA)

  2. If user Don't set spec.replicas in eventlistener yaml then behavior will be same like earlier how it use to work before adding replicas field to eventlistener yaml

Few points from WG discussion

  1. Don't allow spec.replicas as part of eventlistener yaml instead hardcode replicas to some number instead of 1
    -> With this approach if we hardcode replicas to say 3 then if HPA configured with --min=2 --max=5 then again replicas number varies

  2. Some prior art / similar behavior for k8s addons - https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/addon-manager
    -> This is bit tricky to implement

/cc @dibyom @khrm @wlynch

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for summarizing the discussion. It sounds good to me!

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 19, 2020
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 72.5% 73.7% 1.2

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 72.5% 73.7% 1.2

@savitaashture
Copy link
Contributor Author

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 24, 2020
@tekton-robot tekton-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 24, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 72.5% 73.7% 1.2

@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2020
@dibyom
Copy link
Member

dibyom commented Aug 25, 2020

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2020
Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2020
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

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

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2020
@savitaashture
Copy link
Contributor Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 25, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 72.5% 73.7% 1.2

@@ -166,6 +166,8 @@ check out the guide on [exposing EventListeners](./exposing-eventlisteners.md).
The `replicas` field is optional. By default, the number of replicas of EventListener is 1.
If you want to deploy more than one pod, you can specify the number to this field.

**Note:** If user sets `replicas` field while creating eventlistener yaml then it won't respects replicas values edited by user manually or through any other mechanism (ex: HPA).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dibyom Added a note as per the discussion here #715 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@dibyom
Copy link
Member

dibyom commented Aug 26, 2020

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 26, 2020
@tekton-robot tekton-robot merged commit efdd904 into tektoncd:master Aug 26, 2020
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. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increasing the el number of replicas requires deleting the deployment
5 participants