Fix backward compatibility with old task shims
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -48,7 +48,7 @@ type Config struct {
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.RuntimePluginV2,
|
||||
Type: plugin.RuntimeShimPlugin,
|
||||
ID: "shim",
|
||||
Requires: []plugin.Type{
|
||||
plugin.EventPlugin,
|
||||
@@ -65,12 +65,7 @@ func init() {
|
||||
}
|
||||
|
||||
ic.Meta.Platforms = supportedPlatforms
|
||||
if err := os.MkdirAll(ic.Root, 0711); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.MkdirAll(ic.State, 0711); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m, err := ic.Get(plugin.MetadataPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -95,18 +90,47 @@ func init() {
|
||||
})
|
||||
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.RuntimePluginV2Service,
|
||||
Type: plugin.RuntimePluginV2,
|
||||
ID: "task",
|
||||
Requires: []plugin.Type{
|
||||
plugin.RuntimePluginV2,
|
||||
plugin.RuntimeShimPlugin,
|
||||
},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
shimInstance, err := ic.GetByID(plugin.RuntimePluginV2, "shim")
|
||||
m, err := ic.Get(plugin.MetadataPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ep, err := ic.GetByID(plugin.EventPlugin, "exchange")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs := metadata.NewContainerStore(m.(*metadata.DB))
|
||||
events := ep.(*exchange.Exchange)
|
||||
|
||||
shimManager, err := NewShimManager(ic.Context, &ManagerConfig{
|
||||
Root: ic.Root,
|
||||
State: ic.State,
|
||||
Address: ic.Address,
|
||||
TTRPCAddress: ic.TTRPCAddress,
|
||||
Events: events,
|
||||
Store: cs,
|
||||
SchedCore: false,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
shimManager := shimInstance.(*ShimManager)
|
||||
// Internally task manager relies on shim manager to launch task shims.
|
||||
// It's also possible to use shim manager independently and launch other types of shims.
|
||||
//
|
||||
// Ideally task manager should depend on shim instance we registered above, however it'll use
|
||||
// different home directory (`io.containerd.runtime.v2.task` vs `io.containerd.runtime.v2.shim`),
|
||||
// which will break backward compatibility when upgrading containerd to the new version.
|
||||
//
|
||||
// For now, we create another instance of shim manager with the "old" home directory, so shim tasks
|
||||
// are properly restored, but will work independently.
|
||||
//
|
||||
// See more context https://github.com/containerd/containerd/pull/5918#discussion_r705434412
|
||||
return NewTaskManager(shimManager), nil
|
||||
},
|
||||
})
|
||||
@@ -420,7 +444,7 @@ func NewTaskManager(shims *ShimManager) *TaskManager {
|
||||
|
||||
// ID of the task manager
|
||||
func (m *TaskManager) ID() string {
|
||||
return fmt.Sprintf("%s.%s", plugin.RuntimePluginV2Service, "task")
|
||||
return fmt.Sprintf("%s.%s", plugin.RuntimeShimPlugin, "task")
|
||||
}
|
||||
|
||||
// Create launches new shim instance and creates new task
|
||||
|
||||
Reference in New Issue
Block a user