Skip to content

fix: make artifact signature wait context-aware to allow graceful shutdown#6329

Merged
evankanderson merged 3 commits intomindersec:mainfrom
sachin9058:fix/artifact-wait-clean
Apr 11, 2026
Merged

fix: make artifact signature wait context-aware to allow graceful shutdown#6329
evankanderson merged 3 commits intomindersec:mainfrom
sachin9058:fix/artifact-wait-clean

Conversation

@sachin9058
Copy link
Copy Markdown
Contributor

Summary

This change replaces the blocking time.Sleep used during artifact entity processing with a context-aware wait.

Currently, the handler unconditionally waits for ArtifactSignatureWaitPeriod (10 seconds) before proceeding with evaluation of artifact entities. This is implemented using time.Sleep, which does not respect context cancellation. As a result, if the server is shutting down and the parent context is cancelled, goroutines remain blocked for the full duration, delaying graceful shutdown.

This PR updates the logic to use a select statement over time.After and msgCtx.Done(). This allows the goroutine to exit early when the context is cancelled, while preserving the intended wait behavior during normal execution.

The fix leverages the existing msgCtx, which is already tied to the handler’s shutdown lifecycle, keeping the change minimal and aligned with current design.

No additional dependencies are introduced.

Fixes #6324


Testing

Steps to Reproduce

  1. Start the server.
  2. Trigger artifact entity evaluations (ENTITY_ARTIFACTS).
  3. While evaluations are in the initial wait period, initiate server shutdown.

Behavior Before Fix

  • Goroutines remain blocked for up to 10 seconds.
  • Shutdown is delayed until all sleeps complete.

Behavior After Fix

  • Goroutines exit immediately when shutdown is triggered.
  • Server shuts down promptly without unnecessary delay.

Additional Verification

  • Verified that normal execution still waits for the full ArtifactSignatureWaitPeriod when no shutdown occurs.
  • Confirmed no changes to evaluation flow or behavior outside shutdown scenarios.
  • Successfully ran:
go build ./...
go vet ./...

@sachin9058 sachin9058 requested a review from a team as a code owner April 10, 2026 13:34
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 59.501% (-0.004%) from 59.505% — sachin9058:fix/artifact-wait-clean into mindersec:main

@evankanderson evankanderson merged commit 4d4f30a into mindersec:main Apr 11, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Artifact evaluation sleep ignores context cancellation during shutdown

3 participants