Skip to content

Commit

Permalink
fix(compose): avoid race conditions when caching services
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed May 3, 2024
1 parent da2d5c5 commit d702774
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/compose/compose_api.go
Original file line number Diff line number Diff line change
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 d702774

Please sign in to comment.