Skip to content

Commit

Permalink
fix(compose): avoid race conditions when caching services (#2528)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed May 3, 2024
1 parent da2d5c5 commit 5e97046
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/compose/compose_api.go
Expand Up @@ -370,6 +370,8 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) error {
}()
}

d.containersLock.Lock()
defer d.containersLock.Unlock()
d.containers[srv.Name] = dc

return nil
Expand Down Expand Up @@ -398,6 +400,8 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) error {
}

// cache all the containers on compose.up
d.containersLock.Lock()
defer d.containersLock.Unlock()
d.containers[svc] = target

return strategy.WaitUntilReady(errGrpCtx, target)
Expand Down

0 comments on commit 5e97046

Please sign in to comment.