Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progress: minor correctness fixes #10871

Merged
merged 1 commit into from Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/compose/convergence.go
Expand Up @@ -324,7 +324,11 @@
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
for {
<-ticker.C
select {
case <-ticker.C:
case <-ctx.Done():
return nil

Check warning on line 330 in pkg/compose/convergence.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/convergence.go#L329-L330

Added lines #L329 - L330 were not covered by tests
}
switch config.Condition {
case ServiceConditionRunningOrHealthy:
healthy, err := s.isServiceHealthy(ctx, waitingFor, true)
Expand Down
15 changes: 13 additions & 2 deletions pkg/progress/tty.go
Expand Up @@ -73,16 +73,25 @@
func (w *ttyWriter) Event(e Event) {
w.mtx.Lock()
defer w.mtx.Unlock()
w.event(e)
}

func (w *ttyWriter) event(e Event) {
if !utils.StringContains(w.eventIDs, e.ID) {
w.eventIDs = append(w.eventIDs, e.ID)
}
if _, ok := w.events[e.ID]; ok {
last := w.events[e.ID]
switch e.Status {
case Done, Error, Warning:
if last.Status != e.Status {
if last.endTime.IsZero() {
last.stop()
}
case Working:
if !last.endTime.IsZero() {
// already done, don't overwrite
return
}

Check warning on line 94 in pkg/progress/tty.go

View check run for this annotation

Codecov / codecov/patch

pkg/progress/tty.go#L90-L94

Added lines #L90 - L94 were not covered by tests
}
last.Status = e.Status
last.Text = e.Text
Expand All @@ -106,8 +115,10 @@
}

func (w *ttyWriter) Events(events []Event) {
w.mtx.Lock()
defer w.mtx.Unlock()

Check warning on line 119 in pkg/progress/tty.go

View check run for this annotation

Codecov / codecov/patch

pkg/progress/tty.go#L118-L119

Added lines #L118 - L119 were not covered by tests
for _, e := range events {
w.Event(e)
w.event(e)

Check warning on line 121 in pkg/progress/tty.go

View check run for this annotation

Codecov / codecov/patch

pkg/progress/tty.go#L121

Added line #L121 was not covered by tests
}
}

Expand Down