Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More resilient droplet upload #195

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

kathap
Copy link

@kathap kathap commented Mar 21, 2025

Previously, the cc-uploader process did not have a draining mechanism. When the process was stopped, any ongoing droplet uploads were aborted immediately, leading to potential failures and incomplete uploads.

This PR introduces a graceful shutdown mechanism to allow ongoing uploads to complete before termination. The key enhancements include:

  • Handling shutdown signals:
    • The process now listens for termination signals (SIGINT, SIGTERM) and responds by allowing uploads to finish before exiting.
  • Tracking active uploads:
    • A global WaitGroup (uploadWaitGroup) is introduced to track ongoing uploads.
    • A wrapper (trackedPoller) ensures uploads are properly accounted for by incrementing/decrementing the WaitGroup.
  • Graceful waiting before shutdown:
    • When a shutdown signal is received, cc-uploader will:
      1. Log the shutdown request.
      2. Wait for all active uploads to complete.
      3. Sleep for 20 seconds as an additional buffer.
      4. Proceed with shutdown.
  • Forceful termination fallback:
    • If necessary, a force shutdown mechanism (forceShutdown()) ensures the process does not hang indefinitely.

Code Changes

  1. Signal Handling:
    • Introduced a signalChan to capture termination signals.
    • Logs all received signals for debugging.
  2. WaitGroup for Uploads:
    • uploadWaitGroup ensures cc-uploader waits for all uploads to finish before stopping.
  3. Poller Enhancements:
    • Wrapped the existing Poller to track polling completion, ensuring uploads are properly accounted for.
  4. Graceful Shutdown Logic:
    • Modified the shutdown process to allow ongoing uploads to complete before exiting.

@kathap kathap marked this pull request as draft March 21, 2025 15:18
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.

1 participant