diff --git a/pkg/compose/convergence.go b/pkg/compose/convergence.go index 7eb40793..401abbe4 100644 --- a/pkg/compose/convergence.go +++ b/pkg/compose/convergence.go @@ -266,7 +266,21 @@ const ServiceConditionRunningOrHealthy = "running_or_healthy" func (s *composeService) waitDependencies(ctx context.Context, project *types.Project, dependencies types.DependsOnConfig) error { eg, _ := errgroup.WithContext(ctx) + w := progress.ContextWriter(ctx) for dep, config := range dependencies { + if config.Condition == types.ServiceConditionStarted { + // already managed by InDependencyOrder + return nil + } + + containers, err := s.getContainers(ctx, project.Name, oneOffExclude, false, dep) + if err != nil { + return err + } + for _, container := range containers { + w.Event(progress.Waiting(getContainerProgressName(container))) + } + dep, config := dep, config eg.Go(func() error { ticker := time.NewTicker(500 * time.Millisecond) @@ -280,6 +294,9 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr return err } if healthy { + for _, container := range containers { + w.Event(progress.Healthy(getContainerProgressName(container))) + } return nil } case types.ServiceConditionHealthy: @@ -288,6 +305,9 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr return err } if healthy { + for _, container := range containers { + w.Event(progress.Healthy(getContainerProgressName(container))) + } return nil } case types.ServiceConditionCompletedSuccessfully: @@ -296,14 +316,14 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr return err } if exited { + for _, container := range containers { + w.Event(progress.Exited(getContainerProgressName(container))) + } if code != 0 { return fmt.Errorf("service %q didn't completed successfully: exit %d", dep, code) } return nil } - case types.ServiceConditionStarted: - // already managed by InDependencyOrder - return nil default: logrus.Warnf("unsupported depends_on condition: %s", config.Condition) return nil diff --git a/pkg/progress/event.go b/pkg/progress/event.go index 979a0e53..5a013a8b 100644 --- a/pkg/progress/event.go +++ b/pkg/progress/event.go @@ -68,6 +68,21 @@ func StartedEvent(ID string) Event { return NewEvent(ID, Done, "Started") } +// Waiting creates a new waiting event +func Waiting(ID string) Event { + return NewEvent(ID, Working, "Waiting") +} + +// Healthy creates a new healthy event +func Healthy(ID string) Event { + return NewEvent(ID, Done, "Healthy") +} + +// Exited creates a new exited event +func Exited(ID string) Event { + return NewEvent(ID, Done, "Exited") +} + // RestartingEvent creates a new Restarting in progress Event func RestartingEvent(ID string) Event { return NewEvent(ID, Working, "Restarting")