Add container monitor plugin type for restart
Adds a plugin type for container monitor. Rename the task monitor type to avoid confusion. Add config migration for new plugin types to pass existing migration tests. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/containerd/containerd/v2/internal/tomlext"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"github.com/containerd/containerd/v2/plugins"
|
||||
"github.com/containerd/containerd/v2/version"
|
||||
"github.com/containerd/log"
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
@@ -41,7 +42,7 @@ type Config struct {
|
||||
|
||||
func init() {
|
||||
registry.Register(&plugin.Registration{
|
||||
Type: plugins.InternalPlugin,
|
||||
Type: plugins.ContainerMonitorPlugin,
|
||||
Requires: []plugin.Type{
|
||||
plugins.EventPlugin,
|
||||
plugins.ServicePlugin,
|
||||
@@ -62,6 +63,19 @@ func init() {
|
||||
go m.run(tomlext.ToStdTime(ic.Config.(*Config).Interval))
|
||||
return m, nil
|
||||
},
|
||||
ConfigMigration: func(ctx context.Context, configVersion int, pluginConfigs map[string]interface{}) error {
|
||||
if configVersion >= version.ConfigVersion {
|
||||
return nil
|
||||
}
|
||||
const pluginName = string(plugins.InternalPlugin) + ".restart"
|
||||
c, ok := pluginConfigs[pluginName]
|
||||
if ok {
|
||||
pluginConfigs[string(plugins.ContainerMonitorPlugin)+".restart"] = c
|
||||
delete(pluginConfigs, pluginName)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user