MCPcopy Create free account
hub / github.com/containerd/containerd / init

Function init

core/runtime/v2/task_manager.go:62–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62func init() {
63 registry.Register(&plugin.Registration{
64 Type: plugins.RuntimePluginV2,
65 ID: "task",
66 Requires: []plugin.Type{
67 plugins.ShimPlugin,
68 plugins.MountManagerPlugin,
69 plugins.WarningPlugin,
70 },
71 Config: &TaskConfig{
72 Platforms: defaultPlatforms(),
73 },
74 InitFn: func(ic *plugin.InitContext) (any, error) {
75 config := ic.Config.(*TaskConfig)
76
77 supportedPlatforms, err := platforms.ParseAll(config.Platforms)
78 if err != nil {
79 return nil, err
80 }
81 ic.Meta.Platforms = supportedPlatforms
82 if ic.Meta.Exports == nil {
83 ic.Meta.Exports = make(map[string]string, 1)
84 }
85 ic.Meta.Exports["log-uri-schemes"] = strings.Join(supportedLogURISchemes(), ",")
86
87 shimManagerI, err := ic.GetSingle(plugins.ShimPlugin)
88 if err != nil {
89 return nil, err
90 }
91 shimManager := shimManagerI.(*ShimManager)
92
93 var mounts mount.Manager
94 if mountsI, err := ic.GetSingle(plugins.MountManagerPlugin); err == nil {
95 mounts = mountsI.(mount.Manager)
96 } else if !errors.Is(err, plugin.ErrPluginNotFound) {
97 return nil, err
98 }
99 root, state := ic.Properties[plugins.PropertyRootDir], ic.Properties[plugins.PropertyStateDir]
100 for _, d := range []string{root, state} {
101 // root: the parent of this directory is created as 0o700, not 0o711.
102 // state: the parent of this directory is created as 0o711 too, so as to support userns-remapped containers.
103 if err := os.MkdirAll(d, 0711); err != nil {
104 return nil, err
105 }
106 }
107
108 if err := shimManager.LoadExistingShims(ic.Context, state, root); err != nil {
109 return nil, fmt.Errorf("failed to load existing shims for task manager")
110 }
111
112 warningsI, err := ic.GetSingle(plugins.WarningPlugin)
113 if err != nil {
114 return nil, err
115 }
116 warnings := warningsI.(warning.Service)
117 emitPlatformWarnings(ic.Context, warnings)
118
119 return &TaskManager{

Callers

nothing calls this directly

Calls 6

supportedLogURISchemesFunction · 0.85
LoadExistingShimsMethod · 0.80
defaultPlatformsFunction · 0.70
emitPlatformWarningsFunction · 0.70
RegisterMethod · 0.65
MkdirAllMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…