Skip to content

Commit

Permalink
use service.stop to stop dependent containers
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof authored and glours committed Nov 25, 2024
1 parent 43ac1e3 commit 2d148fa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/compose/convergence.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,18 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
}

func (c *convergence) stopDependentContainers(ctx context.Context, project *types.Project, service types.ServiceConfig) error {
w := progress.ContextWriter(ctx)
// Stop dependent containers, so they will be restarted after service is re-created
dependents := project.GetDependentsForService(service)
err := c.service.stop(ctx, project.Name, api.StopOptions{
Services: dependents,
Project: project,
})
if err != nil {
return err
}

for _, name := range dependents {
dependents := c.getObservedState(name)
err := c.service.stopContainers(ctx, w, &service, dependents, nil)
if err != nil {
return err
}
for i, dependent := range dependents {
dependent.State = ContainerExited
dependents[i] = dependent
Expand Down

0 comments on commit 2d148fa

Please sign in to comment.