From cb06091f8ce2c8b7e217135a920a396f5848fdaf Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 17 Jan 2024 18:36:06 -0700 Subject: [PATCH] Don't panic during acorn local start Signed-off-by: Darren Shepherd --- pkg/local/docker.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/local/docker.go b/pkg/local/docker.go index 23f296a3e..33076a08a 100644 --- a/pkg/local/docker.go +++ b/pkg/local/docker.go @@ -187,6 +187,19 @@ func (c *Container) Upgrade(ctx context.Context, ignoreLocal bool) (string, stri return "", "", err } + if con.State == nil || !con.State.Running { + if err := c.Start(ctx); err != nil { + return "", "", err + } + if err := c.Wait(ctx); err != nil { + return "", "", err + } + con, err = c.c.ContainerInspect(ctx, ContainerName) + if err != nil { + return "", "", err + } + } + if con.Config.Image == system.DefaultImage() || (ignoreLocal && con.Config.Image == "localdev") { return con.ID, con.NetworkSettings.Ports["6443/tcp"][0].HostPort, c.Start(ctx) } @@ -216,7 +229,7 @@ func (c *Container) Wait(ctx context.Context) error { } imageStatus.Success() - conStatus := pb.New("Container created") + conStatus := pb.New("Container created (to delete \"acorn local rm\")") conStatus.Infof("Creating") for { @@ -236,7 +249,7 @@ func (c *Container) Wait(ctx context.Context) error { } } - running := pb.New("Container running") + running := pb.New("Container running (to stop \"acorn local stop\")") running.Infof("Starting") var port string