Skip to content

Commit f0c5794

Browse files
authored
Merge pull request #5600 from twz123/containerd-wait-failed-msg
Include last error when waiting for containerd failed
2 parents b4ce4fb + f6367a9 commit f0c5794

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/component/worker/containerd/component.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,28 @@ func (c *Component) Start(ctx context.Context) error {
179179
go c.watchDropinConfigs(ctx)
180180

181181
log.Debug("Waiting for containerd")
182-
return wait.ExponentialBackoffWithContext(ctx, wait.Backoff{
182+
var lastErr error
183+
err := wait.ExponentialBackoffWithContext(ctx, wait.Backoff{
183184
Duration: 100 * time.Millisecond, Factor: 1.2, Jitter: 0.05, Steps: 30,
184185
}, func(ctx context.Context) (bool, error) {
185186
rt := containerruntime.NewContainerRuntime(runtimeEndpoint)
186-
if err := rt.Ping(ctx); err != nil {
187-
log.WithError(err).Debug("Failed to ping containerd")
187+
if lastErr = rt.Ping(ctx); lastErr != nil {
188+
log.WithError(lastErr).Debug("Failed to ping containerd")
188189
return false, nil
189190
}
190191

191192
log.Debug("Successfully pinged containerd")
192193
return true, nil
193194
})
195+
196+
if err != nil {
197+
if lastErr == nil {
198+
return fmt.Errorf("failed to ping containerd: %w", err)
199+
}
200+
return fmt.Errorf("failed to ping containerd: %w (%w)", err, lastErr)
201+
}
202+
203+
return nil
194204
}
195205

196206
func (c *Component) windowsStart(_ context.Context) error {

0 commit comments

Comments
 (0)