|
|
@@ -214,13 +214,13 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
- expected []string
|
|
|
+ expected = utils.NewSet[string]()
|
|
|
watched = map[string]int{}
|
|
|
replaced []string
|
|
|
)
|
|
|
for _, c := range containers {
|
|
|
if isRequired(c) {
|
|
|
- expected = append(expected, c.ID)
|
|
|
+ expected.Add(c.ID)
|
|
|
}
|
|
|
watched[c.ID] = 0
|
|
|
}
|
|
|
@@ -242,7 +242,7 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
// be able to inspect in time before they're gone from the
|
|
|
// API, so just remove the watch without erroring
|
|
|
delete(watched, event.Container)
|
|
|
- expected = utils.Remove(expected, event.Container)
|
|
|
+ expected.Remove(event.Container)
|
|
|
return nil
|
|
|
}
|
|
|
return err
|
|
|
@@ -253,7 +253,6 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
Labels: inspected.Config.Labels,
|
|
|
}
|
|
|
name := getContainerNameWithoutProject(container)
|
|
|
-
|
|
|
service := container.Labels[api.ServiceLabel]
|
|
|
switch event.Status {
|
|
|
case "stop":
|
|
|
@@ -278,7 +277,7 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
}
|
|
|
|
|
|
delete(watched, container.ID)
|
|
|
- expected = utils.Remove(expected, container.ID)
|
|
|
+ expected.Remove(container.ID)
|
|
|
case "die":
|
|
|
restarted := watched[container.ID]
|
|
|
watched[container.ID] = restarted + 1
|
|
|
@@ -308,7 +307,7 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
if !willRestart {
|
|
|
// we're done with this one
|
|
|
delete(watched, container.ID)
|
|
|
- expected = utils.Remove(expected, container.ID)
|
|
|
+ expected.Remove(container.ID)
|
|
|
}
|
|
|
case "start":
|
|
|
count, ok := watched[container.ID]
|
|
|
@@ -316,7 +315,7 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
if !ok {
|
|
|
// A new container has just been added to service by scale
|
|
|
watched[container.ID] = 0
|
|
|
- expected = append(expected, container.ID)
|
|
|
+ expected.Add(container.ID)
|
|
|
mustAttach = true
|
|
|
}
|
|
|
if mustAttach {
|
|
|
@@ -333,17 +332,15 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- if utils.StringContains(expected, id) {
|
|
|
- expected = append(expected, inspected.ID)
|
|
|
+ if expected.Has(id) {
|
|
|
+ expected.Add(inspected.ID)
|
|
|
+ expected.Add(container.ID)
|
|
|
}
|
|
|
watched[container.ID] = 1
|
|
|
- if utils.Contains(expected, id) {
|
|
|
- expected = append(expected, container.ID)
|
|
|
- }
|
|
|
} else if ofInterest(container) {
|
|
|
watched[container.ID] = 1
|
|
|
if isRequired(container) {
|
|
|
- expected = append(expected, container.ID)
|
|
|
+ expected.Add(container.ID)
|
|
|
}
|
|
|
}
|
|
|
}
|