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: add annotation labels #232

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

AkihiroSuda
Copy link
Member

$ sudo ./bin/buildctl local-workers -v labels.org.mobyproject.buildkit.worker.executor==containerd 
ID:                                             containerd-overlayfs@ws01                                                                         
org.mobyproject.buildkit.worker.hostname:       ws01                     
org.mobyproject.buildkit.worker.os:             linux                    
org.mobyproject.buildkit.worker.arch:           amd64                    
org.mobyproject.buildkit.worker.executor:       containerd               
org.mobyproject.buildkit.worker.snapshotter:    overlayfs

Update #62 #41

@AkihiroSuda AkihiroSuda changed the title Worker annotations worker: add annotation labels Dec 19, 2017
if daemonInstanceID == "" {
daemonInstanceID = hostname
}
id := executor + "-" + snapshotter + "@" + daemonInstanceID
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we just use random string?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think ID should be unique. We can show these fields on the non-verbose output of the command.

Copy link
Member

Choose a reason for hiding this comment

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

Store it in the state directory on first run.

)

var localWorkersCommand = cli.Command{
Name: "local-workers",
Copy link
Member

Choose a reason for hiding this comment

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

Add this under debug for now (and add comments to proto that this API will likely change). In the future I'd expect this to be part of some generic inspection API that shows remote workers, daemon info etc. but too early for that atm.

return err
}

workers, err := c.ListLocalWorkers(appcontext.Context(), client.WithWorkerFilter(clicontext.Args()))
Copy link
Member

Choose a reason for hiding this comment

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

Why the "local" prefix everywhere? When remote workers become possible I'd expect them to be included in this output.

Copy link
Member

Choose a reason for hiding this comment

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

Should we keep this under --filter/-f flag still, like buildctl du.

if daemonInstanceID == "" {
daemonInstanceID = hostname
}
id := executor + "-" + snapshotter + "@" + daemonInstanceID
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think ID should be unique. We can show these fields on the non-verbose output of the command.

if daemonInstanceID == "" {
daemonInstanceID = hostname
}
id := executor + "-" + snapshotter + "@" + daemonInstanceID
Copy link
Member

Choose a reason for hiding this comment

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

Store it in the state directory on first run.

func printWorkersVerbose(tw *tabwriter.Writer, winfo []*client.WorkerInfo) {
for _, wi := range winfo {
printKV(tw, "ID", wi.ID)
for k, v := range wi.Labels {
Copy link
Member

Choose a reason for hiding this comment

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

We should keep this output in order.

@@ -64,6 +64,14 @@ func main() {
Name: "debug",
Usage: "enable debug output in logs",
},
cli.StringFlag{
Name: "instance-id",
Copy link
Member

Choose a reason for hiding this comment

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

I think we can skip this for now if we use random IDs.

Usage: "daemon instance id (required only when multiple daemons share the hostname)",
},
cli.StringSliceFlag{
Name: "labels",
Copy link
Member

Choose a reason for hiding this comment

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

Aren't these worker specific?

@@ -68,11 +70,16 @@ func NewWorkerOpt(root string) (base.WorkerOpt, error) {

// TODO: call mdb.GarbageCollect . maybe just inject it into nsSnapshotter.Remove and csContent.Delete

id, xlabels := base.DetermineAnnotations(daemonInstanceID, "oci", "overlayfs")
Copy link
Member

Choose a reason for hiding this comment

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

No need for "Determine" here

worker/filter.go Outdated
"github.com/containerd/containerd/filters"
)

func adaptWorker(o interface{}) filters.Adaptor {
Copy link
Member

Choose a reason for hiding this comment

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

Why does this func take interface{}?

@AkihiroSuda
Copy link
Member Author

updated


// ID reads the worker id from the metadata store.
// If not exist, generate a random one,
func ID(meta *metadata.Store) (string, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Is it ok to use metadata store here?

Copy link
Member

Choose a reason for hiding this comment

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

No, it should only be for snapshot metadata. There is an All() request in the snapshots initializer that reads in all records from here and expects them to be snapshots.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

You can add a note to readme about this command as well

}

message DiskUsageRequest {
string filter = 1;
string filter = 1; // FIXME: this should be containerd-compatible repeated string?
Copy link
Member

Choose a reason for hiding this comment

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

Yes. (Not in this PR)


// ID reads the worker id from the metadata store.
// If not exist, generate a random one,
func ID(meta *metadata.Store) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

No, it should only be for snapshot metadata. There is an All() request in the snapshots initializer that reads in all records from here and expects them to be snapshots.

}

func sortMap(m map[string]string) [][2]string {
var s [][2]string
Copy link
Member

Choose a reason for hiding this comment

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

nit: you don't really need the [][2] construction in here as you only need to sort the keys and could read the value from map. sortedKeys(m) []string would probably be easier to follow. Also, initialize the slice with map length.

@AkihiroSuda
Copy link
Member Author

updated

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

One small nit.

LGTM

@@ -23,9 +23,11 @@ import (
// NewWorkerOpt creates a WorkerOpt.
// But it does not set the following fields:
// - SessionManager
func NewWorkerOpt(root string) (base.WorkerOpt, error) {
//
// daemonInstanceID is optional unless multiple instances share the single hostname.
Copy link
Member

Choose a reason for hiding this comment

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

remove comment

@@ -19,17 +19,19 @@ import (
// NewWorkerOpt creates a WorkerOpt.
// But it does not set the following fields:
// - SessionManager
func NewWorkerOpt(root string, address, snapshotterName string, opts ...containerd.ClientOpt) (base.WorkerOpt, error) {
//
// daemonInstanceID is optional unless multiple instances share the single hostname.
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@AkihiroSuda
Copy link
Member Author

done

@AkihiroSuda
Copy link
Member Author

Flaky docker build: https://travis-ci.org/moby/buildkit/builds/319031791?utm_source=github_status&utm_medium=notification

Step 7/17 : RUN apk add --no-cache git make

 ---> Running in b148f1428a8b

fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz

fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz

(1/6) Installing libssh2 (1.8.0-r1)

(2/6) Installing libcurl (7.57.0-r0)

(3/6) Installing expat (2.2.0-r1)

(4/6) Installing pcre (8.41-r0)

(5/6) Installing git (2.13.5-r0)

ERROR: Failed to create usr/libexec/git-core/git-show-index: I/O error

ERROR: git-2.13.5-r0: IO ERROR

(6/6) Installing make (4.2.1-r0)

Executing busybox-1.26.2-r9.trigger

1 error; 166 MiB in 33 packages

Removing intermediate container b148f1428a8b

The command '/bin/sh -c apk add --no-cache git make' returned a non-zero code: 1

make: *** [bin/buildkitd] Error 1

Is this an issue of Docker? (Docker 17.11-ce, probably overlayfs driver)

@tonistiigi
Copy link
Member

@AkihiroSuda Or network issue. BTW, Do you have permissions to restart CI?

@AkihiroSuda
Copy link
Member Author

Yes
image

Signed-off-by: Akihiro Suda <[email protected]>
@tonistiigi tonistiigi merged commit 35bef6e into moby:master Dec 20, 2017
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