containerd/pkg
Davanum Srinivas 494b940f14
Introduce a new go module - containerd/api for use in standalone clients
In containerd 1.5.x, we introduced support for go modules by adding a
go.mod file in the root directory. This go.mod lists all the things
needed across the whole code base (with the exception of
integration/client which has its own go.mod). So when projects that
need to make calls to containerd API will pull in some code from
containerd/containerd, the `go mod` commands will add all the things
listed in the root go.mod to the projects go.mod file. This causes
some problems as the list of things needed to make a simple API call
is enormous. in effect, making a API call will pull everything that a
typical server needs as well as the root go.mod is all encompassing.
In general if we had smaller things folks could use, that will make it
easier by reducing the number of things that will end up in a consumers
go.mod file.

Now coming to a specific problem, the root containerd go.mod has various
k8s.io/* modules listed. Also kubernetes depends on containerd indirectly
via both moby/moby (working with docker maintainers seperately) and via
google/cadvisor. So when the kubernetes maintainers try to use latest
1.5.x containerd, they will see the kubernetes go.mod ending up depending
on the older version of kubernetes!

So if we can expose just the minimum things needed to make a client API
call then projects like cadvisor can adopt that instead of pulling in
the entire go.mod from containerd. Looking at the existing code in
cadvisor the minimum things needed would be the api/ directory from
containerd. Please see proof of concept here:
github.com/google/cadvisor/pull/2908

To enable that, in this PR, we add a go.mod file in api/ directory. we
split the Protobuild.yaml into two, one for just the things in api/
directory and the rest in the root directory. We adjust various targets
to build things correctly using `protobuild` and also ensure that we
end up with the same generated code as before as well. To ensure we
better take care of the various go.mod/go.sum files, we update the
existing `make vendor` and also add a new `make verify-vendor` that one
can run locally as well in the CI.

Ideally, we would have a `containerd/client` either as a standalone repo
or within `containerd/containerd` as a separate go module. but we will
start here to experiment with a standalone api go module first.

Also there are various follow ups we can do, for example @thaJeztah has
identified two tasks we could do after this PR lands:

github.com/containerd/containerd/pull/5716#discussion_r668821396

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-27 07:34:59 -04:00
..
apparmor update the link 2021-05-20 11:56:29 +08:00
atomic use containerd/project header test 2020-04-22 19:35:37 -05:00
cap Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
cri remove pkg/cri/platforms package 2021-07-10 10:14:27 +08:00
dialer Unify dialer implementations 2020-02-26 23:29:04 +02:00
ioutil use containerd/project header test 2020-04-22 19:35:37 -05:00
netns Allow moving netns directory into StateDir 2021-02-10 18:33:14 +01:00
oom cgroup2: implement containerd.events.TaskOOM event 2020-06-01 14:00:13 +09:00
os windows: Use GetFinalPathNameByHandle for ResolveSymbolicLink 2021-05-04 11:55:11 -07:00
process Merge pull request #5401 from Iceber/use-unbuffered-channel 2021-04-21 16:50:32 -07:00
progress Fix linter errors 2019-07-14 20:49:40 -07:00
registrar use containerd/project header test 2020-04-22 19:35:37 -05:00
runtimeoptions/v1 Introduce a new go module - containerd/api for use in standalone clients 2021-07-27 07:34:59 -04:00
seccomp pkg/seccomp: use sync.Once to speed up IsEnabled 2021-04-16 15:52:35 -07:00
seed Seed random on ctr and containerd startup 2018-07-12 17:51:55 -07:00
seutil Handle KVM based runtimes with selinux 2020-08-26 21:38:03 -04:00
stdio Add logging binary support when terminal is true 2020-08-25 17:28:29 -07:00
testutil vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
timeout Allow timeouts to be configured in config 2019-08-13 17:36:32 +00:00
ttrpcutil fix dial error when clean up a dead shim 2020-03-12 10:57:55 +08:00
userns Move RunningInUserNS() to its own package 2021-03-23 11:29:53 +01:00