-
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
llb: per-vertex metadata (e.g. IgnoreCache) #114
Conversation
545b19e
to
0cee46f
Compare
client/solve.go
Outdated
func (c *Client) Solve(ctx context.Context, r io.Reader, opt SolveOpt, statusChan chan *SolveStatus) error { | ||
// Solve calls Solve on the controller. | ||
// def and metadata are empty if opt.Frontend is set. | ||
func (c *Client) Solve(ctx context.Context, def [][]byte, metadata pb.Metadata, opt SolveOpt, statusChan chan *SolveStatus) 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.
Avoid protobuf types in client pkg
solver/pb/ops.proto
Outdated
} | ||
|
||
message BuildInput { | ||
int64 input = 1 [(gogoproto.customtype) = "InputIndex", (gogoproto.nullable) = false]; | ||
} | ||
|
||
message Metadata { |
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 this really related to LLB
definition at all, or controller definition? How about defining
struct {
Definition [][]byte
Metadata map[digest.Digest]MetadataEntry
}
that would be what llb.Marshal
generates and client.Solve
takes as an input. buildctl
can also understand that and override if needed. Then a script generating llb
can also define it. For example, worker constraints need to be defined by the script not by the override in buildctl
.
solver/solver.go
Outdated
@@ -479,6 +485,12 @@ func (s *Solver) getRef(ctx context.Context, g *vertex, index Index) (ref Refere | |||
return false, err | |||
} | |||
if lookupRef != nil { | |||
if md, ok := g.SysMetadata().(pb.MetadataEntry); ok && md.IgnoreCache { |
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.
Doesn't this only work for the last vertex?
I'll rebase today |
0cee46f
to
e76c61a
Compare
solver/jobs.go
Outdated
@@ -210,6 +211,9 @@ func (j *job) getRef(ctx context.Context, v *vertex, index Index) (Reference, er | |||
} | |||
|
|||
func getRef(s VertexSolver, ctx context.Context, v *vertex, index Index, cache InstructionCache) (Reference, error) { | |||
if v.sysMetadata.IgnoreCache { | |||
logrus.Warnf("Unimplemented OpMetadata: IgnoreCache (%s, %s)", v.digest, v.name) |
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.
@tonistiigi
I'll try to implement cache invalidation in another PR, please review the data structure?
e76c61a
to
2d881b2
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.
Some comments. Most could be addressed in a follow-up. Overall looks good
@@ -92,12 +93,12 @@ func (e *ExecOp) Validate() error { | |||
return nil | |||
} | |||
|
|||
func (e *ExecOp) Marshal() ([]byte, error) { | |||
func (e *ExecOp) Marshal() ([]byte, *pb.OpMetadata, 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.
I'd just (*llb.Definition, error)
. This can be follow-up
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.
This function just returns []byte
representation of single Op while llb.Definition
contains [][]byte
representation of multiple Ops.
Should we modify definition of llb.Definition
?
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.
ah, sorry. I mixed this up with https://github.com/moby/buildkit/pull/114/files#diff-23cdf6d75aab7a60db2eaa3d2b59710eR51 . No change required.
@@ -49,9 +53,36 @@ var buildCommand = cli.Command{ | |||
Name: "frontend-opt", | |||
Usage: "Define custom options for frontend", | |||
}, | |||
cli.BoolFlag{ | |||
Name: "no-cache", |
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 remove this, for now, to avoid confusion if it doesn't work yet?
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 put "not implemented" to the command line help string.
This will be soonly implemented.
} | ||
} else { | ||
if clicontext.Bool("no-cache") { | ||
return errors.New("no-cache is not supported for frontends") |
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 map these to frontend-opt
? (follow-up)
client/llb/marshal.go
Outdated
} | ||
return nil | ||
l := make([]byte, 4) |
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.
There is probably no reason to add a length if we just marshal the whole object. Just write/read the protobuf object.
client/llb/state.go
Outdated
@@ -48,48 +48,54 @@ func (s State) Value(k interface{}) interface{} { | |||
return s.ctx.Value(k) | |||
} | |||
|
|||
func (s State) Marshal() ([][]byte, error) { | |||
list, err := marshal(s.Output().Vertex(), nil, map[digest.Digest]struct{}{}, map[Vertex]struct{}{}) | |||
func (s State) Marshal() (Definition, 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.
nit: I like when functions like this return pointers. As it contains slices/maps it shares the memory anyway.
solver/vertex.go
Outdated
@@ -17,6 +18,7 @@ type Vertex interface { | |||
// Sys returns an internal value that is used to execute the vertex. Usually | |||
// this is capured by the operation resolver method during solve. | |||
Sys() interface{} | |||
SysMetadata() pb.OpMetadata |
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.
just Metadata()
, and maybe return solver.Metadata
interface? Atm the solver should be usable without llb definition.
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, updated PR.
However, Solver still has depend on the pb
package:
func (s *Solver) Solve(ctx context.Context, id string, f frontend.Frontend, def *pb.Definition, exp exporter.ExporterInstance, frontendOpt map[string]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.
Ok, yes I think I broke it when I moved the protobuf-to-vertex conversion to the job.load
. Need to think about it later if there is a way around that.
2d881b2
to
282b17f
Compare
@tonistiigi updated |
cache invalidation itself it not implemented yet Signed-off-by: Akihiro Suda <[email protected]>
282b17f
to
f89ffc2
Compare
CI green |
LGTM |
prevent long lived connection reuse
Signed-off-by: Akihiro Suda [email protected]
This PR is an initial step to add per-vertex metadata, of which structure is defined in
solver/pb/ops.proto
:Currently, only
ignore_cache
is implemented.buildctl build --no-cache
setsignore_cache
for all the vertices.Future version will contain worker constraint and so on: #62 (comment) #41 #81
@tonistiigi