Compare commits

...

7 Commits

Author SHA1 Message Date
412e366200 Merge remote-tracking branch 'coopcloud/main' into add-waiting-interrupt-handling
All checks were successful
continuous-integration/drone/pr Build is passing
2023-08-04 19:08:12 +01:00
f5cadcc5f0 Further changes to messages.
All checks were successful
continuous-integration/drone/pr Build is passing
2023-08-04 19:05:49 +01:00
ae1a6c45f9 Merge branch 'add-waiting-interrupt-handling' of ssh://git.coopcloud.tech:2222/rix/abra into add-waiting-interrupt-handling 2023-08-01 12:53:36 +01:00
65fdaf43cc Attempt to replace the deploy completed message.
All checks were successful
continuous-integration/drone/pr Build is passing
2023-08-01 12:50:15 +01:00
2d135329bb Change message when starting to poll for deployment status. 2023-07-31 22:45:44 +01:00
3e95319969 Add os hook for interrupt signal while waiting for service to converge. 2023-07-31 22:45:44 +01:00
1208438cba Add os hook for interrupt signal while waiting for service to converge.
All checks were successful
continuous-integration/drone/pr Build is passing
2023-07-30 12:28:11 +01:00

View File

@ -5,7 +5,8 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"strings" "os"
"os/signal"
"time" "time"
"coopcloud.tech/abra/pkg/upstream/convert" "coopcloud.tech/abra/pkg/upstream/convert"
@ -414,7 +415,7 @@ func deployServices(
return nil return nil
} }
logrus.Infof("waiting for services to converge: %s", strings.Join(serviceNames, ", ")) logrus.Infof("Starting to poll for deployment status for: %s", appName)
ch := make(chan error, len(serviceIDs)) ch := make(chan error, len(serviceIDs))
for serviceID, serviceName := range serviceIDs { for serviceID, serviceName := range serviceIDs {
logrus.Debugf("waiting on %s to converge", serviceName) logrus.Debugf("waiting on %s to converge", serviceName)
@ -431,7 +432,7 @@ func deployServices(
logrus.Debugf("assuming %s converged successfully", serviceID) logrus.Debugf("assuming %s converged successfully", serviceID)
} }
logrus.Info("services converged 👌") logrus.Infof("Successfully deployed %s", appName)
return nil return nil
} }
@ -454,6 +455,10 @@ func WaitOnService(ctx context.Context, cl *dockerClient.Client, serviceID, appN
errChan := make(chan error, 1) errChan := make(chan error, 1)
pipeReader, pipeWriter := io.Pipe() pipeReader, pipeWriter := io.Pipe()
sigintChannel := make(chan os.Signal, 1)
signal.Notify(sigintChannel, os.Interrupt)
defer signal.Stop(sigintChannel)
go func() { go func() {
errChan <- progress.ServiceProgress(ctx, cl, serviceID, pipeWriter) errChan <- progress.ServiceProgress(ctx, cl, serviceID, pipeWriter)
}() }()
@ -465,6 +470,14 @@ func WaitOnService(ctx context.Context, cl *dockerClient.Client, serviceID, appN
select { select {
case err := <-errChan: case err := <-errChan:
return err return err
case <-sigintChannel:
return fmt.Errorf(fmt.Sprintf(`
Cancelling polling for %s, deployment is still continuing.
If you want to stop the deployment try:
abra app undeploy %s
`, appName, appName))
case <-time.After(timeout): case <-time.After(timeout):
return fmt.Errorf(fmt.Sprintf(` return fmt.Errorf(fmt.Sprintf(`
%s has not converged (%s second timeout reached). %s has not converged (%s second timeout reached).
@ -481,7 +494,7 @@ And inspect the logs with:
abra app logs %s abra app logs %s
If a service is failing to even start, try smoke out the error with: If a service is failing to even start, try to smoke out the error with:
abra app errors --watch %s abra app errors --watch %s