Skip to content

Commit

Permalink
Add support for weak ProgressGroup membership.
Browse files Browse the repository at this point in the history
A ProgressGroup will now only be displayed if a vertex member marked as
non-weak has started.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
  • Loading branch information
sipsma committed Feb 25, 2022
1 parent 77e383d commit cc1499e
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 176 deletions.
4 changes: 2 additions & 2 deletions client/llb/state.go
Expand Up @@ -598,9 +598,9 @@ func LocalUniqueID(v string) ConstraintsOpt {
})
}

func ProgressGroup(id, name string) ConstraintsOpt {
func ProgressGroup(id, name string, weak bool) ConstraintsOpt {
return constraintsOptFunc(func(c *Constraints) {
c.Metadata.ProgressGroup = &pb.ProgressGroup{Id: id, Name: name}
c.Metadata.ProgressGroup = &pb.ProgressGroup{Id: id, Name: name, Weak: weak}
})
}

Expand Down
15 changes: 12 additions & 3 deletions frontend/dockerfile/dockerfile2llb/convert.go
Expand Up @@ -1072,11 +1072,20 @@ func dispatchCopyFileOp(d *dispatchState, cfg copyConfig) error {
}

if cfg.opt.llbCaps.Supports(pb.CapMergeOp) == nil && cfg.link && cfg.chmod == "" {
pgID := identity.NewID()
d.cmdIndex-- // prefixCommand increases it
fileOpt = append(fileOpt, llb.ProgressGroup(identity.NewID(), prefixCommand(d, name, d.prefixPlatform, &platform, env)))
pgName := prefixCommand(d, name, d.prefixPlatform, &platform, env)

var copyOpts []llb.ConstraintsOpt
copy(copyOpts, fileOpt)
copyOpts = append(copyOpts, llb.ProgressGroup(pgID, pgName, true))

var mergeOpts []llb.ConstraintsOpt
copy(mergeOpts, fileOpt)
d.cmdIndex--
mergeOpt := append(fileOpt, llb.WithCustomName(prefixCommand(d, "LINK "+name, d.prefixPlatform, &platform, env)))
d.state = d.state.WithOutput(llb.Merge([]llb.State{d.state, llb.Scratch().File(a, fileOpt...)}, mergeOpt...).Output())
mergeOpts = append(mergeOpts, llb.ProgressGroup(pgID, pgName, false), llb.WithCustomName(prefixCommand(d, "LINK "+name, d.prefixPlatform, &platform, env)))

d.state = d.state.WithOutput(llb.Merge([]llb.State{d.state, llb.Scratch().File(a, copyOpts...)}, mergeOpts...).Output())
} else {
d.state = d.state.File(a, fileOpt...)
}
Expand Down

0 comments on commit cc1499e

Please sign in to comment.