worker/containerd: expose namespace and UUID as labels
e.g., ``` Labels: org.mobyproject.buildkit.worker.containerd.namespace: buildkit org.mobyproject.buildkit.worker.containerd.uuid: 343cfb49-cce9-453f-b21c-e5d22ca2cb47 org.mobyproject.buildkit.worker.executor: containerd org.mobyproject.buildkit.worker.hostname: suda-ws01 org.mobyproject.buildkit.worker.snapshotter: overlayfs ``` Planned to be used by nerdctl to detect whether containerd exporter can be used Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>v0.9
parent
f09774d589
commit
35949ab569
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/gc"
|
"github.com/containerd/containerd/gc"
|
||||||
"github.com/containerd/containerd/leases"
|
"github.com/containerd/containerd/leases"
|
||||||
|
gogoptypes "github.com/gogo/protobuf/types"
|
||||||
"github.com/moby/buildkit/cache"
|
"github.com/moby/buildkit/cache"
|
||||||
"github.com/moby/buildkit/cache/metadata"
|
"github.com/moby/buildkit/cache/metadata"
|
||||||
"github.com/moby/buildkit/executor/containerdexecutor"
|
"github.com/moby/buildkit/executor/containerdexecutor"
|
||||||
|
@ -17,6 +18,7 @@ import (
|
||||||
"github.com/moby/buildkit/util/leaseutil"
|
"github.com/moby/buildkit/util/leaseutil"
|
||||||
"github.com/moby/buildkit/util/network/netproviders"
|
"github.com/moby/buildkit/util/network/netproviders"
|
||||||
"github.com/moby/buildkit/util/winlayers"
|
"github.com/moby/buildkit/util/winlayers"
|
||||||
|
"github.com/moby/buildkit/worker"
|
||||||
"github.com/moby/buildkit/worker/base"
|
"github.com/moby/buildkit/worker/base"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -48,7 +50,15 @@ func newContainerd(root string, client *containerd.Client, snapshotterName, ns s
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return base.WorkerOpt{}, err
|
return base.WorkerOpt{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serverInfo, err := client.IntrospectionService().Server(context.TODO(), &gogoptypes.Empty{})
|
||||||
|
if err != nil {
|
||||||
|
return base.WorkerOpt{}, err
|
||||||
|
}
|
||||||
|
|
||||||
xlabels := base.Labels("containerd", snapshotterName)
|
xlabels := base.Labels("containerd", snapshotterName)
|
||||||
|
xlabels[worker.LabelContainerdNamespace] = ns
|
||||||
|
xlabels[worker.LabelContainerdUUID] = serverInfo.UUID
|
||||||
for k, v := range labels {
|
for k, v := range labels {
|
||||||
xlabels[k] = v
|
xlabels[k] = v
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,6 @@ const (
|
||||||
LabelExecutor = labelPrefix + "executor" // "oci" or "containerd"
|
LabelExecutor = labelPrefix + "executor" // "oci" or "containerd"
|
||||||
LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
|
LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
|
||||||
LabelHostname = labelPrefix + "hostname"
|
LabelHostname = labelPrefix + "hostname"
|
||||||
|
LabelContainerdUUID = labelPrefix + "containerd.uuid" // containerd worker: containerd UUID
|
||||||
|
LabelContainerdNamespace = labelPrefix + "containerd.namespace" // containerd worker: containerd namespace
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue