monitor: support step-by-step breakpoint debugger
This commit adds a set of commands to monitor for enabling breakpoint debugger. This is implemented based on the walker utility for step-by-step LLB inspection. For each vertex and breakpoint, monitor calls Solve API so the user can enter to the debugger container on each vertex for inspection. User can enter to the breakpoint debugger mode by --invoke=debug-step flag. Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
@@ -354,7 +354,11 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
|
||||
logrus.Debug("propagating stdin close")
|
||||
return nil
|
||||
})
|
||||
|
||||
if options.invoke != nil && options.invoke.invokeFlag == "debug-step" {
|
||||
// Special mode where we don't get the result but get only the build definition.
|
||||
// In this mode, Build() doesn't perform the build therefore always fails.
|
||||
opts.Debug = true
|
||||
}
|
||||
ref, resp, err = c.Build(ctx, *opts, pr, printer)
|
||||
if err != nil {
|
||||
var be *controllererrors.BuildError
|
||||
@@ -680,7 +684,7 @@ type invokeConfig struct {
|
||||
|
||||
func (cfg *invokeConfig) needsMonitor(retErr error) bool {
|
||||
switch cfg.invokeFlag {
|
||||
case "debug-shell":
|
||||
case "debug-shell", "debug-step":
|
||||
return true
|
||||
case "on-error":
|
||||
return retErr != nil
|
||||
@@ -695,7 +699,7 @@ func parseInvokeConfig(invoke string) (cfg invokeConfig, err error) {
|
||||
switch invoke {
|
||||
case "default", "debug-shell":
|
||||
return cfg, nil
|
||||
case "on-error":
|
||||
case "on-error", "debug-step":
|
||||
// NOTE: we overwrite the command to run because the original one should fail on the failed step.
|
||||
// TODO: make this configurable via flags or restorable from LLB.
|
||||
// Discussion: https://github.com/docker/buildx/pull/1640#discussion_r1113295900
|
||||
|
||||
Reference in New Issue
Block a user