mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
fix: panic when pulling non-existent image
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
dockerclient "github.com/docker/docker/client"
|
dockerclient "github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"uncloud/internal/api"
|
"uncloud/internal/api"
|
||||||
@@ -127,14 +128,15 @@ func (cli *Client) pullImageWithProgress(ctx context.Context, image, machineName
|
|||||||
|
|
||||||
pullCh, err := cli.Docker.PullImage(ctx, image)
|
pullCh, err := cli.Docker.PullImage(ctx, image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
statusErr := status.Convert(err)
|
||||||
pw.Event(progress.Event{
|
pw.Event(progress.Event{
|
||||||
ID: eventID,
|
ID: eventID,
|
||||||
ParentID: parentEventID,
|
ParentID: parentEventID,
|
||||||
Text: "Error",
|
Text: "Error",
|
||||||
Status: progress.Error,
|
Status: progress.Error,
|
||||||
StatusText: errors.Unwrap(err).Error(),
|
StatusText: statusErr.Message(),
|
||||||
})
|
})
|
||||||
return fmt.Errorf("pull image: %w", err)
|
return fmt.Errorf("pull image: %w", errors.New(statusErr.Message()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for pull to complete by reading all progress messages and converting them to events.
|
// Wait for pull to complete by reading all progress messages and converting them to events.
|
||||||
@@ -147,14 +149,15 @@ func (cli *Client) pullImageWithProgress(ctx context.Context, image, machineName
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
statusErr := status.Convert(err)
|
||||||
pw.Event(progress.Event{
|
pw.Event(progress.Event{
|
||||||
ID: eventID,
|
ID: eventID,
|
||||||
ParentID: parentEventID,
|
ParentID: parentEventID,
|
||||||
Text: "Error",
|
Text: "Error",
|
||||||
Status: progress.Error,
|
Status: progress.Error,
|
||||||
StatusText: errors.Unwrap(err).Error(),
|
StatusText: statusErr.Message(),
|
||||||
})
|
})
|
||||||
return fmt.Errorf("pull image: %w", err)
|
return fmt.Errorf("pull image: %w", errors.New(statusErr.Message()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add like in compose: --quiet-pull Pull without printing progress information
|
// TODO: add like in compose: --quiet-pull Pull without printing progress information
|
||||||
|
|||||||
Reference in New Issue
Block a user