Improve tty error logging when buildkit vertex is unknown (#2188)
* Improve tty error logging when buildkit vertex is unknown Creates a generic "system" group in the tty output which captures buildkit events that report a non-dagger vertex name. This happens currently when using core.#Dockerfile actions since Dagger delegates the LLB generation to buildkit through it's frontend and we don't get meaningful events that we can correlate from Dagger's side Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
@@ -22,13 +22,12 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
Register("Dockerfile", func() Task { return &dockerfileTask{} })
|
||||
Register("Dockerfile", func() Task { return &DockerfileTask{} })
|
||||
}
|
||||
|
||||
type dockerfileTask struct {
|
||||
}
|
||||
type DockerfileTask struct{}
|
||||
|
||||
func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
||||
func (t *DockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
||||
lg := log.Ctx(ctx)
|
||||
auths, err := v.Lookup("auth").Fields()
|
||||
if err != nil {
|
||||
@@ -76,7 +75,7 @@ func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *
|
||||
}
|
||||
dockerfileDef, err = s.Marshal(ctx,
|
||||
llb.Scratch().File(
|
||||
llb.Mkfile("/Dockerfile", 0644, []byte(contents)),
|
||||
llb.Mkfile("/Dockerfile", 0o644, []byte(contents)),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -139,7 +138,7 @@ func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s *
|
||||
})
|
||||
}
|
||||
|
||||
func (t *dockerfileTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
||||
func (t *DockerfileTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
||||
opts := map[string]string{}
|
||||
|
||||
if dockerfilePath := v.Lookup("dockerfile.path"); dockerfilePath.Exists() {
|
||||
|
@@ -28,13 +28,36 @@ var (
|
||||
)
|
||||
|
||||
// State is the state of the task.
|
||||
type State string
|
||||
type State int8
|
||||
|
||||
func (s State) String() string {
|
||||
return [...]string{"computing", "cancelled", "failed", "completed"}[s]
|
||||
}
|
||||
|
||||
func ParseState(s string) (State, error) {
|
||||
switch s {
|
||||
case "computing":
|
||||
return StateComputing, nil
|
||||
case "cancelled":
|
||||
return StateCanceled, nil
|
||||
case "failed":
|
||||
return StateFailed, nil
|
||||
case "completed":
|
||||
return StateCompleted, nil
|
||||
}
|
||||
|
||||
return -1, fmt.Errorf("invalid state [%s]", s)
|
||||
}
|
||||
|
||||
func (s State) CanTransition(t State) bool {
|
||||
return s == StateComputing && s <= t
|
||||
}
|
||||
|
||||
const (
|
||||
StateComputing = State("computing")
|
||||
StateCanceled = State("canceled")
|
||||
StateFailed = State("failed")
|
||||
StateCompleted = State("completed")
|
||||
StateComputing State = iota
|
||||
StateCanceled
|
||||
StateFailed
|
||||
StateCompleted
|
||||
)
|
||||
|
||||
type NewFunc func() Task
|
||||
|
Reference in New Issue
Block a user