Skip to content

Commit 246240f

Browse files
committed
Move PLEG event back to CRI
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent 16f3726 commit 246240f

4 files changed

Lines changed: 3 additions & 17 deletions

File tree

pkg/cri/sbserver/podsandbox/controller.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ type CRIService interface {
4545

4646
// TODO: we should implement Event backoff in Controller.
4747
BackOffEvent(id string, event interface{})
48-
49-
// TODO: refactor event generator for PLEG.
50-
// GenerateAndSendContainerEvent is called by controller for sandbox container events.
51-
GenerateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType)
5248
}
5349

5450
type Controller struct {

pkg/cri/sbserver/podsandbox/sandbox_delete.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
"context"
2121
"fmt"
2222

23-
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
24-
2523
"github.com/containerd/containerd"
2624
"github.com/containerd/containerd/errdefs"
2725
"github.com/containerd/containerd/log"
@@ -59,10 +57,5 @@ func (c *Controller) Shutdown(ctx context.Context, sandboxID string) error {
5957
}
6058
}
6159

62-
// Send CONTAINER_DELETED event with ContainerId equal to SandboxId.
63-
c.cri.GenerateAndSendContainerEvent(ctx, sandboxID, sandboxID, runtime.ContainerEventType_CONTAINER_DELETED_EVENT)
64-
65-
c.sandboxStore.Delete(sandboxID)
66-
6760
return nil
6861
}

pkg/cri/sbserver/sandbox_remove.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
9090
return nil, fmt.Errorf("failed to delete sandbox %q: %w", id, err)
9191
}
9292

93+
// Send CONTAINER_DELETED event with ContainerId equal to SandboxId.
94+
c.generateAndSendContainerEvent(ctx, id, id, runtime.ContainerEventType_CONTAINER_DELETED_EVENT)
95+
9396
err = c.nri.RemovePodSandbox(ctx, &sandbox)
9497
if err != nil {
9598
log.G(ctx).WithError(err).Errorf("NRI pod removal notification failed")

pkg/cri/sbserver/service.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,6 @@ func (c *criService) BackOffEvent(id string, event interface{}) {
205205
c.eventMonitor.backOff.enBackOff(id, event)
206206
}
207207

208-
// GenerateAndSendContainerEvent is a temporary workaround to send PLEG events from podsandbopx/ controller
209-
// TODO: refactor PLEG event generator so both podsandbox/ controller and CRI service can access it.
210-
func (c *criService) GenerateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType) {
211-
c.generateAndSendContainerEvent(ctx, containerID, sandboxID, eventType)
212-
}
213-
214208
// Register registers all required services onto a specific grpc server.
215209
// This is used by containerd cri plugin.
216210
func (c *criService) Register(s *grpc.Server) error {

0 commit comments

Comments
 (0)