Skip to content

[Alternative to 148] go.mod: github.com/containerd/containerd/v2 v2.0.0-rc.0#153

Closed
AkihiroSuda wants to merge 5 commits intocontainerd:mainfrom
AkihiroSuda:containerd-v2-take2
Closed

[Alternative to 148] go.mod: github.com/containerd/containerd/v2 v2.0.0-rc.0#153
AkihiroSuda wants to merge 5 commits intocontainerd:mainfrom
AkihiroSuda:containerd-v2-take2

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

Similar to PR #148, but does not bump up urfave/cli.

  • cmd/ctr is kept to use urfave/cli v1, but its containerd library is
    bumped up from v1.6 to v1.7 due to dependencies.
    typeurl is bumped up from v1 to v2 as a part of them.

  • cmd/ctr/v2v1glue and cmd/ctr/v1v2glue are added for using
    containerd v2-based encryption library from containerd v1-based CLI.

  • cmd/ctr/commands/tasks was copied from https://github.com/containerd/containerd/tree/v1.7.14/cmd/ctr/commands/tasks,
    but metrics.go was removed due to a dependency issue:
    containerd v1 depends on hcsshim v0.11, while containerd v2 depends on hcsshim v0.12.


(This is a very quick attempt at "what this will look like")

This repository provides both command-line utilities, and a module for external
consumers.

Currently, both are part of the same module; as a result, dependencies of both
the module *and* the command-line utilities are listed in the repositories go.mod.
This affects consumers of this project, because (due to go module's nature of
dependency (version) resolution), those consumers will inherit all dependencies,
or will be "forced" to use the same version of the CLI dependencies.

This is a very quick attempt at separating the CLI utilities from the "module",
by creating a separate go.mod (and module) for the CLI utilities.

I'm not fond of the name (github.com/containerd/imgcrypt/cmd) for that module
(possibly renaming to github.com/containerd/imgcrypt/cli would be slightly
clearer).

This change _will_ add some additional work when tagging releases; a separate tag
should be created for the cli utilities (tagging as `cmd/vX.Y.Z`), and the
"github.com/containerd/imgcrypt" dependency in the go.mod inside the cmd directory
may need to be updated to reflect the latest version of the main module when tagging
new releases (as the replace rule is non-transitional); something like:

1. update `github.com/containerd/imgcrypt` version in cmd/go.mod to "next release"
2. tag both `v<new release>` and `cmd/v<new version>` in tandem.

CI / validation also needs to be updated to verify both `go.mod` and `go.sum`
files are correct / up-to-date. Possibly checks should be added to make sure the
main module is isolated from the cmd module (i.e., the "module" should not import
any path from the cmd directory: the reverse is of course OK (and expected)).

Finally; use of the 'vendor' directory may need to be discussed; it is common
to only use a vendor directory for projects that produce binaries, but omit the
vendor directory for "library" projects. In this case (if vendoring is still
desired), the vendor directory should be removed from the root of the repository,
and moved inside the `cmd` directory.

Originally-from: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the containerd-v2-take2 branch from 984c5a5 to 553a587 Compare March 28, 2024 08:16
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the containerd-v2-take2 branch 3 times, most recently from fa20237 to 7dcfe5b Compare March 28, 2024 08:25
….0-rc.0

Similar to PR 148, but does not bump up urfave/cli.

- `cmd/ctr` is kept to use urfave/cli v1, but its containerd library is
  bumped up from v1.6 to v1.7 due to dependencies.
  typeurl is bumped up from v1 to v2 as a part of them.

- `cmd/ctr/v2v1glue` and `cmd/ctr/v1v2glue` are added for using
  containerd v2-based encryption library from containerd v1-based CLI.

- `cmd/ctr/commands/tasks` was copied from <https://github.com/containerd/containerd/tree/v1.7.14/cmd/ctr/commands/tasks>,
  but `metrics.go` was removed due to a dependency issue:
  containerd v1 depends on hcsshim v0.11, while containerd v2 depends on hcsshim v0.12.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda force-pushed the containerd-v2-take2 branch from 7dcfe5b to 34eabb9 Compare March 28, 2024 08:25
@AkihiroSuda
Copy link
Copy Markdown
Member Author

Looks like we can't import containerd v1 and v2 together

panic: proto: file "github.com/containerd/containerd/core/runtime/v2/runc/options/oci.proto" has a name conflict over containerd.runc.v1.ProcessDetails
	previously from: "github.com/containerd/containerd/runtime/v2/runc/options"
	currently from:  "github.com/containerd/containerd/v2/core/runtime/v2/runc/options"
See https://protobuf.dev/reference/go/faq#namespace-conflict

https://github.com/containerd/imgcrypt/actions/runs/8464452194/job/23189151410?pr=153

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.

2 participants