Skip to content

Add dry-run guard for AWS scaling actions - #34

Open
Cool-fire wants to merge 1 commit into
mainfrom
gambits/ses_9a9b74e2b6ee4b1e-efcfa46c8c7d
Open

Add dry-run guard for AWS scaling actions#34
Cool-fire wants to merge 1 commit into
mainfrom
gambits/ses_9a9b74e2b6ee4b1e-efcfa46c8c7d

Conversation

@Cool-fire

Copy link
Copy Markdown
Owner

This change wires a new --dry-run flag from the CLI into the scaler/service layer so scaling commands can validate configs and report the intended action without mutating AWS resources.

Why this is needed:

  • the reported regression was in the EC2 scale-down path, where a dry run still proceeded to the autoscaling update call instead of only reporting the intended change
  • the existing service layout made the smallest safe fix to pass dry-run intent through cmd/root.go -> pkg/scaler.go -> pkg/service/*

What changed:

  • added --dry-run to the Cobra root command and passed it into pkg.ScaleApp
  • threaded dryRun through the scaler dispatch so each AWS service can short-circuit before its mutation call
  • updated the EC2 autoscaling service to log the intended scale-up/scale-down action and skip UpdateAutoScalingGroup during dry runs
  • added the same dry-run no-op behavior for the other AWS service handlers so the CLI does not apply changes when --dry-run is set
  • added a regression test covering EC2 scale-down dry runs and asserting they log the action while never calling the autoscaling client

Verification:

  • attempted gofmt -w cmd/root.go pkg/scaler.go pkg/service/ec2.go pkg/service/elasticache.go pkg/service/kinesis.go pkg/service/dynamodb.go pkg/service/ec2_test.go -> failed because gofmt is not installed in this sandbox (/usr/bin/bash: line 1: gofmt: command not found)
  • attempted go env GOROOT / which go to locate the toolchain -> failed because go is not installed in this sandbox
  • tests could not be run here for the same reason

Limitations:

  • I could not format or execute the Go test suite in this environment due the missing Go toolchain, so the PR notes that explicitly

Files changed

cmd/root.go                |  4 +++-
 pkg/scaler.go              | 18 ++++++++--------
 pkg/service/dynamodb.go    |  9 +++++++-
 pkg/service/ec2.go         | 19 +++++++++++++++--
 pkg/service/ec2_test.go    | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 pkg/service/elasticache.go | 12 ++++++++++-
 pkg/service/kinesis.go     |  8 ++++++-
 7 files changed, 108 insertions(+), 15 deletions(-)

Session

View session

Generated by Gambits Staging

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