-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
worker/base/worker.go
Outdated
if daemonInstanceID == "" { | ||
daemonInstanceID = hostname | ||
} | ||
id := executor + "-" + snapshotter + "@" + daemonInstanceID |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
b2a8bac
to
edc6ce7
Compare
cmd/buildctl/localworkers.go
Outdated
) | ||
|
||
var localWorkersCommand = cli.Command{ | ||
Name: "local-workers", |
There was a problem hiding this comment.
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.
cmd/buildctl/localworkers.go
Outdated
return err | ||
} | ||
|
||
workers, err := c.ListLocalWorkers(appcontext.Context(), client.WithWorkerFilter(clicontext.Args())) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
worker/base/worker.go
Outdated
if daemonInstanceID == "" { | ||
daemonInstanceID = hostname | ||
} | ||
id := executor + "-" + snapshotter + "@" + daemonInstanceID |
There was a problem hiding this comment.
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.
worker/base/worker.go
Outdated
if daemonInstanceID == "" { | ||
daemonInstanceID = hostname | ||
} | ||
id := executor + "-" + snapshotter + "@" + daemonInstanceID |
There was a problem hiding this comment.
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.
cmd/buildctl/localworkers.go
Outdated
func printWorkersVerbose(tw *tabwriter.Writer, winfo []*client.WorkerInfo) { | ||
for _, wi := range winfo { | ||
printKV(tw, "ID", wi.ID) | ||
for k, v := range wi.Labels { |
There was a problem hiding this comment.
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.
cmd/buildkitd/main.go
Outdated
@@ -64,6 +64,14 @@ func main() { | |||
Name: "debug", | |||
Usage: "enable debug output in logs", | |||
}, | |||
cli.StringFlag{ | |||
Name: "instance-id", |
There was a problem hiding this comment.
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.
cmd/buildkitd/main.go
Outdated
Usage: "daemon instance id (required only when multiple daemons share the hostname)", | ||
}, | ||
cli.StringSliceFlag{ | ||
Name: "labels", |
There was a problem hiding this comment.
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?
worker/runc/runc.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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{}
?
updated |
edc6ce7
to
8456e32
Compare
worker/base/worker.go
Outdated
|
||
// ID reads the worker id from the metadata store. | ||
// If not exist, generate a random one, | ||
func ID(meta *metadata.Store) (string, error) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
8456e32
to
f4c7297
Compare
There was a problem hiding this 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? |
There was a problem hiding this comment.
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)
worker/base/worker.go
Outdated
|
||
// ID reads the worker id from the metadata store. | ||
// If not exist, generate a random one, | ||
func ID(meta *metadata.Store) (string, error) { |
There was a problem hiding this comment.
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.
cmd/buildctl/debug/workers.go
Outdated
} | ||
|
||
func sortMap(m map[string]string) [][2]string { | ||
var s [][2]string |
There was a problem hiding this comment.
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.
f4c7297
to
6be96b1
Compare
updated |
There was a problem hiding this 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
worker/runc/runc.go
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
worker/containerd/containerd.go
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
6be96b1
to
9dcbdc0
Compare
done |
Flaky
Is this an issue of Docker? (Docker 17.11-ce, probably overlayfs driver) |
@AkihiroSuda Or network issue. BTW, Do you have permissions to restart CI? |
Signed-off-by: Akihiro Suda <[email protected]>
9dcbdc0
to
84c0dd0
Compare
Update #62 #41