Skip to content

Commit

Permalink
fix(compose): race condition (#2842)
Browse files Browse the repository at this point in the history
Fix a race condition in compose module when setting up multiple
containers.
  • Loading branch information
stevenh authored Oct 21, 2024
1 parent 5a4eec1 commit e945309
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 @@ -379,6 +379,7 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err erro

// Lookup the containers for each service and connect them
// to the reaper if needed.
var termSignalsMtx sync.Mutex
for _, srv := range d.project.Services {
srv := srv
errGrpContainers.Go(func() error {
Expand All @@ -394,6 +395,9 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err erro
}

dc.SetTerminationSignal(termSignal)

termSignalsMtx.Lock()
defer termSignalsMtx.Unlock()
termSignals = append(termSignals, termSignal)
}

Expand Down

0 comments on commit e945309

Please sign in to comment.