mirror of https://github.com/docker/compose.git
progress: minor correctness fixes (#10871)
* When waiting for dependencies, `select` on the context as well as the ticker * Write multiple progress events "transactionally" (i.e. hold the lock for the duration to avoid other events being interleaved) * Do not change "finished" steps back to "in progress" to prevent flickering Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
d7b1972d5e
commit
80856eacaf
|
@ -324,7 +324,11 @@ func (s *composeService) waitDependencies(ctx context.Context, project *types.Pr
|
||||||
ticker := time.NewTicker(500 * time.Millisecond)
|
ticker := time.NewTicker(500 * time.Millisecond)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
<-ticker.C
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil
|
||||||
|
}
|
||||||
switch config.Condition {
|
switch config.Condition {
|
||||||
case ServiceConditionRunningOrHealthy:
|
case ServiceConditionRunningOrHealthy:
|
||||||
healthy, err := s.isServiceHealthy(ctx, waitingFor, true)
|
healthy, err := s.isServiceHealthy(ctx, waitingFor, true)
|
||||||
|
|
|
@ -73,6 +73,10 @@ func (w *ttyWriter) Stop() {
|
||||||
func (w *ttyWriter) Event(e Event) {
|
func (w *ttyWriter) Event(e Event) {
|
||||||
w.mtx.Lock()
|
w.mtx.Lock()
|
||||||
defer w.mtx.Unlock()
|
defer w.mtx.Unlock()
|
||||||
|
w.event(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *ttyWriter) event(e Event) {
|
||||||
if !utils.StringContains(w.eventIDs, e.ID) {
|
if !utils.StringContains(w.eventIDs, e.ID) {
|
||||||
w.eventIDs = append(w.eventIDs, e.ID)
|
w.eventIDs = append(w.eventIDs, e.ID)
|
||||||
}
|
}
|
||||||
|
@ -80,9 +84,14 @@ func (w *ttyWriter) Event(e Event) {
|
||||||
last := w.events[e.ID]
|
last := w.events[e.ID]
|
||||||
switch e.Status {
|
switch e.Status {
|
||||||
case Done, Error, Warning:
|
case Done, Error, Warning:
|
||||||
if last.Status != e.Status {
|
if last.endTime.IsZero() {
|
||||||
last.stop()
|
last.stop()
|
||||||
}
|
}
|
||||||
|
case Working:
|
||||||
|
if !last.endTime.IsZero() {
|
||||||
|
// already done, don't overwrite
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
last.Status = e.Status
|
last.Status = e.Status
|
||||||
last.Text = e.Text
|
last.Text = e.Text
|
||||||
|
@ -106,8 +115,10 @@ func (w *ttyWriter) Event(e Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ttyWriter) Events(events []Event) {
|
func (w *ttyWriter) Events(events []Event) {
|
||||||
|
w.mtx.Lock()
|
||||||
|
defer w.mtx.Unlock()
|
||||||
for _, e := range events {
|
for _, e := range events {
|
||||||
w.Event(e)
|
w.event(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue