Skip to content

Introduce new component config flag #325

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

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

ardaguclu
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it

This PR adds configuration file and flag to customize the functionality via new config file resource which is already supported by Kueue and JobSet.

Which issue(s) this PR fixes

Fixes #170, #322

Does this PR introduce a user-facing change?

Introducing new config flag to customize behaviors via a flag

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 16, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @ardaguclu!

It looks like this is your first PR to kubernetes-sigs/lws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/lws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 16, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @ardaguclu. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 16, 2025
@ardaguclu
Copy link
Contributor Author

This PR is mostly inspired by kubernetes-sigs/jobset#609 and nearly all credit should still go to @rainfd :)

@kannon92
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 16, 2025
func validateInternalCertManagement(c *configapi.Configuration) field.ErrorList {
var allErrs field.ErrorList
if c.InternalCertManagement == nil || !ptr.Deref(c.InternalCertManagement.Enable, false) {
return allErrs
Copy link
Contributor

Choose a reason for hiding this comment

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

This would return a nil error.

Maybe you should add an error message here that if certManagement is enabled we need the internalCertManager filed out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for review @kannon92.

I'm not sure I fully understand, If internal certificate management is disabled, shouldn't we return nil?. As far as I understand from the code block, if internal cert management is nil or false, we don't need to pursue further validation for the other fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea that is true. Maybe we just return nil there to make it clear we don’t expect an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine as is. I was thinking we could validate if the settings are set if it’s enabled false so we bring awareness that they don’t be used

@kannon92
Copy link
Contributor

The e2e tests are failing due to some oddities with the docker file.

https://github.com/kubernetes-sigs/lws/blob/main/Dockerfile#L19

I think you need to add config to the dockerfile.

@Edwinhr716
Copy link
Contributor

@ahg-g is there a reason why we copy all the folders inside pkg/ separately instead of just copying the whole folder?

@kannon92 kannon92 mentioned this pull request Jan 16, 2025
@ardaguclu
Copy link
Contributor Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jan 17, 2025
@kannon92
Copy link
Contributor

@ahg-g is there a reason why we copy all the folders inside pkg/ separately instead of just copying the whole folder?

I think this comes from the default template for kubebuilder.

@kannon92
Copy link
Contributor

kannon92 commented Jan 19, 2025

Could you update manager to use component config as default for kustomize and helm?

https://github.com/kubernetes-sigs/lws/blob/main/config/manager/manager.yaml

see https://github.com/kubernetes-sigs/jobset/pull/724/files for an example

@ardaguclu
Copy link
Contributor Author

ardaguclu commented Jan 20, 2025

Could you update manager to use component config as default for kustomize and helm?

https://github.com/kubernetes-sigs/lws/blob/main/config/manager/manager.yaml

see https://github.com/kubernetes-sigs/jobset/pull/724/files for an example

@kannon92 I believe that I've successfully updated the required configurations for this.

@kannon92
Copy link
Contributor

LGTM

/assign @ahg-g @kerthcet @Edwinhr716

@ardaguclu
Copy link
Contributor Author

Thanks @ardaguclu This is great, generally LGTM.

Can we have one more test to cover that: the flags will overwrite the config file? And left another comment about Remove the flags in the future.

@kerthcet thank you for review. I've added unit tests based on your suggestions.

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jan 23, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, kerthcet

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2025
@ardaguclu ardaguclu force-pushed the add-component-config branch from 39cc492 to 4cbe08a Compare January 27, 2025 05:21
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 27, 2025
@ardaguclu ardaguclu force-pushed the add-component-config branch from 4cbe08a to 6044f7e Compare January 27, 2025 05:23
Copy link
Contributor

@ahg-g ahg-g left a comment

Choose a reason for hiding this comment

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

few more, sorry for the late review

Comment on lines +55 to +63
if cfg.LeaderElection == nil {
cfg.LeaderElection = &configv1alpha1.LeaderElectionConfiguration{}
}
if len(cfg.LeaderElection.ResourceName) == 0 {
cfg.LeaderElection.ResourceName = DefaultLeaderElectionID
}
if len(cfg.LeaderElection.ResourceLock) == 0 {
cfg.LeaderElection.ResourceLock = DefaultResourceLock
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since LeaderElection is a type that we import, we can default it using the upstream RecommendedDefaultLeaderElectionConfiguration from component-base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +67 to +77
// Host is the hostname that the webhook server binds to.
// It is used to set webhook.Server.Host.
// +optional
Host string `json:"host,omitempty"`

// CertDir is the directory that contains the server key and certificate.
// if not set, webhook server would look up the server key and certificate in
// {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
// must be named tls.key and tls.crt, respectively.
// +optional
CertDir string `json:"certDir,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

do we actually need to make those two (host and certDir) configurable? I don't see why would someone wants to change them. I think it is important to have a tighter API and only expose what we think users will actually want to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I agree with tighter API makes sense, there are various cluster types and webhook configurations are one of the most dynamic. User may want to modify Host or temp directory for CertDir might be different than /tmp.

@ardaguclu
Copy link
Contributor Author

@ahg-g I've updated based on your suggestions. Could you PTAL one more round and thank you.

@ardaguclu
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 27, 2025
Comment on lines 35 to 38
DefaultLeaderElectionID = "b8b2488c.x-k8s.io"
DefaultLeaderElectionLeaseDuration = 15 * time.Second
DefaultLeaderElectionRenewDeadline = 10 * time.Second
DefaultLeaderElectionRetryPeriod = 2 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move those to the test file since changing them is not going to actually change the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Updated.

@ahg-g
Copy link
Contributor

ahg-g commented Jan 28, 2025

/lgtm

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 28, 2025
@k8s-ci-robot k8s-ci-robot merged commit 06f2219 into kubernetes-sigs:main Jan 28, 2025
9 checks passed
@ardaguclu ardaguclu deleted the add-component-config branch January 28, 2025 05:50
@kerthcet kerthcet mentioned this pull request Mar 26, 2025
19 tasks
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add component config
6 participants