diff --git a/internal/idlewatcher/handle_http.go b/internal/idlewatcher/handle_http.go index a0f65ee..49b5b50 100644 --- a/internal/idlewatcher/handle_http.go +++ b/internal/idlewatcher/handle_http.go @@ -90,16 +90,14 @@ func (w *Watcher) wakeFromHTTP(rw http.ResponseWriter, r *http.Request) (shouldN return false } - ctx, cancel := context.WithTimeoutCause(r.Context(), w.cfg.WakeTimeout, errors.New("wake timeout")) - defer cancel() - + ctx := r.Context() if w.cancelled(ctx) { gphttp.ServerError(rw, r, context.Cause(ctx), http.StatusServiceUnavailable) return false } w.l.Trace().Msg("signal received") - err := w.wakeIfStopped() + err := w.Wake(ctx) if err != nil { gphttp.ServerError(rw, r, err) return false diff --git a/internal/idlewatcher/watcher.go b/internal/idlewatcher/watcher.go index dd7ac13..ddfc722 100644 --- a/internal/idlewatcher/watcher.go +++ b/internal/idlewatcher/watcher.go @@ -186,18 +186,17 @@ func (w *Watcher) Key() string { return w.cfg.Key() } -func (w *Watcher) Wake() error { - return w.wakeIfStopped() +func (w *Watcher) Wake(ctx context.Context) error { } -func (w *Watcher) wakeIfStopped() error { +func (w *Watcher) wakeIfStopped(ctx context.Context) error { state := w.state.Load() if state.status == idlewatcher.ContainerStatusRunning { w.l.Debug().Msg("container is already running") return nil } - ctx, cancel := context.WithTimeout(w.task.Context(), w.cfg.WakeTimeout) + ctx, cancel := context.WithTimeout(ctx, w.cfg.WakeTimeout) defer cancel() switch state.status { case idlewatcher.ContainerStatusStopped: