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

Is it inappropriate to mark leaderworkerset.SetNameLabelKey here? #385

Open
Monsterlin2018 opened this issue Feb 14, 2025 · 3 comments · May be fixed by #394
Open

Is it inappropriate to mark leaderworkerset.SetNameLabelKey here? #385

Monsterlin2018 opened this issue Feb 14, 2025 · 3 comments · May be fixed by #394
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Monsterlin2018
Copy link

Monsterlin2018 commented Feb 14, 2025

I think there are incorrect labels, which cause the worker nodes to continuously increase until the names of the pods exceed the limit.

v0.5.1
1、pkg\controllers\pod_controller.go

283 func constructWorkerStatefulSetApplyConfiguration
...
**306 		leaderworkerset.SetNameLabelKey:         lws.Name,**

As a result, the label "leaderworkerset.sigs.k8s.io/name" is added to the worker pods.

2、 pkg\webhooks\pod_webhook.go

82  func (p *PodWebhook) Default
...
90 	// if pod is not part of leaderworkerset, skip
91	_, found := pod.Labels[leaderworkerset.SetNameLabelKey]
92	if !found {
93		return nil
94	}
...
140  _, workerIndex := statefulsetutils.GetParentNameAndOrdinal(pod.Name)  ##--> workerIndex =0
...
**144 pod.Labels[leaderworkerset.WorkerIndexLabelKey] = fmt.Sprint(workerIndex)**

Then, a label "leaderworkerset.sigs.k8s.io/worker-index: '0'" is added to the worker pods, making them the leader pods.

3、pkg\controllers\pod_controller.go

66   func (r *PodReconciler) Reconcile
...
96 	// worker pods' reconciliation is only done to handle restart policy
97	if !podutils.LeaderPod(pod) {
98		return ctrl.Result{}, nil
99	}

Here, the process won't be skipped. Instead, new worker pods will continue to be created, and the process goes back to step 1.


I'm not sure if my understanding is correct.
If my understanding is incorrect, please ignore it.

@Monsterlin2018 Monsterlin2018 added the kind/bug Categorizes issue or PR as related to a bug. label Feb 14, 2025
@Monsterlin2018 Monsterlin2018 changed the title 这里是不是不应该标记 leaderworkerset.SetNameLabelKey Is it inappropriate to mark leaderworkerset.SetNameLabelKey here? Feb 14, 2025
@Edwinhr716
Copy link
Contributor

Then, a label "leaderworkerset.sigs.k8s.io/worker-index: '0'" is added to the worker pods, making them the leader pods

Why would the worker-index be zero here? WorkerIndex is taken from this function, where the pod.Name is <lws-name>-<replica>-<workerIndex>.

_, workerIndex := statefulsetutils.GetParentNameAndOrdinal(pod.Name)

And workerIndex starts from 1, so workerIndex will never be zero.

WithOrdinals(appsapplyv1.StatefulSetOrdinals().WithStart(1)).

@yankay
Copy link
Member

yankay commented Feb 17, 2025

It seems the same as #391

@yankay
Copy link
Member

yankay commented Feb 17, 2025

HI @Monsterlin2018
Update the Kubernetes to >1.27 may solve the issue :-) ref to https://github.com/kubernetes-sigs/lws/blob/main/docs/setup/install.md#before-you-begin
Because the statefulset ordinals feature is supported after Kubernetes 1.27 as detailed here: https://kubernetes.io/blog/2023/04/28/statefulset-start-ordinal/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants