Add configurable restart strategies to prevent unexpected downtime #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Statement
When using ECS Anywhere to manage on-premises services, a critical issue occurs when network connectivity is restored after an outage:
Current behavior: Containers that restarted during the connectivity loss are immediately stopped and removed when connectivity returns, causing unexpected downtime of critical services.
This is unacceptable for production environments running critical services that require high availability.
Solution
This PR implements four configurable restart strategies that allow operators to choose how eINS handles restarted containers when connectivity is restored, including options for zero-downtime transitions.
New Restart Strategies
1.
cleanup(default) - Backward Compatible2.
preserve- Simple Zero-Downtime3.
graceful-cutover- Recommended for Critical Services ⭐--cutover-timeout)4.
manual- Full Operator ControlUsage
Basic Examples
Systemd Service Configuration
Update
/lib/systemd/system/ecs-external-instance-network-sentry.service:How Graceful-Cutover Works
on-failurerestart policyResult: Critical services experience zero unexpected downtime!
Implementation Details
New Configuration Parameters
--restart-strategy(choices: cleanup, preserve, graceful-cutover, manual)cleanup--cutover-timeout(integer, seconds)300(5 minutes)graceful-cutoverstrategyEnhanced Logging
All strategies include comprehensive logging:
State Tracking
Added state variables for graceful-cutover:
cutover_in_progress: Tracks if cutover is activecutover_start_time: Timestamp when cutover beganrestarted_containers: Dictionary mapping container IDs to metadataFiles Changed
python/ecs-external-instance-network-sentry.py: Core implementationREADME.md: Documentation for new parameters and strategies.gitignore: Added to exclude Python cache filesTesting Recommendations
graceful-cutoverstrategyBackward Compatibility
✅ Fully backward compatible
cleanupstrategy)Benefits
✅ Prevents unexpected downtime of critical services
✅ Provides multiple strategies for different use cases
✅ Zero-downtime cutover option with graceful-cutover
✅ Full operator control with manual mode
✅ Comprehensive logging for visibility
✅ Configurable timeouts for flexibility
✅ Backward compatible with existing deployments
🤖 Generated with Claude Code