Skip to content

Commit 02f0a8b

Browse files
committed
pkg/cri/server: nuke old v0.1.0 NRI hooks.
Remove direct invocation of old v0.1.0 NRI plugins. They can be enabled using the revised NRI API and the v0.1.0 adapter plugin. Signed-off-by: Krisztian Litkey <[email protected]>
1 parent ca84aba commit 02f0a8b

File tree

4 files changed

+4
-86
lines changed

4 files changed

+4
-86
lines changed

pkg/cri/server/container_start.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
containerdio "github.com/containerd/containerd/cio"
2828
"github.com/containerd/containerd/errdefs"
2929
"github.com/containerd/containerd/log"
30-
"github.com/containerd/nri"
31-
v1 "github.com/containerd/nri/types/v1"
3230
"github.com/sirupsen/logrus"
3331
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
3432

@@ -135,7 +133,7 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain
135133
deferCtx, deferCancel := ctrdutil.DeferContext()
136134
defer deferCancel()
137135
// It's possible that task is deleted by event monitor.
138-
if _, err := task.Delete(deferCtx, WithNRISandboxDelete(sandboxID), containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
136+
if _, err := task.Delete(deferCtx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
139137
log.G(ctx).WithError(err).Errorf("Failed to delete containerd task %q", id)
140138
}
141139
}
@@ -146,19 +144,6 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain
146144
if err != nil {
147145
return nil, fmt.Errorf("failed to wait for containerd task: %w", err)
148146
}
149-
nric, err := nri.New()
150-
if err != nil {
151-
log.G(ctx).WithError(err).Error("unable to create nri client")
152-
}
153-
if nric != nil {
154-
nriSB := &nri.Sandbox{
155-
ID: sandboxID,
156-
Labels: sandbox.Config.Labels,
157-
}
158-
if _, err := nric.InvokeWithSandbox(ctx, task, v1.Create, nriSB); err != nil {
159-
return nil, fmt.Errorf("nri invoke: %w", err)
160-
}
161-
}
162147

163148
defer func() {
164149
if retErr != nil {

pkg/cri/server/events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
384384
}
385385
} else {
386386
// TODO(random-liu): [P1] This may block the loop, we may want to spawn a worker
387-
if _, err = task.Delete(ctx, WithNRISandboxDelete(cntr.SandboxID), c.nri.WithContainerExit(&cntr), containerd.WithProcessKill); err != nil {
387+
if _, err = task.Delete(ctx, c.nri.WithContainerExit(&cntr), containerd.WithProcessKill); err != nil {
388388
if !errdefs.IsNotFound(err) {
389389
return fmt.Errorf("failed to stop container: %w", err)
390390
}
@@ -424,7 +424,7 @@ func handleSandboxExit(ctx context.Context, e *eventtypes.TaskExit, sb sandboxst
424424
}
425425
} else {
426426
// TODO(random-liu): [P1] This may block the loop, we may want to spawn a worker
427-
if _, err = task.Delete(ctx, WithNRISandboxDelete(sb.ID), containerd.WithProcessKill); err != nil {
427+
if _, err = task.Delete(ctx, containerd.WithProcessKill); err != nil {
428428
if !errdefs.IsNotFound(err) {
429429
return fmt.Errorf("failed to stop sandbox: %w", err)
430430
}

pkg/cri/server/opts.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/cri/server/sandbox_run.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828
"time"
2929

3030
cni "github.com/containerd/go-cni"
31-
"github.com/containerd/nri"
32-
v1 "github.com/containerd/nri/types/v1"
3331
"github.com/containerd/typeurl"
3432
"github.com/davecgh/go-spew/spew"
3533
selinux "github.com/opencontainers/selinux/go-selinux"
@@ -346,7 +344,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
346344
deferCtx, deferCancel := ctrdutil.DeferContext()
347345
defer deferCancel()
348346
// Cleanup the sandbox container if an error is returned.
349-
if _, err := task.Delete(deferCtx, WithNRISandboxDelete(id), containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
347+
if _, err := task.Delete(deferCtx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
350348
log.G(ctx).WithError(err).Errorf("Failed to delete sandbox container %q", id)
351349
cleanupErr = err
352350
}
@@ -359,20 +357,6 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
359357
return nil, fmt.Errorf("failed to wait for sandbox container task: %w", err)
360358
}
361359

362-
nric, err := nri.New()
363-
if err != nil {
364-
return nil, fmt.Errorf("unable to create nri client: %w", err)
365-
}
366-
if nric != nil {
367-
nriSB := &nri.Sandbox{
368-
ID: id,
369-
Labels: config.Labels,
370-
}
371-
if _, err := nric.InvokeWithSandbox(ctx, task, v1.Create, nriSB); err != nil {
372-
return nil, fmt.Errorf("nri invoke: %w", err)
373-
}
374-
}
375-
376360
if c.nri.isEnabled() {
377361
err = c.nri.runPodSandbox(ctx, &sandbox)
378362
if err != nil {

0 commit comments

Comments
 (0)