diff --git a/packages/orchestrator/internal/sandbox/checks.go b/packages/orchestrator/internal/sandbox/checks.go index 0354c60843..57b4544160 100644 --- a/packages/orchestrator/internal/sandbox/checks.go +++ b/packages/orchestrator/internal/sandbox/checks.go @@ -13,8 +13,8 @@ import ( ) const ( - healthCheckInterval = 10 * time.Second - metricsCheckInterval = 2 * time.Second + healthCheckInterval = 20 * time.Second + metricsCheckInterval = 60 * time.Second minEnvdVersionForMetrcis = "0.1.5" ) @@ -29,9 +29,6 @@ func (s *Sandbox) logHeathAndUsage(ctx *utils.LockableCancelableContext) { // Get metrics on sandbox startup go s.LogMetrics(ctx) - ticker := time.NewTicker(15 * time.Second) - defer ticker.Stop() - for { select { case <-healthTicker.C: diff --git a/packages/orchestrator/internal/server/sandboxes.go b/packages/orchestrator/internal/server/sandboxes.go index e95997b32f..3b1aed2895 100644 --- a/packages/orchestrator/internal/server/sandboxes.go +++ b/packages/orchestrator/internal/server/sandboxes.go @@ -7,6 +7,7 @@ import ( "log" "os" "sync" + "time" "go.opentelemetry.io/otel/attribute" "golang.org/x/sync/semaphore" @@ -172,9 +173,12 @@ func (s *server) Delete(ctx context.Context, in *orchestrator.SandboxDeleteReque // Ideally we would rely only on the goroutine defer. s.sandboxes.Remove(in.SandboxId) + loggingCtx, cancelLogginCtx := context.WithTimeout(ctx, 2*time.Second) + defer cancelLogginCtx() + // Check health metrics before stopping the sandbox - sbx.Healthcheck(ctx, true) - sbx.LogMetrics(ctx) + sbx.Healthcheck(loggingCtx, true) + sbx.LogMetrics(loggingCtx) err := sbx.Stop() if err != nil {