-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
EventedPLEG: Update global cache timestamp more frequently #127954
Conversation
Hi @hshiina. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
pkg/kubelet/pleg/evented.go
Outdated
@@ -150,6 +152,13 @@ func (e *EventedPLEG) Stop() { | |||
// called periodically to update the global timestamp of the cache so that those | |||
// pods stuck at GetNewerThan in pod workers will get unstuck. | |||
func (e *EventedPLEG) updateGlobalCache() { | |||
// Confirm that there is no communication problem with the runtime. | |||
if _, err := e.runtimeService.Version(context.TODO(), ""); err != nil { | |||
e.logger.Error(err, "Evented PLEG: failed to communicate with the runtime before updaing the global cache") |
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.
e.logger.Error(err, "Evented PLEG: failed to communicate with the runtime before updaing the global cache") | |
e.logger.Error(err, "Evented PLEG: failed to communicate with the runtime before updating the global cache") |
/ok-to-test |
This fix makes the period to update the global cache timestamp for Evented PLEG shorter in order to unblock pod workers that get stuck in `cache.GetNewerThan()` as fast as Generic PLEG. Before updating the global timestamp, this fix calls Version() CRI API in order to confirm there is no problem with communicating with the runtime. By this, we can assume pods that have not been receiving events are in the latest status.
bbb5c2a
to
13edfa4
Compare
/retest |
/test pull-kubernetes-node-crio-cgrpv1-evented-pleg-e2e |
/triage accepted |
/test pull-kubernetes-node-crio-cgrpv1-evented-pleg-e2e |
LGTM label has been added. Git tree hash: a2247d8552a30a39c85d06c962174ee7675cbe71
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hshiina, pacoxu 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 |
/test pull-kubernetes-node-crio-cgrpv1-evented-pleg-e2e-kubetest2 |
/lgtm |
const globalCacheUpdatePeriod = 5 * time.Second | ||
// This is the same values as the relist period of Generic PLEG | ||
// in order to unblock pod workers as frequent as Generic PLEG. | ||
const globalCacheUpdatePeriod = 1 * time.Second |
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.
If Evented PLEG also relists every 1 second then it is as good as just having Generic PLEG right?
kubernetes/pkg/kubelet/kubelet.go
Line 193 in a499fac
genericPlegRelistPeriod = time.Second * 1 |
What is the advantage of using Evented PLEG in that case?
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.
With this change, Evented PLEG just updates the global timestamp every one second while Generic PLEG goes through all containers to see if their states are changed. I think Evented PLEG is still lighter than Generic PLEG.
I think the fix proposed in this PR is not addressing the root cause of the issue. The problem arises after introducing the evented PLEG, where the To verify this, I injected some debugging logs into diff --git a/pkg/kubelet/pod_workers.go b/pkg/kubelet/pod_workers.go
index 30850d830f6..40351e7f83d 100644
--- a/pkg/kubelet/pod_workers.go
+++ b/pkg/kubelet/pod_workers.go
@@ -1253,7 +1253,9 @@ func (p *podWorkers) podWorkerLoop(podUID types.UID, podUpdates <-chan struct{})
// Improving this latency also reduces the possibility that a terminated
// container's status is garbage collected before we have a chance to update the
// API server (thus losing the exit code).
+ klog.Info("---------debug-------: waiting new event")
status, err = p.podCache.GetNewerThan(update.Options.Pod.UID, lastSyncTime)
+ klog.Info("---------debug-------: sync begining")
if err != nil {
// This is the legacy event thrown by manage pod loop all other events are now dispatched
@@ -1267,6 +1269,7 @@ func (p *podWorkers) podWorkerLoop(podUID types.UID, podUpdates <-chan struct{})
switch {
case update.WorkType == TerminatedPod:
err = p.podSyncer.SyncTerminatedPod(ctx, update.Options.Pod, status)
+ klog.Info("---------debug-------: sync terminated pod end")
case update.WorkType == TerminatingPod:
var gracePeriod *int64
@@ -1281,9 +1284,11 @@ func (p *podWorkers) podWorkerLoop(podUID types.UID, podUpdates <-chan struct{})
} else {
err = p.podSyncer.SyncTerminatingPod(ctx, update.Options.Pod, status, gracePeriod, podStatusFn)
}
+ klog.Info("---------debug-------: sync terminating pod end")
default:
isTerminal, err = p.podSyncer.SyncPod(ctx, update.Options.UpdateType, update.Options.Pod, update.Options.MirrorPod, status)
+ klog.Info("---------debug-------: default sync end")
}
lastSyncTime = p.clock.Now()
---
diff --git a/pkg/kubelet/pleg/evented.go b/pkg/kubelet/pleg/evented.go
index 39e13b55223..b8c867b69be 100644
--- a/pkg/kubelet/pleg/evented.go
+++ b/pkg/kubelet/pleg/evented.go
@@ -285,6 +285,7 @@ func (e *EventedPLEG) processCRIEvent(event *runtimeapi.ContainerEventResponse)
switch event.ContainerEventType {
case runtimeapi.ContainerEventType_CONTAINER_STOPPED_EVENT:
e.sendPodLifecycleEvent(&PodLifecycleEvent{ID: types.UID(event.PodSandboxStatus.Metadata.Uid), Type: ContainerDied, Data: event.ContainerId})
+ klog.Infof("---------debug-------: container event type: %s", ContainerDied)
e.logger.V(4).Info("Received Container Stopped Event", "event", event.String())
case runtimeapi.ContainerEventType_CONTAINER_CREATED_EVENT:
// We only need to update the pod status on container create.
@@ -294,11 +295,14 @@ func (e *EventedPLEG) processCRIEvent(event *runtimeapi.ContainerEventResponse)
// https://github.com/kubernetes/kubernetes/blob/24753aa8a4df8d10bfd6330e0f29186000c018be/pkg/kubelet/pleg/generic.go#L273
e.logger.V(4).Info("Received Container Created Event", "event", event.String())
case runtimeapi.ContainerEventType_CONTAINER_STARTED_EVENT:
+ klog.Infof("---------debug-------: container event type: %s", ContainerStarted)
e.sendPodLifecycleEvent(&PodLifecycleEvent{ID: types.UID(event.PodSandboxStatus.Metadata.Uid), Type: ContainerStarted, Data: event.ContainerId})
e.logger.V(4).Info("Received Container Started Event", "event", event.String())
case runtimeapi.ContainerEventType_CONTAINER_DELETED_EVENT:
// In case the pod is deleted it is safe to generate both ContainerDied and ContainerRemoved events, just like in the case of
// Generic PLEG. https://github.com/kubernetes/kubernetes/blob/24753aa8a4df8d10bfd6330e0f29186000c018be/pkg/kubelet/pleg/generic.go#L169
+ klog.Infof("---------debug-------: container event type: %s", ContainerDied)
+ klog.Infof("---------debug-------: container event type: %s", ContainerRemoved)
e.sendPodLifecycleEvent(&PodLifecycleEvent{ID: types.UID(event.PodSandboxStatus.Metadata.Uid), Type: ContainerDied, Data: event.ContainerId})
e.sendPodLifecycleEvent(&PodLifecycleEvent{ID: types.UID(event.PodSandboxStatus.Metadata.Uid), Type: ContainerRemoved, Data: event.ContainerId})
e.logger.V(4).Info("Received Container Deleted Event", "event", event)
The resulting logs show:
From the logs, it is evident that PLEG updates container events while Although the current PR mitigates the issue by allowing If I am mistaken, please let me know. |
As being pointed out, this PR is not a fundamental fix. Ideally, I think we should solve these TODOs: kubernetes/pkg/kubelet/kubelet.go Lines 2100 to 2101 in cb93d6e
kubernetes/pkg/kubelet/pod_workers.go Lines 1249 to 1252 in cb93d6e
|
EventedPLEG is currently an alpha feature, which means it has been operating in an incorrect manner. What we may need is not a temporary fix but ensuring it functions as expected before it progresses to the beta stage. If possible, we should also consider revising the content of the KEP retrospectively. |
Agree. And can we merge this first as this is a safe improvement on Evented PLEG?
|
/test pull-kubernetes-e2e-kind-evented-pleg |
/test pull-kubernetes-node-crio-cgrpv1-evented-pleg-e2e |
@hshiina: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/close |
@hshiina: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This fix makes the period to update the global cache timestamp for Evented PLEG shorter in order to unblock pod workers that get stuck in
cache.GetNewerThan()
as fast as Generic PLEG. Before updating the global timestamp, this fix calls Version() CRI API in order to confirm there is no problem with communicating with the runtime. By this, we can assume pods that have not been receiving events are in the latest status.In order to verify this PR, run
pull-kubernetes-node-crio-cgrpv1-evented-pleg-e2e
and confirm the following failures don't appear:Which issue(s) this PR fixes:
Fixes #124704, Fixes #127312
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: