Skip to content

About

No description, website, or topics provided.

Resources

Stars

7 stars

Watchers

1 watching

Forks

Repository files navigation

πŸŽͺ Superset Showtime

Modern ephemeral environment management for Apache Superset using circus tent emoji labels

PyPI version Python 3.10+

🎯 What is Showtime?

Superset Showtime is a CLI tool designed primarily for GitHub Actions to manage Apache Superset ephemeral environments. It uses circus tent emoji labels as a visual state management system and depends on Superset's existing build infrastructure.

πŸš€ Quick Start for Superset Contributors

Create an ephemeral environment:

  1. Go to your PR in GitHub
  2. Add label: πŸŽͺ ⚑ showtime-trigger-start
  3. Watch the magic happen - labels will update automatically
  4. When you see πŸŽͺ 🚦 {sha} running, your environment is ready!
  5. Get URL from πŸŽͺ 🌐 {sha} {ip} β†’ http://{ip}:8080
  6. Every new commit can deploy a fresh environment while the prior SHA remains available until promotion succeeds

To test a specific commit without auto-updates:

  • Add label: πŸŽͺ 🧊 showtime-freeze (prevents auto-sync on new commits)

Clean up when done:

# Add this label:
πŸŽͺ πŸ›‘ showtime-trigger-stop
# Labels disappear only after AWS deletion is confirmed

πŸŽͺ How It Works

πŸŽͺ GitHub labels become a visual state machine:

# User adds trigger label in GitHub UI:
πŸŽͺ ⚑ showtime-trigger-start

# System responds with state labels:
πŸŽͺ abc123f 🚦 building      # Environment abc123f is building
πŸŽͺ 🎯 abc123f               # abc123f is the active environment
πŸŽͺ abc123f πŸ“… 2024-01-15T14-30  # Created timestamp
πŸŽͺ abc123f βŒ› 24h           # Time-to-live policy
πŸŽͺ abc123f 🀑 maxime        # Requested by maxime (clown emoji!)

# When ready:
πŸŽͺ abc123f 🚦 running       # Environment is now running
πŸŽͺ abc123f 🌐 52-1-2-3      # Available at http://52.1.2.3:8080

πŸ”„ Showtime Workflow

flowchart TD
    A[User adds πŸŽͺ ⚑ trigger-start] --> B[GitHub Actions: sync]
    B --> C{Current state?}

    C -->|No environment| D[πŸ”’ Claim: Remove trigger + Set building]
    C -->|Running + new SHA| E[πŸ”’ Claim: Remove trigger + Set building]
    C -->|Already building| F[❌ Exit: Another job active]
    C -->|No triggers| G[❌ Exit: Nothing to do]

    D --> H[πŸ“‹ State: building]
    E --> H
    H --> I[🐳 Docker build + immutable digest]
    I -->|Success| S{Runner smoke enabled?}
    S -->|Yes| T[Local /health smoke + owned cleanup]
    S -->|No| J[πŸ“‹ State: built]
    T -->|Healthy and cleaned| J
    T -->|Failure| K
    I -->|Fail| K[πŸ“‹ State: failed]

    J --> L[πŸ“‹ State: deploying]
    L --> M[☁️ AWS Deploy]
    M -->|Success| N[πŸ“‹ State: running]
    M -->|Fail| O[πŸ“‹ State: failed]

    N --> P[πŸŽͺ Environment ready!]

    Q[User adds πŸŽͺ πŸ›‘ trigger-stop] --> R[🧹 Cleanup AWS + Remove labels]
Loading

Install CLI for debugging:

pip install superset-showtime
export GITHUB_TOKEN=your_token

Monitor and debug:

showtime list                    # See all active environments
showtime status 1234            # Debug specific environment
showtime labels                 # Complete label reference

Testing/development:

showtime sync 1234 --dry-run-aws --dry-run-docker  # Test without costs
showtime sync 1234 --dry-run-github                 # Read GitHub state without writes
showtime cleanup --dry-run --older-than 1h         # Test environment + label cleanup
showtime cleanup-labels                         # Preview stale repo label definitions

Architecture: GitHub label writes and AWS operations are not transactional. Showtime preserves the previous environment during a different-SHA deployment and records partial cleanup so serialized retries can converge safely. Callers must serialize operations for each PR; there is no distributed global lock.

πŸŽͺ Complete Label Reference

🎯 Trigger Labels (Add These to Your PR)

Label Action Result
πŸŽͺ ⚑ showtime-trigger-start Create environment Builds and deploys ephemeral environment with blue-green deployment
πŸŽͺ πŸ›‘ showtime-trigger-stop Destroy environment Removes resource labels only after confirmed AWS deletion
πŸŽͺ 🧊 showtime-freeze Freeze environment Prevents auto-sync on new commits (for testing specific SHAs)

πŸ“Š State Labels (Automatically Managed)

Label Pattern Meaning Example
πŸŽͺ {sha} 🚦 {status} Environment status πŸŽͺ abc123f 🚦 running
πŸŽͺ 🎯 {sha} Active environment pointer πŸŽͺ 🎯 abc123f
πŸŽͺ πŸ—οΈ {sha} Building environment pointer πŸŽͺ πŸ—οΈ def456a
πŸŽͺ {sha} πŸ“… {timestamp} Creation time πŸŽͺ abc123f πŸ“… 2024-01-15T14-30
πŸŽͺ {sha} 🌐 {ip:port} Environment URL πŸŽͺ abc123f 🌐 52.1.2.3:8080
πŸŽͺ {sha} βŒ› {ttl} Time-to-live policy πŸŽͺ abc123f βŒ› 24h
πŸŽͺ {sha} 🀑 {username} Who requested πŸŽͺ abc123f 🀑 maxime
πŸŽͺ {sha} 🧬 {fingerprint} Task-definition ownership used for guarded cleanup πŸŽͺ abc123f 🧬 0123456789abcdef0123456789abcdef
πŸŽͺ {sha} 🧹 cleanup-pending AWS deletion is unconfirmed and tracking must remain πŸŽͺ abc123f 🧹 cleanup-pending

πŸ”§ Testing Configuration Changes

Approach: Modify configuration directly in your PR code, then trigger environment.

Workflow:

  1. Modify superset_config.py with your changes
  2. Push commit β†’ Creates new SHA (e.g., def456a)
  3. Add πŸŽͺ ⚑ showtime-trigger-start β†’ Deploys with your config
  4. Test environment reflects your exact code changes

This approach creates traceable, reviewable changes that are part of your git history.

πŸ”„ Complete Workflows

Creating Your First Environment

  1. Add trigger label in GitHub UI: πŸŽͺ ⚑ showtime-trigger-start
  2. Watch state labels appear:
    πŸŽͺ abc123f 🚦 building      ← Environment is building
    πŸŽͺ 🎯 abc123f               ← This is the active environment
    πŸŽͺ abc123f πŸ“… 2024-01-15T14-30  ← Started building at this time
    
  3. Wait for completion:
    πŸŽͺ abc123f 🚦 running       ← Now ready!
    πŸŽͺ abc123f 🌐 52.1.2.3:8080  ← Visit http://52.1.2.3:8080
    

Testing Specific Commits

  1. Add freeze label: πŸŽͺ 🧊 showtime-freeze
  2. Result: Environment won't auto-update on new commits
  3. Use case: Test specific SHA while continuing development
  4. Override: Add πŸŽͺ ⚑ showtime-trigger-start to force update despite freeze

Rolling Updates (Automatic!)

When you push new commits, Showtime automatically:

  1. Detects new commit via GitHub webhook
  2. Builds new environment alongside old one
  3. Switches traffic when new environment is ready
  4. Cleans up old environment

You'll see:

# During update:
πŸŽͺ abc123f 🚦 running       # Old environment still serving
πŸŽͺ def456a 🚦 building      # New environment building
πŸŽͺ 🎯 abc123f               # Traffic still on old
πŸŽͺ πŸ—οΈ def456a               # New one being prepared

# After update:
πŸŽͺ def456a 🚦 running       # New environment live
πŸŽͺ 🎯 def456a               # Traffic switched
πŸŽͺ def456a 🌐 52-4-5-6      # New IP address
# abc123f labels are removed after its AWS deletion is confirmed

The cross-SHA flow promotes the candidate only after deployment succeeds. A failed candidate does not move the active pointer or delete the prior healthy service. Cleanup removes labels only after service absence is confirmed; false returns, exceptions, ownership mismatches, and uncertain AWS responses retain tracking and make the CLI exit nonzero.

An explicit rebuild of the same SHA is different: service names are deterministic, so it destructively reuses that service identity and has no fallback environment. Showtime warns before this path. Per-PR operations must remain serialized. GitHub label writes can still be partially applied, and a later sync reconciles the active pointer without rebuilding a candidate that is already marked running.

Per-PR teardown only detaches labels. Repository-wide label definitions may be shared by other PRs and are deleted exclusively by cleanup-labels after a global attachment-count check.

Startup readiness and diagnostics

start and sync accept --startup-timeout-seconds, or SHOWTIME_STARTUP_TIMEOUT_SECONDS. The default is 1800 seconds (30 minutes); values must be positive integers and are validated before deployment changes.

showtime sync PR_NUMBER --sha SHA --startup-timeout-seconds 1800

After task-definition registration and any required same-SHA teardown, one monotonic startup budget covers dedicated client setup, service creation, update, task observation, networking, and HTTP health checks. Task replacement does not reset it. Success requires the expected task definition, one stable primary deployment with matching running/desired counts and no pending tasks, and /health returning HTTP 200 from that deployment's running task. An incomplete or failed rollout cannot pass just because HTTP responds; there is no homepage or redirect fallback.

Showtime reports task, endpoint, and service-state changes while waiting. A stopped task can be replaced within the original budget. Failed rollouts and terminal service states fail promptly. Newly created service/task/network identities get a bounded visibility allowance of up to five minutes, constrained by the original deadline; permission errors are not treated as visibility delays. Historical task records cannot establish current readiness, and historical scans do not delay a candidate that has already passed strict health. After a failed probe, historical collection has a 15-second per-cycle cap and reserves time for the next live poll; incomplete history is reported as partial evidence.

Startup AWS requests use 2-second connect and 5-second read timeouts with SDK retries disabled. HTTP uses a streaming response and finite timeouts without reading the body. A request is not started with less than its 7-second transport allowance remaining. These are practical request bounds, not an unconditional process kill: DNS, credential providers, and OS scheduling can affect elapsed time. The longer default is a mitigation, not a diagnosis of slow application startup.

Before failed-candidate cleanup, Showtime collects bounded service/task evidence, including exit codes, stop reasons, replacements, and recent service events. An additional 30-second diagnostic budget permits at most one CloudWatch log page (100 events), with log content limited to 100 lines and 16 KiB. Log access uses the packaged ECS log configuration and requires optional logs:GetLogEvents permission on that log group. Available, empty, denied, unavailable, and not-attempted logs are reported distinctly. Known configured secret values are redacted; raw task environments and AWS exception payloads are not printed. Diagnostic failures cannot suppress candidate cleanup or erase the primary failure. Total command time can exceed the startup budget by this diagnostic allowance and the existing bounded cleanup waits.

Optional runner smoke test

start and sync expose a local pre-deployment smoke test. It is off by default and can be enabled with --smoke-test or SHOWTIME_SMOKE_TEST=true. The managed path builds and pushes linux/amd64, reads Buildx's manifest digest, then uses that exact apache/superset@sha256:... reference for both the smoke container and ECS task definition. Missing or malformed digest metadata stops before smoke or AWS.

showtime sync PR_NUMBER --smoke-test \
  --build-timeout-seconds 3600 \
  --smoke-timeout-seconds 600 \
  --smoke-diagnostics-dir .showtime/diagnostics

Environment equivalents are SHOWTIME_BUILD_TIMEOUT_SECONDS, SHOWTIME_SMOKE_TIMEOUT_SECONDS, and SHOWTIME_SMOKE_DIAGNOSTICS_DIR. Timeouts must be positive integers. The diagnostics path must be writable and must not use symlinked directories. The reference Actions job allows 120 minutes; adjust its job timeout when changing the build, smoke, ECS, or cleanup budgets.

The disposable container is rendered from the packaged ECS task definition, including effective feature flags, entrypoint, command, container port, 0.5 CPU, and 2 GiB memory with swap capped at the same value. Its port is published only on 127.0.0.1 with an ephemeral host port. Environment values are written to a mode-0600 temporary env file, never command arguments, and the file is deleted immediately after create. Success requires /health HTTP 200 and verified removal of the randomly named, ownership-labelled container before any AWS allocation. ECS readiness remains mandatory afterward.

Build output, Docker errors, and retained logs use the same redaction rules and finite buffers. On smoke failure Showtime writes unique mode-0600 runner-smoke-pr-<pr>-<sha>-<attempt>.json and .log files. JSON contains only the primary outcome, selected container state, mapped port, immutable image, log status, cleanup result, and secondary evidence errors. Log status is one of captured_nonempty, captured_empty, unavailable, or not_attempted; logs are limited to 100 lines and 16 KiB. Process output retention is limited to 64 KiB. Docker commands have 30-second execution budgets, HTTP requests have seven-second request envelopes, and diagnostic and cleanup work have separate 30-second budgets. Subprocess shutdown can add up to seven seconds for TERM/KILL handling. Handled SIGINT and SIGTERM trigger bounded evidence and owned cleanup; SIGKILL cannot be cleaned up by the process.

Showtime creates local diagnostic files but does not upload them. Every consuming workflow must add an if: always() actions/upload-artifact@v4 step with include-hidden-files: true and the narrow path .showtime/diagnostics/runner-smoke-*; do not upload .showtime/ wholesale. See workflows-reference/showtime-trigger.yml for the default-off example.

The smoke check approximates packaged startup and resource limits. It does not reproduce Fargate networking, scheduling, or logging, does not establish the unknown incident cause, and never replaces strict ECS readiness. Fully mocked testing remains available with both --dry-run-docker --dry-run-aws; skipping Docker is rejected with live AWS or with smoke enabled because neither can prove immutable identity.

πŸ”’ Security & Permissions

Who Can Use This?

  • βœ… Superset maintainers (with write access) can add trigger labels
  • ❌ External contributors cannot trigger environments (no write access to add labels)
  • πŸ”’ Secure by design - only trusted users can create expensive AWS resources

GitHub Actions Integration

🎯 Live Workflow: showtime-trigger.yml

How it works:

  • Triggers on PR label changes, commits, and closures
  • Installs superset-showtime from PyPI (trusted code, not PR code)
  • Runs showtime sync to handle trigger processing and deployments
  • Supports manual testing via workflow_dispatch with specific SHA override

Commands used:

showtime sync PR_NUMBER --check-only    # Read-only: determine build_needed + target_sha
showtime sync PR_NUMBER --sha SHA       # Execute atomic claim + build + deploy

πŸ› οΈ CLI Usage

The CLI is primarily used by GitHub Actions, but available for debugging and advanced users:

pip install superset-showtime
export GITHUB_TOKEN=your_token

# Core commands:
showtime sync PR_NUMBER              # Sync to desired state (main command)
showtime start PR_NUMBER             # Create new environment
showtime stop PR_NUMBER              # Delete environment
showtime status PR_NUMBER            # Show current state
showtime list                        # List all environments
showtime cleanup --older-than 48h --force    # Clean up expired envs, closed PR labels, and stale labels
showtime cleanup-labels --no-dry-run --force  # Prune unattached per-SHA labels only

🀝 Contributing

Testing Your Changes

Test with real PRs safely:

# Test full workflow without costs:
showtime sync YOUR_PR_NUMBER --dry-run-aws --dry-run-docker

# Test cleanup logic:
showtime cleanup --dry-run --older-than 24h
showtime cleanup-labels  # dry-run by default

Development Setup

git clone https://github.com/mistercrunch/superset-showtime
cd superset-showtime

# Using uv (recommended):
uv pip install -e ".[dev]"
make pre-commit
make test

# Traditional pip:
pip install -e ".[dev]"
pre-commit install
pytest

πŸ“„ License

Apache License 2.0 - same as Apache Superset.


πŸŽͺ "Ladies and gentlemen, welcome to Superset Showtime - where ephemeral environments are always under the big top!" πŸŽͺ🀑✨

About

No description, website, or topics provided.

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages