Skip to content

Commit 372e67f

Browse files
committedAug 12, 2024·
Merge branch 'main' into v1
* main: fix: readiness hook back off (#2718) fix: skip unhealthy (#2717) fix: filter context errors from log production (#2715)
2 parents eaa90db + 8dbd4cd commit 372e67f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed
 

‎container_started.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,16 @@ func (c *DockerContainer) StopLogProduction() error {
165165

166166
c.logProductionWaitGroup.Wait()
167167

168-
return <-c.logProductionError
168+
if err := <-c.logProductionError; err != nil {
169+
if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
170+
// Returning context errors is not useful for the consumer.
171+
return nil
172+
}
173+
174+
return err
175+
}
176+
177+
return nil
169178
}
170179

171180
func (c *DockerContainer) WithLogProductionTimeout(timeout time.Duration) {

‎lifecycle_ready.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ var defaultReadinessHook = func() LifecycleHooks {
1717
func(ctx context.Context, c StartedContainer) error {
1818
// wait until all the exposed ports are mapped:
1919
// it will be ready when all the exposed ports are mapped,
20-
// checking every 50ms, up to 5s, and failing if all the
21-
// exposed ports are not mapped in that time.
20+
// checking every 50ms, up to 1s, and failing if all the
21+
// exposed ports are not mapped in 5s.
2222
dockerContainer := c.(*DockerContainer)
2323

2424
b := backoff.NewExponentialBackOff()
2525

2626
b.InitialInterval = 50 * time.Millisecond
27-
b.MaxElapsedTime = 1 * time.Second
28-
b.MaxInterval = 5 * time.Second
27+
b.MaxElapsedTime = 5 * time.Second
28+
b.MaxInterval = time.Duration(float64(time.Second) * backoff.DefaultRandomizationFactor)
2929

3030
err := backoff.RetryNotify(
3131
func() error {

‎reaper_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func TestReaperReusedIfHealthy(t *testing.T) {
210210
t.Skip("Ryuk is disabled, skipping test")
211211
}
212212

213-
SkipIfContainerRuntimeIsNotHealthy(&testing.T{})
213+
SkipIfContainerRuntimeIsNotHealthy(t)
214214

215215
ctx := context.Background()
216216

@@ -240,7 +240,7 @@ func TestRecreateReaperIfTerminated(t *testing.T) {
240240
t.Skip("Ryuk is disabled, skipping test")
241241
}
242242

243-
SkipIfContainerRuntimeIsNotHealthy(&testing.T{})
243+
SkipIfContainerRuntimeIsNotHealthy(t)
244244

245245
ctx := context.Background()
246246

0 commit comments

Comments
 (0)
Please sign in to comment.