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 platforms support #461

Merged
merged 3 commits into from
Jun 25, 2018
Merged

Conversation

tonistiigi
Copy link
Member

Define supported platforms for workers and automatically detect the defaults.

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

@AkihiroSuda
Copy link
Member

Can we use labels?

@@ -122,7 +133,7 @@ message OpMetadata {
bool ignore_cache = 1;
// Description can be used for keeping any text fields that builder doesn't parse
map<string, string> description = 2;
WorkerConstraint worker_constraint = 3;
// WorkerConstraint worker_constraint = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this deliberately left commented out?

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'll add a better comment.

Labels map[string]string `protobuf:"bytes,2,rep,name=Labels" json:"Labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Labels map[string]string `protobuf:"bytes,2,rep,name=Labels" json:"Labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Platforms []*pb.Platform `protobuf:"bytes,3,rep,name=platforms" json:"platforms,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably be []pb.Platform, similar to client's WorkerInfo.

if len(platformsStr) != 0 {
platforms, err := parsePlatforms(platformsStr)
if err != nil {
return nil, errors.Wrapf(err, "invalid platforms")
Copy link
Collaborator

Choose a reason for hiding this comment

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

errors.Wrap

@tiborvass
Copy link
Collaborator

Overall looks good

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
)

type Worker interface {
// ID needs to be unique in the cluster
ID() string
Labels() map[string]string
Platforms() []specs.Platform
Copy link
Member

Choose a reason for hiding this comment

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

What should we do with?

38 	LabelOS          = labelPrefix + "os"          // GOOS
39 	LabelArch        = labelPrefix + "arch"        // GOARCH

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, they could be still used for constraints with filters but as they are just GOOS/GOARCH they may not be that useful. We can reevaluate if this is more complete. The Platform field is more like a "target platform" for vertex and less like a value based constraint.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe better to remove these labels for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll remove

Copy link
Member

Choose a reason for hiding this comment

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

LGTM after removal of LabelOS and LabelArch consts

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@tonistiigi
Copy link
Member Author

Can we use labels?

Hmm, I'm pretty sure I left answer for that yesterday but can't see it anymore. @AkihiroSuda Did you see the answer? (maybe in e-mail notification)

@AkihiroSuda
Copy link
Member

Hmm, I'm pretty sure I left answer for that yesterday but can't see it anymore. @AkihiroSuda Did you see the answer? (maybe in e-mail notification)

Unfortunately no (I'm not using email notification)

@tonistiigi
Copy link
Member Author

Ok, I'll try again. Maybe I just failed to press send.

Can we use labels?

First problem is that it should be an array. Containerd supports multiple platforms in this value and BuildKit should do it was well. In practical build cases these would be either emulators or different container compatibility versions for windows.

If you look at #462, #463 then LLB now always defines the target platform so there is no ambiguity on LLB possibly meaning two different things based on worker configuration. In LLB, target platform is separated from regular constrains filters because it needs to be used for determining the image to pull/export. This happens using the image-spec platform field so it makes sense to use the same type here as well to make in consistent. Also, the target platform isn't neccessarily a constraint for any vertex, eg. a Dockerfile COPY operation should work even if the node doesn't support execution on target platform - hence in #463 the validation is only limited to exec operations and that can only happen if we use a typed value.

Superceded by platforms array.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@AkihiroSuda AkihiroSuda merged commit a084629 into moby:master Jun 25, 2018
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.

4 participants