Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/1.7] tasks: emit warning for v1 runtime and runc v1 runtime #9450

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/deprecation/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
CRIAPIV1Alpha2 Warning = Prefix + "cri-api-v1alpha2"
// AUFSSnapshotter is a warning for the use of the aufs snapshotter
AUFSSnapshotter Warning = Prefix + "aufs-snapshotter"
// RuntimeV1 is a warning for the io.containerd.runtime.v1.linux runtime
RuntimeV1 Warning = Prefix + "runtime-v1"
// RuntimeRuncV1 is a warning for the io.containerd.runc.v1 runtime
RuntimeRuncV1 Warning = Prefix + "runtime-runc-v1"
)

var messages = map[Warning]string{
Expand All @@ -49,6 +53,8 @@ var messages = map[Warning]string{
"Use `config_path` instead.",
CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.",
AUFSSnapshotter: "The aufs snapshotter is deprecated since containerd v1.5 and removed in containerd v2.0. Use the overlay snapshotter instead.",
RuntimeV1: "The `io.containerd.runtime.v1.linux` runtime is deprecated since containerd v1.4 and removed in containerd v2.0. Use the `io.containerd.runc.v2` runtime instead.",
RuntimeRuncV1: "The `io.containerd.runc.v1` runtime is deprecated since containerd v1.4 and removed in containerd v2.0. Use the `io.containerd.runc.v2` runtime instead.",
}

// Valid checks whether a given Warning is valid
Expand Down
26 changes: 21 additions & 5 deletions services/tasks/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/blockio"
"github.com/containerd/containerd/pkg/deprecation"
"github.com/containerd/containerd/pkg/rdt"
"github.com/containerd/containerd/pkg/timeout"
"github.com/containerd/containerd/plugin"
Expand All @@ -50,6 +51,8 @@ import (
"github.com/containerd/containerd/runtime/linux/runctypes"
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/containerd/services"
"github.com/containerd/containerd/services/warning"

"github.com/containerd/typeurl/v2"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -117,6 +120,11 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
monitor = runtime.NewNoopMonitor()
}

w, err := ic.Get(plugin.WarningPlugin)
if err != nil {
return nil, err
}

db := m.(*metadata.DB)
l := &local{
runtimes: runtimes,
Expand All @@ -125,6 +133,7 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
publisher: ep.(events.Publisher),
monitor: monitor.(runtime.TaskMonitor),
v2Runtime: v2r.(runtime.PlatformRuntime),
warnings: w.(warning.Service),
}
for _, r := range runtimes {
tasks, err := r.Tasks(ic.Context, true)
Expand Down Expand Up @@ -161,6 +170,7 @@ type local struct {

monitor runtime.TaskMonitor
v2Runtime runtime.PlatformRuntime
warnings warning.Service
}

func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.CallOption) (*api.CreateTaskResponse, error) {
Expand Down Expand Up @@ -221,11 +231,7 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
Options: m.Options,
})
}
if strings.HasPrefix(container.Runtime.Name, "io.containerd.runtime.v1.") {
log.G(ctx).Warn("runtime v1 is deprecated since containerd v1.4, consider using runtime v2")
} else if container.Runtime.Name == plugin.RuntimeRuncV1 {
log.G(ctx).Warnf("%q is deprecated since containerd v1.4, consider using %q", plugin.RuntimeRuncV1, plugin.RuntimeRuncV2)
}
l.emitRuntimeWarning(ctx, container.Runtime.Name)
rtime, err := l.getRuntime(container.Runtime.Name)
if err != nil {
return nil, err
Expand Down Expand Up @@ -255,6 +261,16 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
}, nil
}

func (l *local) emitRuntimeWarning(ctx context.Context, runtime string) {
switch runtime {
case plugin.RuntimeLinuxV1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we are only emitting warnings for io.containerd.runtime.v1.linux. Are we not deprecating other v1 runtimes like io.containerd.runtime.v1.windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. Does io.containerd.runtime.v1.windows exist? I see it in a couple places in the client code (1, 2, 3) but can't find the actual plugin implementing it. @dcantah do you know?

log.G(ctx).Warnf("%q is deprecated since containerd v1.4 and will be removed in containerd v2.0, use %q instead", plugin.RuntimeLinuxV1, plugin.RuntimeRuncV2)
l.warnings.Emit(ctx, deprecation.RuntimeV1)
case plugin.RuntimeRuncV1:
log.G(ctx).Warnf("%q is deprecated since containerd v1.4 and will be removed in containerd v2.0, use %q instead", plugin.RuntimeRuncV1, plugin.RuntimeRuncV2)
l.warnings.Emit(ctx, deprecation.RuntimeRuncV1)
}
}
func (l *local) Start(ctx context.Context, r *api.StartRequest, _ ...grpc.CallOption) (*api.StartResponse, error) {
t, err := l.getTask(ctx, r.ContainerID)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions services/tasks/local_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var tasksServiceRequires = []plugin.Type{
plugin.RuntimePluginV2,
plugin.MetadataPlugin,
plugin.TaskMonitorPlugin,
plugin.WarningPlugin,
}

// loadV1Runtimes on darwin returns an empty map. There are no v1 runtimes
Expand Down
1 change: 1 addition & 0 deletions services/tasks/local_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var tasksServiceRequires = []plugin.Type{
plugin.RuntimePluginV2,
plugin.MetadataPlugin,
plugin.TaskMonitorPlugin,
plugin.WarningPlugin,
}

// loadV1Runtimes on FreeBSD returns an empty map. There are no v1 runtimes
Expand Down
1 change: 1 addition & 0 deletions services/tasks/local_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var tasksServiceRequires = []plugin.Type{
plugin.RuntimePluginV2,
plugin.MetadataPlugin,
plugin.TaskMonitorPlugin,
plugin.WarningPlugin,
}

func loadV1Runtimes(ic *plugin.InitContext) (map[string]runtime.PlatformRuntime, error) {
Expand Down
1 change: 1 addition & 0 deletions services/tasks/local_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var tasksServiceRequires = []plugin.Type{
plugin.RuntimePluginV2,
plugin.MetadataPlugin,
plugin.TaskMonitorPlugin,
plugin.WarningPlugin,
}

// loadV1Runtimes on Windows V2 returns an empty map. There are no v1 runtimes
Expand Down