Browse code

plugin: replace uses of errdefs package

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Matthieu MOREL authored on 2025/05/28 14:40:55
Showing 1 changed files
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	containerd "github.com/containerd/containerd/v2/client"
11 11
 	"github.com/containerd/containerd/v2/pkg/cio"
12
+	cerrdefs "github.com/containerd/errdefs"
12 13
 	"github.com/containerd/log"
13 14
 	"github.com/docker/docker/errdefs"
14 15
 	"github.com/docker/docker/libcontainerd"
... ...
@@ -61,12 +62,12 @@ type c8dPlugin struct {
61 61
 // deleteTaskAndContainer deletes plugin task and then plugin container from containerd
62 62
 func (p c8dPlugin) deleteTaskAndContainer(ctx context.Context) {
63 63
 	if p.tsk != nil {
64
-		if err := p.tsk.ForceDelete(ctx); err != nil && !errdefs.IsNotFound(err) {
64
+		if err := p.tsk.ForceDelete(ctx); err != nil && !cerrdefs.IsNotFound(err) {
65 65
 			p.log.WithError(err).Error("failed to delete plugin task from containerd")
66 66
 		}
67 67
 	}
68 68
 	if p.ctr != nil {
69
-		if err := p.ctr.Delete(ctx); err != nil && !errdefs.IsNotFound(err) {
69
+		if err := p.ctr.Delete(ctx); err != nil && !cerrdefs.IsNotFound(err) {
70 70
 			p.log.WithError(err).Error("failed to delete plugin container from containerd")
71 71
 		}
72 72
 	}
... ...
@@ -102,14 +103,14 @@ func (e *Executor) Restore(id string, stdout, stderr io.WriteCloser) (bool, erro
102 102
 	p := c8dPlugin{log: log.G(ctx).WithField("plugin", id)}
103 103
 	ctr, err := e.client.LoadContainer(ctx, id)
104 104
 	if err != nil {
105
-		if errdefs.IsNotFound(err) {
105
+		if cerrdefs.IsNotFound(err) {
106 106
 			return false, nil
107 107
 		}
108 108
 		return false, err
109 109
 	}
110 110
 	p.tsk, err = ctr.AttachTask(ctx, attachStreamsFunc(stdout, stderr))
111 111
 	if err != nil {
112
-		if errdefs.IsNotFound(err) {
112
+		if cerrdefs.IsNotFound(err) {
113 113
 			p.deleteTaskAndContainer(ctx)
114 114
 			return false, nil
115 115
 		}
... ...
@@ -117,7 +118,7 @@ func (e *Executor) Restore(id string, stdout, stderr io.WriteCloser) (bool, erro
117 117
 	}
118 118
 	s, err := p.tsk.Status(ctx)
119 119
 	if err != nil {
120
-		if errdefs.IsNotFound(err) {
120
+		if cerrdefs.IsNotFound(err) {
121 121
 			// Task vanished after attaching?
122 122
 			p.tsk = nil
123 123
 			p.deleteTaskAndContainer(ctx)