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

add replicas syncer for resources with HPA #4072

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

lxtywypc
Copy link
Contributor

@lxtywypc lxtywypc commented Sep 18, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
As #4057

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: Introduced `hpaReplicasSyncer` controller which syncs workload's replicas from the member cluster to the control plane.  

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 18, 2023
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 18, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2023

Codecov Report

Patch coverage: 40.24% and project coverage change: -0.02% ⚠️

Comparison is base (5c77f45) 53.80% compared to head (5ae8178) 53.79%.
Report is 18 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4072      +/-   ##
==========================================
- Coverage   53.80%   53.79%   -0.02%     
==========================================
  Files         231      232       +1     
  Lines       23013    23144     +131     
==========================================
+ Hits        12383    12451      +68     
- Misses       9957    10015      +58     
- Partials      673      678       +5     
Flag Coverage Δ
unittests 53.79% <40.24%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...pareplicassyncer/hpa_replicas_syncer_controller.go 40.24% <40.24%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@XiShanYongYe-Chang
Copy link
Member

/assign

@lxtywypc
Copy link
Contributor Author

Hi @XiShanYongYe-Chang

I'm not familiar with the chart-lint-test, could you help me find out why it failed? XD

@XiShanYongYe-Chang
Copy link
Member

XiShanYongYe-Chang commented Sep 19, 2023

Hi @lxtywypc Can we not add the logic related to webhook first? Can we consider adding a finalizer for HPA?

The controller we added can be set to closed by default, but once the webhook is set, it will always take effect. Therefore, there may be inconsistencies between these two behaviors.

@lxtywypc
Copy link
Contributor Author

Okay, I will give a try.

@RainbowMango
Copy link
Member

I think we can focus on building the controller with this PR (for the finalizer thing, we can do it by a follow-up), which helps keep PR small and easy for review and testing.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot~
I skipped the logic related to webhook when I reviewed it.

pkg/replicassyncer/controller.go Outdated Show resolved Hide resolved
pkg/replicassyncer/controller.go Outdated Show resolved Hide resolved
pkg/replicassyncer/controller.go Outdated Show resolved Hide resolved
pkg/replicassyncer/utils.go Outdated Show resolved Hide resolved
pkg/replicassyncer/controller.go Outdated Show resolved Hide resolved
@lxtywypc lxtywypc force-pushed the add-replicas-syncer branch 3 times, most recently from 9b96f9d to 1c49f9e Compare September 19, 2023 10:36
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot~

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot~
Just one little suggestion. Other parts LGTM

Signed-off-by: lxtywypc <lxtywypc@gmail.com>
@karmada-bot karmada-bot 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 Sep 20, 2023
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks a lot~
/lgtm
/cc @RainbowMango @chaosi-zju

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 20, 2023
@karmada-bot
Copy link
Collaborator

@XiShanYongYe-Chang: GitHub didn't allow me to request PR reviews from the following users: chaosi-zju.

Note that only karmada-io members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

Thanks a lot~
/lgtm
/cc @RainbowMango @chaosi-zju

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.

@chaunceyjiang
Copy link
Member

/assign

@XiShanYongYe-Chang
Copy link
Member

Thanks @chaunceyjiang
I'm sorry forgot to assign it to you.

return nil
}

if scale.Spec.Replicas != hpa.Status.CurrentReplicas {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why you are using CurrentReplicas instead of DesiredReplicas?

Copy link
Member

Choose a reason for hiding this comment

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

I think the .status.currentReplicas represents the real replicas of a managed workload, but the .status.desiredReplicas is the planned replicas which might not represent the current situation.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang Sep 20, 2023

Choose a reason for hiding this comment

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

Hi @lxtywypc, can you help update it?

Wait a moment, Let me have a try.

Copy link
Member

Choose a reason for hiding this comment

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

@chaunceyjiang
I guess you mean the .spec.replicas represents desired replicas that match the definition of .status.desiredReplicas in HPA, right?

The difference between the two approaches is when to sync replicas. after and before replica change. It makes more sense to sync desired replicas, it looks like the HPA in the Karmada control plane scales the workload :)

Copy link
Member

Choose a reason for hiding this comment

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

Hi @lxtywypc How do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I guess you mean the .spec.replicas represents desired replicas that match the definition of .status.desiredReplicas in HPA, right?

Yes. I mean exactly this.

Copy link
Member

Choose a reason for hiding this comment

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

So I prefer to use .status.desiredReplicas because its meaning is consistent with .spec.replicas.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @chaunceyjiang, it sounds good to me.

Given following task relies on this controller, I suppose we can move this forward, and leave another task for this.
What do you think? @chaunceyjiang @XiShanYongYe-Chang @lxtywypc

Copy link
Member

Choose a reason for hiding this comment

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

OK

return false
}

return oldHPA.Status.CurrentReplicas != newHPA.Status.CurrentReplicas
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why you use CurrentReplicas insterd of DesiredReplicas

@XiShanYongYe-Chang
Copy link
Member

XiShanYongYe-Chang commented Sep 21, 2023

Now we have different views on whether to use CurrentReplicas or desiredReplicas, and in my opinion, we need to have a more in-depth discussion of that.

For now, whether to use CurrentReplicas or desiredReplicas does not affect the addition of controllers. The current PR complies with the task description in the issue #4057. Therefore, the issues discussed here can be escalated to the issue description for discussion and analysis.

What do you think? @lxtywypc @chaunceyjiang @RainbowMango

Copy link
Member

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

Thanks~

/lgtm

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 21, 2023
@karmada-bot karmada-bot merged commit 68f4ac7 into karmada-io:master Sep 21, 2023
12 checks passed
@lxtywypc lxtywypc deleted the add-replicas-syncer branch September 21, 2023 02:08
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. 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.

None yet

6 participants