From 95b48ff00d66d61d5454360ec632b736fe27f5f9 Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Tue, 22 Aug 2023 11:13:01 +0200 Subject: [PATCH] Also clean up when cancelling experiment --- webhosting-operator/pkg/experiment/scenario/basic/basic.go | 6 ++---- .../pkg/experiment/scenario/reconcile/reconcile.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/webhosting-operator/pkg/experiment/scenario/basic/basic.go b/webhosting-operator/pkg/experiment/scenario/basic/basic.go index fe5ca304..f240a723 100644 --- a/webhosting-operator/pkg/experiment/scenario/basic/basic.go +++ b/webhosting-operator/pkg/experiment/scenario/basic/basic.go @@ -172,13 +172,11 @@ func (s *scenario) Start(ctx context.Context) error { select { case <-ctx.Done(): - log.Info("Scenario cancelled") - return ctx.Err() + log.Info("Scenario cancelled, cleaning up") case <-time.After(15 * time.Minute): + log.Info("Scenario finished, cleaning up") } - log.Info("Scenario finished, cleaning up") - cleanupCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() diff --git a/webhosting-operator/pkg/experiment/scenario/reconcile/reconcile.go b/webhosting-operator/pkg/experiment/scenario/reconcile/reconcile.go index 50aa04e6..24d5409c 100644 --- a/webhosting-operator/pkg/experiment/scenario/reconcile/reconcile.go +++ b/webhosting-operator/pkg/experiment/scenario/reconcile/reconcile.go @@ -136,13 +136,11 @@ func (s *scenario) Start(ctx context.Context) error { select { case <-ctx.Done(): - log.Info("Scenario cancelled") - return ctx.Err() + log.Info("Scenario cancelled, cleaning up") case <-time.After(15 * time.Minute): + log.Info("Scenario finished, cleaning up") } - log.Info("Scenario finished, cleaning up") - cleanupCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel()