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 leader address environment variable injection #144

Merged
merged 1 commit into from
May 20, 2024

Conversation

jjk-g
Copy link
Contributor

@jjk-g jjk-g commented May 14, 2024

This adds LWS_LEADER_ADDRESS environment variable injection constructed via related LWS pod labels. This avoids making the user specify in yaml via downward api.

What type of PR is this?

/kind feature

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #143

Special notes for your reviewer

Does this PR introduce a user-facing change?

Add LWS_LEADER_ADDRESS environment variable to all containers in a leaderworkerset.

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label May 14, 2024
Copy link

linux-foundation-easycla bot commented May 14, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jasonkramberger (caafb85)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 14, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @jasonkramberger!

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 May 14, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @jasonkramberger. 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 14, 2024
@ahg-g
Copy link
Contributor

ahg-g commented May 14, 2024

/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 May 14, 2024
Copy link
Contributor

@kerthcet kerthcet left a comment

Choose a reason for hiding this comment

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

Glad to have this. Thanks @jasonkramberger

pkg/utils/pod/pod_utils.go Outdated Show resolved Hide resolved
pkg/utils/pod/pod_utils_test.go Outdated Show resolved Hide resolved
},
},
ObjectMeta: v1.ObjectMeta{
Name: fmt.Sprintf("%s-%s-%s", setName, groupIndex, workerIndex),
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 the name is not right if this is a leader pod.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if this is a wrapper, let's make it more general like pass in the name and namespace to build a Pod spec.

@@ -139,6 +139,11 @@ func (p *PodWebhook) Default(ctx context.Context, obj runtime.Object) error {
return err
}
}

if err := podutils.AddLWSVariables(pod); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Only needed for workerPod I think, which also worths to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

itt it may simplify some use cases (init scripts) to have this be available to the leader containers as well. I don't know if that is the most compelling use case, but imo it seems more convenient to have this standardized across all containers in the lws.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually the opposite, we need to set this in the webook for the leader, but for the workers we can set it on the worker sts. But it is fine to set it here for all.

Copy link
Contributor

@kerthcet kerthcet May 16, 2024

Choose a reason for hiding this comment

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

Why not localhost then? But I'm ok to keep it, it's not a big problem at this moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

localhost is not relevant here :)

@@ -146,6 +146,23 @@ func MakeWorkerPodSpec() corev1.PodSpec {
}
}

func MakeWorkerPodSpecWithInitContainer() corev1.PodSpec {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make it a PodWrapper to avoid duplicate codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you link me an example? I think this may be something I tackle in the follow up PR mentioned above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, agree.

Copy link
Contributor

@kerthcet kerthcet May 16, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, going to follow up with test code refactoring PR.

pkg/utils/pod/pod_utils.go Outdated Show resolved Hide resolved
pkg/utils/pod/pod_utils.go Show resolved Hide resolved
@@ -139,6 +139,11 @@ func (p *PodWebhook) Default(ctx context.Context, obj runtime.Object) error {
return err
}
}

if err := podutils.AddLWSVariables(pod); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

actually the opposite, we need to set this in the webook for the leader, but for the workers we can set it on the worker sts. But it is fine to set it here for all.

test/testutils/util.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kerthcet kerthcet left a comment

Choose a reason for hiding this comment

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

General LGTM. One last comment. You can squash as well.

api/leaderworkerset/v1/leaderworkerset_types.go Outdated Show resolved Hide resolved
Adds LWS_LEADER_ADDRESS environment variable injection constructed
via related LWS pod labels. This avoids making the user specify in yaml
via downward api.
@liurupeng
Copy link
Collaborator

/lgtm
/approve
/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 May 20, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jasonkramberger, liurupeng

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 May 20, 2024
@k8s-ci-robot k8s-ci-robot merged commit 1bc9e96 into kubernetes-sigs:main May 20, 2024
7 checks passed
Edwinhr716 pushed a commit to Edwinhr716/lws that referenced this pull request May 21, 2024
Adds LWS_LEADER_ADDRESS environment variable injection constructed
via related LWS pod labels. This avoids making the user specify in yaml
via downward api.
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/L Denotes a PR that changes 100-499 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 leader address environment variable
5 participants