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

worker: move labels const to its own package #3014

Merged
merged 1 commit into from
Aug 9, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions worker/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/moby/buildkit/util/leaseutil"
"github.com/moby/buildkit/util/network/netproviders"
"github.com/moby/buildkit/util/winlayers"
"github.com/moby/buildkit/worker"
"github.com/moby/buildkit/worker/base"
wlabel "github.com/moby/buildkit/worker/label"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -67,16 +67,16 @@ func newContainerd(root string, client *containerd.Client, snapshotterName, ns s
hostname = "unknown"
}
xlabels := map[string]string{
worker.LabelExecutor: "containerd",
worker.LabelSnapshotter: snapshotterName,
worker.LabelHostname: hostname,
worker.LabelNetwork: npResolvedMode,
wlabel.Executor: "containerd",
wlabel.Snapshotter: snapshotterName,
wlabel.Hostname: hostname,
wlabel.Network: npResolvedMode,
}
if apparmorProfile != "" {
xlabels[worker.LabelApparmorProfile] = apparmorProfile
xlabels[wlabel.ApparmorProfile] = apparmorProfile
}
xlabels[worker.LabelContainerdNamespace] = ns
xlabels[worker.LabelContainerdUUID] = serverInfo.UUID
xlabels[wlabel.ContainerdNamespace] = ns
xlabels[wlabel.ContainerdUUID] = serverInfo.UUID
for k, v := range labels {
xlabels[k] = v
}
Expand Down
15 changes: 15 additions & 0 deletions worker/label/label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package label

// Pre-defined label keys
const (
prefix = "org.mobyproject.buildkit.worker."

Executor = prefix + "executor" // "oci" or "containerd"
Snapshotter = prefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
Hostname = prefix + "hostname"
Network = prefix + "network" // "cni" or "host"
ApparmorProfile = prefix + "apparmor.profile"
OCIProcessMode = prefix + "oci.process-mode" // OCI worker: process mode ("sandbox", "no-sandbox")
ContainerdUUID = prefix + "containerd.uuid" // containerd worker: containerd UUID
ContainerdNamespace = prefix + "containerd.namespace" // containerd worker: containerd namespace
)
14 changes: 7 additions & 7 deletions worker/runc/runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/moby/buildkit/util/leaseutil"
"github.com/moby/buildkit/util/network/netproviders"
"github.com/moby/buildkit/util/winlayers"
"github.com/moby/buildkit/worker"
"github.com/moby/buildkit/worker/base"
wlabel "github.com/moby/buildkit/worker/label"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
bolt "go.etcd.io/bbolt"
"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -104,14 +104,14 @@ func NewWorkerOpt(root string, snFactory SnapshotterFactory, rootless bool, proc
hostname = "unknown"
}
xlabels := map[string]string{
worker.LabelExecutor: "oci",
worker.LabelSnapshotter: snFactory.Name,
worker.LabelHostname: hostname,
worker.LabelNetwork: npResolvedMode,
worker.LabelOCIProcessMode: processMode.String(),
wlabel.Executor: "oci",
wlabel.Snapshotter: snFactory.Name,
wlabel.Hostname: hostname,
wlabel.Network: npResolvedMode,
wlabel.OCIProcessMode: processMode.String(),
}
if apparmorProfile != "" {
xlabels[worker.LabelApparmorProfile] = apparmorProfile
xlabels[wlabel.ApparmorProfile] = apparmorProfile
}

for k, v := range labels {
Expand Down
13 changes: 0 additions & 13 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,3 @@ type Infos interface {
GetDefault() (Worker, error)
WorkerInfos() []client.WorkerInfo
}

// Pre-defined label keys
const (
labelPrefix = "org.mobyproject.buildkit.worker."
Copy link
Member

Choose a reason for hiding this comment

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

Did a quick search if there's any external consumers of these (besides vendoring), and doesn't seem to be the case , so probably no aliases and deprecation needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I https://grep.app/ and found nothing relevant

LabelExecutor = labelPrefix + "executor" // "oci" or "containerd"
LabelSnapshotter = labelPrefix + "snapshotter" // containerd snapshotter name ("overlay", "native", ...)
LabelHostname = labelPrefix + "hostname"
LabelNetwork = labelPrefix + "network" // "cni" or "host"
LabelApparmorProfile = labelPrefix + "apparmor.profile"
LabelOCIProcessMode = labelPrefix + "oci.process-mode" // OCI worker: process mode ("sandbox", "no-sandbox")
LabelContainerdUUID = labelPrefix + "containerd.uuid" // containerd worker: containerd UUID
LabelContainerdNamespace = labelPrefix + "containerd.namespace" // containerd worker: containerd namespace
)