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 Support for Component Priority Class Configuration in Karmada Operator #6068

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jabellard
Copy link
Contributor

@jabellard jabellard commented Jan 20, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:
This is an implementation of this proposal to add support for configuring the priority class name of Karmada control plane components.

Which issue(s) this PR fixes:
Fixes #6009
Partof #6042
Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-operator`: The new `PriorityClassName` field added as part of the Karmada control plane component configurations can be used to specify the priority class name of that component.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 20, 2025
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 20, 2025
@jabellard jabellard force-pushed the control-plane-priority-class branch from 9d89807 to 9a8c510 Compare January 20, 2025 19:01
@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 48.36%. Comparing base (820fd06) to head (954ee76).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
operator/pkg/util/patcher/pather.go 40.00% 3 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6068      +/-   ##
==========================================
+ Coverage   48.33%   48.36%   +0.02%     
==========================================
  Files         666      666              
  Lines       54858    54889      +31     
==========================================
+ Hits        26518    26545      +27     
- Misses      26616    26619       +3     
- Partials     1724     1725       +1     
Flag Coverage Δ
unittests 48.36% <81.25%> (+0.02%) ⬆️

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

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

@zhzhuang-zju
Copy link
Contributor

/kind api-change

@karmada-bot karmada-bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jan 21, 2025
@zhzhuang-zju
Copy link
Contributor

thanks @jabellard Generally LGTM. This is merely a suggestion: for the fields in CommonSettings, I recommend using patcher to handle the passing of field values. This approach can centralize modifications and make them easier to manage. For instance:

// Patcher defines multiple variables that need to be patched.
type Patcher struct {
	labels            map[string]string
        ... ...
	resources         corev1.ResourceRequirements
        priorityClassName string
}

func (p *Patcher) WithPriorityClassName(priorityClassName string) *Patcher {
	p.priorityClassName = priorityClassName
	return p
}

func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) {
	deployment.Annotations = labels.Merge(deployment.Annotations, p.annotations)
	deployment.Spec.Template.Annotations = labels.Merge(deployment.Spec.Template.Annotations, p.annotations)

	deployment.Spec.Template.Spec.PriorityClassName = p.priorityClassName
        ... ...
}

func (p *Patcher) ForStatefulSet(sts *appsv1.StatefulSet) {
	sts.Labels = labels.Merge(sts.Labels, p.labels)
	sts.Spec.Template.Labels = labels.Merge(sts.Spec.Template.Labels, p.labels)
	
	sts.Spec.Template.Spec.PriorityClassName = p.priorityClassName
        ... ...
}

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.

/assign

@RainbowMango
Copy link
Member

thanks @jabellard Generally LGTM. This is merely a suggestion: for the fields in CommonSettings, I recommend using patcher to handle the passing of field values. This approach can centralize modifications and make them easier to manage

Make sense to me. It seems we have a lesson learned after introducing a new configuration led to configuration chaos because failed to properly handle the order of the variables.

@jabellard
Copy link
Contributor Author

I recommend using patcher to handle the passing of field values.

That's a great idea. Will push some changes shortly to incorporate that.

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from rainbowmango. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@jabellard
Copy link
Contributor Author

@RainbowMango , @zhzhuang-zju: Thanks for the constructive feedback. Just pushed changes to address your moments.

@zhzhuang-zju
Copy link
Contributor

/lgtm
leave the approval to @RainbowMango

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2025
@zhzhuang-zju
Copy link
Contributor

@jabellard It would be nice to merge the commit

@jabellard jabellard force-pushed the control-plane-priority-class branch from 385338b to 954ee76 Compare January 24, 2025 01:45
@karmada-bot
Copy link
Collaborator

New changes are detected. LGTM label has been removed.

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2025
@jabellard
Copy link
Contributor Author

@jabellard It would be nice to merge the commit

Just squashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. 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.

Add Support for Component Priority Class Configuration in Karmada Operator
5 participants