-
Notifications
You must be signed in to change notification settings - Fork 1
Change the formula cat-gate uses to schedule pods #20
Conversation
zeroalphat
commented
May 15, 2024
•
edited
Loading
edited
- Change the formula cat-gate uses to schedule pods
- Change 'Number of nodes with pods on which the container status is Running or Terminated' to 'Use the number of nodes with container images'.
- Modify the implementation to avoid requeueing when the scheduling gate is successfully removed.
- Add a process to prevent removing the scheduling gate for other Pods immediately after removing the scheduling gate, in order to prevent race conditions.
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
014080b
to
f4d12f8
Compare
pods := &corev1.PodList{} | ||
err = r.List(ctx, pods, client.MatchingFields{constants.ImageHashAnnotationField: reqImagesHash}) | ||
if err != nil { | ||
logger.Error(err, "failed to list pods") | ||
return ctrl.Result{}, err | ||
} | ||
|
||
nodeSet := make(map[string]struct{}) | ||
|
||
numSchedulablePods := 0 | ||
numImagePulledPods := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the calculation method of numImagePullingPods
.
I think we need to count the pods with the following conditions.
(no cat-gate.cybozu.io/gate
scheduling gate) AND (pod.status.phase
==Pending) AND (pod.spec.nodeName
is not contained in nodeSet
)
IMO, we need not check the status of individual containers. The pod phase is sufficient for our usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@masa213f
I agree that it is better to use Pod phase.
I didn't really understand why you included whether nodeset
is included in the counting method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I changed my mind. We do not need to care about "nodeSet".
I thought pods scheduled to "nodeSet" nodes would not pull images from upstream repositories.
But if the "imagePullPolicy" is "Always", the kubelets may pull the new images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change the conditional expression of numImagePullingPods with f3455c6.
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
Co-authored-by: Masayuki Ishii <masa.ishii.1019@gmail.com>
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM