Skip to content

Migrated urunc from containerd v1.x to v2.x for fixing unparsed new flag#765

Open
Cicada1107 wants to merge 1 commit into
urunc-dev:mainfrom
Cicada1107:info-flag-issue
Open

Migrated urunc from containerd v1.x to v2.x for fixing unparsed new flag#765
Cicada1107 wants to merge 1 commit into
urunc-dev:mainfrom
Cicada1107:info-flag-issue

Conversation

@Cicada1107

Copy link
Copy Markdown

The issue:

  • I checked all the major changes across v1.x and v2.x containerd
  • First, I tried to look at just the sed file and patch it however, in doing so I realized that it is not really a sed issue. The changes introduced in containerd v2.x were not really a sed issue.
  • The root cause of the -info parsing issue was that containerd v2.x daemon expects the shim to parse the new flags like -info which the older containerd v1.x shim implementation did not support (and this is the shim we were using under the hood in our containerd-shim-urunc-v2 as seen in the main.go file of the same)
  • So, the solution was to migrate urunc from containerd v1 to v2.
  • This had the following issues:
    • The path is different for v2. Its github.com/containerd/containerd/v2 instead of github.com/containerd/containerd.
    • The shim manager was relocated from github.com/containerd/containerd/runtime/v2/runc/manager in v1 to github.com/containerd/containerd/v2/cmd/containerd-shim-runc-v2/manager in v2.
    • The task plugin and the api were relocated and also had changes:
      • Task plugin was relocated from in runtime/v2/runc/task v1 to cmd/containerd-shim-runc-v2/task in v2.
      • The NewTaskService constructor signature was chnaged from taking a *plugin.InitContext to taking a (context.Context, shim.Publisher, shutdown.Service).
    • Also, the grpc APIs are now separated out completely into a different path - github.com/containerd/containerd/api .
  • And here's why the sed command in the Makefile was breaking I think: it modifies the vendor/github.com/containerd/go-runc/runc.go but when migrating to v2, the sed command isnt itself wrong, but the files it compiles - cmd/containerd-shim-urunc-v2/main.go - our urunc shim, relied on the old runtime/v2/runc paths which don't exit anymore in containerd v2.

The changes I made:

  • Updated the depenencies to use containerd v2 instead of v1, and the required supporting changes. Basically:
go get [github.com/containerd/containerd/v2@v2.3.1](https://github.com/containerd/containerd/v2@v2.3.1)
go get [github.com/containerd/containerd/api@v1.11.1](https://github.com/containerd/containerd/api@v1.11.1)
go mod tidy
go mod vendor

and then all the below changes are mostly mitigating the breaking changes this migration would cause as I listed above.

  • Updated the makefile to use the updated module structure for making the build
  • Updated the shim manager imports in containerd-shim-urunc-v2/main.go to the new paths and to use the shim.RunShim as per the new v2 instead of shim.RunManager API as described above & (This is important: please let me know if this change is fine!) made an intercption hook before executing shim.RunShim (Because v2 container shim outputs a binary protobuf instead of normal string like v1 shim did, so I was getting errors like "Yunix Schemas" and other misinterpretations, so this wrapper basically takes it and converts the protobuf into a oplaintext string like before. This should take care of backward compatibility).
  • Updated containerd-shim/task_plugin.go to use the new paths and the new fn signature, again, as described above.
  • Containerd v2 also changed the mapping for errors nad plugins. So migrated task_plugin.go and task_service.go accordingly - to use the new namespace definitions (github.com/containerd/containerd/v2/plugins) and also, swapped out deprecated errdefs.FromGRPC for the errgrpc.ToNative and errgrpc.ToGRPCF functions as per the new standard.
  • Searched and replaced all the outdated imports with the new paths across a few other files.

Result:

  • Tested by starting up the same qemu unikernel command that gave me the -info error before, on containerd v2.3.1
  • Got no "level=error flag = -info not parsed...." in journalctl logs
  • I've tried hard to be careful with everything, but do let me know if there is something that I should look into or modify

Fixes #750

This commit:
1. Upgrades dependency and fixes file structure - go.mod, go.sum, vendor/
2. Upgraded shim bootstrapping logic - containerd-shim-urunc-v2/main.go
3. Added backward compatible TTRPC Protocol layer - pkg/containerd-shim/task_service.go
4. Migrated init function and error mapping to accomodate containerd's v2 changes. - task_plugin.go, task_service.go

Signed-off-by: Arijit Dubey <arijitdubey2018@gmail.com>
@netlify

netlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit b50441f
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a303e7f5fd346000858c365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

containerd-shim-urunc-v2 failing to parse -info flag on initialization

1 participant