From a3b1fae96d972393d32a61e314970ba4e025c317 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 20 May 2024 16:38:01 -0700 Subject: [PATCH] driver: handle nil logger for bootstrap resolveNode methods can call with nil logger. Although the results should already be cached now in resolver this makes the protection more explicit. Signed-off-by: Tonis Tiigi (cherry picked from commit 035236a5ed334fdbaa28b976c473ab4161cd4cc8) --- driver/driver.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index d31ce82dda4..ec88f1a4eab 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -83,6 +83,11 @@ func ParseBuilderName(name string) (string, error) { func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Writer) (*client.Client, error) { try := 0 + logger := discardLogger + if pw != nil { + logger = pw.Write + } + for { info, err := d.Info(ctx) if err != nil { @@ -93,7 +98,7 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write if try > 2 { return nil, errors.Errorf("failed to bootstrap %T driver in attempts", d) } - if err := d.Bootstrap(ctx, pw.Write); err != nil { + if err := d.Bootstrap(ctx, logger); err != nil { return nil, err } } @@ -109,6 +114,8 @@ func Boot(ctx, clientContext context.Context, d *DriverHandle, pw progress.Write } } +func discardLogger(*client.SolveStatus) {} + func historyAPISupported(ctx context.Context, c *client.Client) bool { cl, err := c.ControlClient().ListenBuildHistory(ctx, &controlapi.BuildHistoryRequest{ ActiveOnly: true,