MCPcopy
hub / github.com/docker/compose / emitRunningEvents

Function emitRunningEvents

pkg/compose/observed_state.go:220–235  ·  view source on GitHub ↗

emitRunningEvents emits "Running" progress events for containers that are already running and have no operations planned for them. This matches the previous behavior where convergence.ensureService emitted runningEvent for up-to-date containers. Iterates project.Services (not observed.Containers) s

(project *types.Project, observed *ObservedState, plan *Plan, events api.EventProcessor)

Source from the content-addressed store, hash-verified

218// disabled services (e.g. dependencies untouched by `compose run --no-deps`)
219// are not falsely reported as Running — see issue 13882.
220func emitRunningEvents(project *types.Project, observed *ObservedState, plan *Plan, events api.EventProcessor) {
221 planned := map[string]bool{}
222 for _, node := range plan.Nodes {
223 if node.Operation.Container != nil {
224 planned[node.Operation.Container.ID] = true
225 }
226 }
227
228 for _, svc := range project.Services {
229 for _, oc := range observed.Containers[svc.Name] {
230 if oc.State == container.StateRunning && !planned[oc.ID] {
231 events.On(newEvent("Container "+oc.Name, api.Done, api.StatusRunning))
232 }
233 }
234 }
235}
236
237// orphanNames returns the names of orphaned containers as a comma-separated string.
238func (s *ObservedState) orphanNames() string {

Callers 2

TestEmitRunningEventsFunction · 0.85
createMethod · 0.85

Calls 2

newEventFunction · 0.85
OnMethod · 0.65

Tested by 1

TestEmitRunningEventsFunction · 0.68