Skip to content

fix: prevent orphaned ALB target groups and improve Jupyter URL handling#12

Open
wdvr wants to merge 1 commit into
mainfrom
fix/alb-target-group-cleanup
Open

fix: prevent orphaned ALB target groups and improve Jupyter URL handling#12
wdvr wants to merge 1 commit into
mainfrom
fix/alb-target-group-cleanup

Conversation

@wdvr
Copy link
Copy Markdown
Owner

@wdvr wdvr commented Jan 21, 2026

Summary

  • Fix ALB target group leak that caused 100 TG limit to be hit
  • Skip ALB setup when Jupyter is disabled (port=0)
  • Clean up orphaned target groups when listener rule creation fails
  • Add periodic cleanup of orphaned target groups in expiry Lambda
  • Use IP:port fallback instead of broken domain:port URL

Root Cause Analysis

ALB target groups were accumulating because:

  1. Target groups created BEFORE listener rule
  2. Listener rule creation failed (100 TG limit hit)
  3. Target group never cleaned up (no mapping stored)
  4. Some reservations had jupyter_port=0, causing "Invalid port" errors

CloudWatch Evidence

[ERROR] Invalid value for parameter Port, value: 0, valid min value: 1
[ERROR] TooManyUniqueTargetGroupsPerLoadBalancer: 100 limit reached

Test plan

  • Deploy Lambda changes via tf apply
  • Create new reservation with Jupyter enabled - verify HTTPS URL
  • Create reservation without Jupyter - verify no TG created
  • Wait for expiry Lambda to run - check orphaned TG cleanup logs
  • Verify no new orphaned TGs accumulate over time

🤖 Generated with Claude Code

Root cause: ALB target groups were created but never cleaned up when:
1. Listener rule creation failed (100 target group limit)
2. jupyter_port was 0 (Jupyter disabled) causing "Invalid port" errors
3. Expiry Lambda cleanup was failing silently

Changes:
- Skip ALB setup if jupyter_port is 0 (Jupyter disabled)
- Clean up target group if listener rule creation fails
- Add cleanup_orphaned_target_groups() function to alb_utils.py
- Call orphaned TG cleanup from expiry Lambda on each run
- Use IP:port fallback instead of broken domain:port when ALB fails

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@wdvr wdvr force-pushed the fix/alb-target-group-cleanup branch from b7ffe3b to 5d24adc Compare January 22, 2026 00:10
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