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

feat: adopt zones in scheduler spread by constraints #4002

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

zishen
Copy link
Member

@zishen zishen commented Aug 25, 2023

What type of PR is this?

/kind feature
/kind cleanup

What this PR does / why we need it:

Adopt zones in scheduler spread by constraints.

Which issue(s) this PR fixes:
part of #3952

Special notes for your reviewer:

@RainbowMango @whitewindmills @huone1

Does this PR introduce a user-facing change?:

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Aug 25, 2023
@karmada-bot karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 25, 2023
@zishen
Copy link
Member Author

zishen commented Aug 25, 2023

For zone is not supported in scheduler's spread constraint yet,I do not know how to test the zone selection schedule.

see the code here

func selectBestClustersBySpreadConstraints(spreadConstraints []policyv1alpha1.SpreadConstraint,
	groupClustersInfo *GroupClustersInfo, needReplicas int32) ([]*clusterv1alpha1.Cluster, error) {
	spreadConstraintMap := make(map[policyv1alpha1.SpreadFieldValue]policyv1alpha1.SpreadConstraint)
	for i := range spreadConstraints {
		spreadConstraintMap[spreadConstraints[i].SpreadByField] = spreadConstraints[i]
	}

	if _, exist := spreadConstraintMap[policyv1alpha1.SpreadByFieldRegion]; exist {
		return selectBestClustersByRegion(spreadConstraintMap, groupClustersInfo)
	} else if _, exist := spreadConstraintMap[policyv1alpha1.SpreadByFieldCluster]; exist {
		return selectBestClustersByCluster(spreadConstraintMap[policyv1alpha1.SpreadByFieldCluster], groupClustersInfo, needReplicas)
	} else {
		return nil, fmt.Errorf("just support cluster and region spread constraint")
	}
}

@zishen zishen changed the title Adopt zones in scheduler spread by constraints feat: adopt zones in scheduler spread by constraints Aug 25, 2023
Signed-off-by: Tanggui Bian <softwarebtg@163.com>
@codecov-commenter
Copy link

Codecov Report

Merging #4002 (10b5ff2) into master (fb4c16d) will increase coverage by 0.14%.
Report is 8 commits behind head on master.
The diff coverage is 91.66%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #4002      +/-   ##
==========================================
+ Coverage   54.48%   54.62%   +0.14%     
==========================================
  Files         232      232              
  Lines       22685    22854     +169     
==========================================
+ Hits        12359    12485     +126     
- Misses       9649     9688      +39     
- Partials      677      681       +4     
Flag Coverage Δ
unittests 54.62% <91.66%> (+0.14%) ⬆️

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

Files Changed Coverage Δ
.../scheduler/core/spreadconstraint/group_clusters.go 90.47% <91.66%> (-4.73%) ⬇️

... and 6 files with indirect coverage changes

Copy link
Member

@whitewindmills whitewindmills left a comment

Choose a reason for hiding this comment

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

The zone spread constraint is still dead code for now. So I think this PR is unnecessary.

@RainbowMango
Copy link
Member

I get it, This PR just adopted the new zones, how about moving this forward and you can refactor it in #3662?

@whitewindmills
Copy link
Member

how about moving this forward and you can refactor it in #3662?

these zone spread constraint codes have been deleted in #3662. 😂

@RainbowMango
Copy link
Member

I agree that dead code should be removed.

This PR just removed the reference to deprecated code, that's the benefit we can get before #3662.
My opinion is moving this PR forward. What do you think @whitewindmills ?

@whitewindmills
Copy link
Member

okay, just move it forward.

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.

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2023
@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 Aug 29, 2023
@karmada-bot karmada-bot merged commit 641681d into karmada-io:master Aug 29, 2023
12 checks passed
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants