Implement qrun scale command #49

Open
opened 2026-01-03 23:45:58 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-01-03 23:45:58 +00:00 (Migrated from github.com)

User Story

As a developer, I want to scale my application up or down so I can handle varying load or reduce costs during low-traffic periods.

Design

Command Interface

# Scale to specific replica count
qrun scale --app orders-service --env prod --replicas 5

# Scale up by increment
qrun scale --app orders-service --env prod --up 2

# Scale down by increment
qrun scale --app orders-service --env prod --down 1

# Scale to zero (cost saving)
qrun scale --app orders-service --env prod --replicas 0

# Skip confirmation
qrun scale --app orders-service --env prod --replicas 10 --yes

Output Format

Scaling orders-service in prod: 3 -> 5 replicas

  Starting new instances...
    orders-service-mno78  Starting... Ready
    orders-service-pqr90  Starting... Ready

Scaling complete. (5/5 ready)
Current status: qrun status --app orders-service --env prod

Voyage API Integration

POST /v1/apps/{app}/scale
Content-Type: application/json

{
  "environment": "prod",
  "replicas": 5
}

Response:
{
  "status": "scaling",
  "previousReplicas": 3,
  "targetReplicas": 5,
  "message": "Scaling initiated"
}

Files to Create/Modify

File Action Purpose
qctl-qrun/src/main/java/io/qrun/qctl/qrun/ScaleCommand.java Create Main scale command
qctl-qrun/src/main/java/io/qrun/qctl/qrun/model/ScaleResult.java Create Scale response model
qctl-qrun/src/main/java/io/qrun/qctl/qrun/client/VoyageClient.java Modify Add scaleApp()

Implementation Tasks

  • Create ScaleCommand with Picocli annotations
  • Add --app, --env, --replicas, --up, --down, --yes options
  • Create ScaleResult model class
  • Implement VoyageClient.scaleApp() method
  • Validate replica count (min 0, max configurable)
  • Calculate target from --up/--down relative to current
  • Add confirmation prompt for scale to 0 or large increases
  • Show progress as instances start/stop
  • Wait for target replica count to be ready
  • Write unit tests for ScaleCommand

Acceptance Criteria

  • qrun scale --replicas N scales to exact count
  • --up N increases by N replicas
  • --down N decreases by N replicas
  • --replicas 0 scales to zero with confirmation
  • Shows progress during scaling
  • Waits for new replicas to be ready
  • Validates against min/max limits
  • Works with Voyage mock API
## User Story As a developer, I want to scale my application up or down so I can handle varying load or reduce costs during low-traffic periods. ## Design ### Command Interface ```bash # Scale to specific replica count qrun scale --app orders-service --env prod --replicas 5 # Scale up by increment qrun scale --app orders-service --env prod --up 2 # Scale down by increment qrun scale --app orders-service --env prod --down 1 # Scale to zero (cost saving) qrun scale --app orders-service --env prod --replicas 0 # Skip confirmation qrun scale --app orders-service --env prod --replicas 10 --yes ``` ### Output Format ``` Scaling orders-service in prod: 3 -> 5 replicas Starting new instances... orders-service-mno78 Starting... Ready orders-service-pqr90 Starting... Ready Scaling complete. (5/5 ready) Current status: qrun status --app orders-service --env prod ``` ### Voyage API Integration ``` POST /v1/apps/{app}/scale Content-Type: application/json { "environment": "prod", "replicas": 5 } Response: { "status": "scaling", "previousReplicas": 3, "targetReplicas": 5, "message": "Scaling initiated" } ``` ## Files to Create/Modify | File | Action | Purpose | |------|--------|---------| | `qctl-qrun/src/main/java/io/qrun/qctl/qrun/ScaleCommand.java` | Create | Main scale command | | `qctl-qrun/src/main/java/io/qrun/qctl/qrun/model/ScaleResult.java` | Create | Scale response model | | `qctl-qrun/src/main/java/io/qrun/qctl/qrun/client/VoyageClient.java` | Modify | Add scaleApp() | ## Implementation Tasks - [ ] Create ScaleCommand with Picocli annotations - [ ] Add --app, --env, --replicas, --up, --down, --yes options - [ ] Create ScaleResult model class - [ ] Implement VoyageClient.scaleApp() method - [ ] Validate replica count (min 0, max configurable) - [ ] Calculate target from --up/--down relative to current - [ ] Add confirmation prompt for scale to 0 or large increases - [ ] Show progress as instances start/stop - [ ] Wait for target replica count to be ready - [ ] Write unit tests for ScaleCommand ## Acceptance Criteria - [ ] `qrun scale --replicas N` scales to exact count - [ ] `--up N` increases by N replicas - [ ] `--down N` decreases by N replicas - [ ] `--replicas 0` scales to zero with confirmation - [ ] Shows progress during scaling - [ ] Waits for new replicas to be ready - [ ] Validates against min/max limits - [ ] Works with Voyage mock API
Sign in to join this conversation.