From e5a6dea10c58b1bd5bc06307a2fd75bbc543c473 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 17 Jul 2024 10:09:09 +0200 Subject: [PATCH] fix: catch ctrl-c again; less cryptic logging --- pkg/upstream/stack/stack.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/upstream/stack/stack.go b/pkg/upstream/stack/stack.go index 8576f61f..f38f5e39 100644 --- a/pkg/upstream/stack/stack.go +++ b/pkg/upstream/stack/stack.go @@ -175,6 +175,7 @@ func pruneServices(ctx context.Context, cl *dockerClient.Client, namespace conve pruneServices = append(pruneServices, service) } } + removeServices(ctx, cl, pruneServices) } @@ -255,10 +256,12 @@ func deployCompose(ctx context.Context, cl *dockerClient.Client, opts Deploy, co log.Infof("waiting for %s to deploy... please hold 🤚", appName) - if err := waitOnServices(ctx, cl, serviceIDs, appName); err == nil { - log.Infof("successfully deployed %s", appName) + if err := waitOnServices(ctx, cl, serviceIDs, appName); err != nil { + return err } + log.Infof("successfully deployed %s", appName) + return nil } @@ -395,7 +398,7 @@ func deployServices( ) if service, exists := existingServiceMap[name]; exists { - log.Infof("updating service %s (id: %s)", name, service.ID) + log.Infof("updating %s", name) updateOpts := types.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth} @@ -430,7 +433,7 @@ func deployServices( response, err := cl.ServiceUpdate(ctx, service.ID, service.Version, serviceSpec, updateOpts) if err != nil { - return nil, errors.Wrapf(err, "failed to update service %s", name) + return nil, errors.Wrapf(err, "failed to update %s", name) } for _, warning := range response.Warnings { @@ -439,7 +442,7 @@ func deployServices( serviceIDs = append(serviceIDs, service.ID) } else { - log.Infof("creating service %s", name) + log.Infof("creating %s", name) createOpts := types.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth} @@ -450,7 +453,7 @@ func deployServices( serviceCreateResponse, err := cl.ServiceCreate(ctx, serviceSpec, createOpts) if err != nil { - return nil, errors.Wrapf(err, "failed to create service %s", name) + return nil, errors.Wrapf(err, "failed to create %s", name) } serviceIDs = append(serviceIDs, serviceCreateResponse.ID) @@ -510,13 +513,14 @@ func WaitOnService(ctx context.Context, cl *dockerClient.Client, serviceID, appN case err := <-errChan: return err case <-sigintChannel: - return fmt.Errorf(fmt.Sprintf(` + return fmt.Errorf(` Not waiting for %s to deploy. The deployment is ongoing... If you want to stop the deployment, try: - abra app undeploy %s`, appName, appName)) + + abra app undeploy %s`, appName, appName) case <-time.After(timeout): - return fmt.Errorf(fmt.Sprintf(` + return fmt.Errorf(` %s has not converged (%s second timeout reached). This does not necessarily mean your deployment has failed, it may just be that @@ -530,7 +534,7 @@ You can track latest deployment status with: And inspect the logs with: abra app logs %s -`, appName, timeout, appName, appName)) +`, appName, timeout, appName, appName) } } @@ -548,7 +552,7 @@ func GetStacks(cl *dockerClient.Client) ([]*formatter.Stack, error) { labels := service.Spec.Labels name, ok := labels[convert.LabelNamespace] if !ok { - return nil, errors.Errorf("cannot get label %s for service %s", + return nil, errors.Errorf("cannot get label %s for %s", convert.LabelNamespace, service.ID) } ztack, ok := m[name]