Skip to content

Commit 6bccd67

Browse files
committed
Revert shim plugin migration
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
1 parent 2190192 commit 6bccd67

File tree

7 files changed

+7
-70
lines changed

7 files changed

+7
-70
lines changed

integration/client/container_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ func getLogDirPath(runtimeVersion, id string) string {
430430
case "v1":
431431
return filepath.Join(defaultRoot, plugin.RuntimeLinuxV1, testNamespace, id)
432432
case "v2":
433-
return filepath.Join(defaultState, "io.containerd.runtime-shim.v2.shim", testNamespace, id)
433+
return filepath.Join(defaultState, "io.containerd.runtime.v2.task", testNamespace, id)
434434
default:
435435
panic(fmt.Errorf("Unsupported runtime version %s", runtimeVersion))
436436
}

plugin/plugin.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ const (
5757
RuntimePlugin Type = "io.containerd.runtime.v1"
5858
// RuntimePluginV2 implements a runtime v2
5959
RuntimePluginV2 Type = "io.containerd.runtime.v2"
60-
// RuntimeShimPlugin implements the shim manager for runtime v2.
61-
RuntimeShimPlugin Type = "io.containerd.runtime-shim.v2"
6260
// ServicePlugin implements a internal service
6361
ServicePlugin Type = "io.containerd.service.v1"
6462
// GRPCPlugin implements a grpc service

runtime/v2/manager.go

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ type Config struct {
5050

5151
func init() {
5252
plugin.Register(&plugin.Registration{
53-
Type: plugin.RuntimeShimPlugin,
54-
ID: "shim",
53+
Type: plugin.RuntimePluginV2,
54+
ID: "task",
5555
Requires: []plugin.Type{
5656
plugin.EventPlugin,
5757
plugin.MetadataPlugin,
@@ -79,7 +79,7 @@ func init() {
7979
cs := metadata.NewContainerStore(m.(*metadata.DB))
8080
events := ep.(*exchange.Exchange)
8181

82-
return NewShimManager(ic.Context, &ManagerConfig{
82+
shimManager, err := NewShimManager(ic.Context, &ManagerConfig{
8383
Root: ic.Root,
8484
State: ic.State,
8585
Address: ic.Address,
@@ -88,72 +88,15 @@ func init() {
8888
Store: cs,
8989
SchedCore: config.SchedCore,
9090
})
91-
},
92-
})
93-
94-
plugin.Register(&plugin.Registration{
95-
Type: plugin.RuntimePluginV2,
96-
ID: "task",
97-
Requires: []plugin.Type{
98-
plugin.RuntimeShimPlugin,
99-
},
100-
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
101-
shimManagerInterface, err := ic.Get(plugin.RuntimeShimPlugin)
10291
if err != nil {
10392
return nil, err
10493
}
10594

106-
shimManager := shimManagerInterface.(*ShimManager)
107-
108-
// From now on task manager works via shim manager, which has different home directory.
109-
// Check if there are any leftovers from previous containerd versions and migrate home directory,
110-
// so we can properly restore existing tasks as well.
111-
if err := migrateTasks(ic, shimManager); err != nil {
112-
log.G(ic.Context).WithError(err).Error("unable to migrate tasks")
113-
}
114-
11595
return NewTaskManager(shimManager), nil
11696
},
11797
})
11898
}
11999

120-
func migrateTasks(ic *plugin.InitContext, shimManager *ShimManager) error {
121-
if !shimManager.shims.IsEmpty() {
122-
return nil
123-
}
124-
125-
// Rename below will fail is target directory exists.
126-
// `Root` and `State` dirs expected to be empty at this point (we check that there are no shims loaded above).
127-
// If for some they are not empty, these remove calls will fail (`os.Remove` requires a dir to be empty to succeed).
128-
if err := os.Remove(shimManager.root); err != nil && !os.IsNotExist(err) {
129-
return fmt.Errorf("failed to remove `root` dir: %w", err)
130-
}
131-
132-
if err := os.Remove(shimManager.state); err != nil && !os.IsNotExist(err) {
133-
return fmt.Errorf("failed to remove `state` dir: %w", err)
134-
}
135-
136-
if err := os.Rename(ic.Root, shimManager.root); err != nil {
137-
if os.IsNotExist(err) {
138-
return nil
139-
}
140-
return fmt.Errorf("failed to migrate task `root` directory: %w", err)
141-
}
142-
143-
if err := os.Rename(ic.State, shimManager.state); err != nil {
144-
if os.IsNotExist(err) {
145-
return nil
146-
}
147-
return fmt.Errorf("failed to migrate task `state` directory: %w", err)
148-
}
149-
150-
if err := shimManager.loadExistingTasks(ic.Context); err != nil {
151-
return fmt.Errorf("failed to load tasks after migration: %w", err)
152-
}
153-
154-
return nil
155-
}
156-
157100
type ManagerConfig struct {
158101
Root string
159102
State string
@@ -209,7 +152,7 @@ type ShimManager struct {
209152

210153
// ID of the shim manager
211154
func (m *ShimManager) ID() string {
212-
return fmt.Sprintf("%s.%s", plugin.RuntimeShimPlugin, "shim")
155+
return fmt.Sprintf("%s.%s", plugin.RuntimePluginV2, "shim")
213156
}
214157

215158
// Start launches a new shim instance

services/tasks/local.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
"github.com/containerd/containerd/plugin"
4444
"github.com/containerd/containerd/runtime"
4545
"github.com/containerd/containerd/runtime/linux/runctypes"
46-
v2 "github.com/containerd/containerd/runtime/v2"
4746
"github.com/containerd/containerd/runtime/v2/runc/options"
4847
"github.com/containerd/containerd/services"
4948
"github.com/containerd/typeurl"
@@ -111,7 +110,7 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
111110
store: db.ContentStore(),
112111
publisher: ep.(events.Publisher),
113112
monitor: monitor.(runtime.TaskMonitor),
114-
v2Runtime: v2r.(*v2.TaskManager),
113+
v2Runtime: v2r.(runtime.PlatformRuntime),
115114
}
116115
for _, r := range runtimes {
117116
tasks, err := r.Tasks(ic.Context, true)
@@ -139,7 +138,7 @@ type local struct {
139138
publisher events.Publisher
140139

141140
monitor runtime.TaskMonitor
142-
v2Runtime *v2.TaskManager
141+
v2Runtime runtime.PlatformRuntime
143142
}
144143

145144
func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.CallOption) (*api.CreateTaskResponse, error) {

services/tasks/local_freebsd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
var tasksServiceRequires = []plugin.Type{
2525
plugin.EventPlugin,
2626
plugin.RuntimePluginV2,
27-
plugin.RuntimeShimPlugin,
2827
plugin.MetadataPlugin,
2928
plugin.TaskMonitorPlugin,
3029
}

services/tasks/local_unix.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var tasksServiceRequires = []plugin.Type{
3030
plugin.EventPlugin,
3131
plugin.RuntimePlugin,
3232
plugin.RuntimePluginV2,
33-
plugin.RuntimeShimPlugin,
3433
plugin.MetadataPlugin,
3534
plugin.TaskMonitorPlugin,
3635
}

services/tasks/local_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
var tasksServiceRequires = []plugin.Type{
2525
plugin.EventPlugin,
2626
plugin.RuntimePluginV2,
27-
plugin.RuntimeShimPlugin,
2827
plugin.MetadataPlugin,
2928
plugin.TaskMonitorPlugin,
3029
}

0 commit comments

Comments
 (0)