aptible-cli 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97db514e9f8cadd2d35e757350cf16038dc6e319a1bc259b5a9cf28101467f39
4
- data.tar.gz: e2058f731955e95d3bd024d1535a96bfe7e2bb9d9dc61a96192b56346e1c992a
3
+ metadata.gz: 809d2d53a19fb2e5d1994590b45fc667fff94712030b79ad9d235a0fa8012f02
4
+ data.tar.gz: fae62dfb569ad369bda8d20f593bcd350e57eff1a2abc4fa6cafb6b9041f8e8f
5
5
  SHA512:
6
- metadata.gz: bcbc491db4584b58ec9d8cc59ab382302a86cfa83422f29900e57e5e30feb2240ec5f9621b39129852bc03f4d36c0d34383e5efabeeb26cd943c79183e321297
7
- data.tar.gz: 1f2a33631bc7ef8d248bafe247cec5fbf856307e0483fedf03bbe5ff077f38b85b7488c41d6b58016a34a4874ec03d2ce7209dcadd69bfca71af2f91f700034c
6
+ metadata.gz: 9a93f2032ad6c569056d5a8cdf21034cf35147d0d12031b6c907a0e2b6984a7c895db2c6f01135e36d8d1d24e3a838174851de367cb7f34ec9c34016c8c6525d
7
+ data.tar.gz: 8f67f7b07595457831aa438ff718470137496cd35244964bfb050adfda3ee093f8fc87cad364b2b0e3d42d6015eee2582bcdd8eeeca2707f3dc48e4f060e2c7a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aptible-cli (0.22.0)
4
+ aptible-cli (0.23.0)
5
5
  activesupport (>= 4.0, < 6.0)
6
6
  aptible-api (~> 1.6.5)
7
7
  aptible-auth (~> 1.2.5)
data/README.md CHANGED
@@ -26,85 +26,87 @@ From `aptible help`:
26
26
  <!-- BEGIN USAGE -->
27
27
  ```
28
28
  Commands:
29
- aptible apps # List all applications
30
- aptible apps:create HANDLE # Create a new application
31
- aptible apps:deprovision # Deprovision an app
32
- aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename an app handle. In order for the new app handle to appear in log drain and metric drain destinations, you must restart the app.
33
- aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE] # Scale a service
34
- aptible backup:list DB_HANDLE # List backups for a database
35
- aptible backup:orphaned # List backups associated with deprovisioned databases
36
- aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
37
- aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Restore a backup
38
- aptible backup_retention_policy [ENVIRONMENT_HANDLE] # Show the current backup retention policy for the environment
39
- aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] [--force] # Change the environment's backup retention policy
40
- aptible config # Print an app's current configuration
41
- aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
- aptible config:get [VAR1] # Print a specific key within an app's current configuration
43
- aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
44
- aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
45
- aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
46
- aptible db:backup HANDLE # Backup a database
47
- aptible db:clone SOURCE DEST # Clone a database to create a new one
48
- aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Create a new database
49
- aptible db:deprovision HANDLE # Deprovision a database
50
- aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
51
- aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
52
- aptible db:list # List all databases
53
- aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
54
- aptible db:reload HANDLE # Reload a database
55
- aptible db:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename a database handle. In order for the new database handle to appear in log drain and metric drain destinations, you must reload the database.
56
- aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
57
- aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
58
- aptible db:tunnel HANDLE # Create a local tunnel to a database
59
- aptible db:url HANDLE # Display a database URL
60
- aptible db:versions # List available database versions
61
- aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
62
- aptible endpoints:database:create DATABASE # Create a Database Endpoint
63
- aptible endpoints:database:modify --database DATABASE ENDPOINT_HOSTNAME # Modify a Database Endpoint
64
- aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
65
- aptible endpoints:grpc:create [--app APP] SERVICE # Create an App gRPC Endpoint
66
- aptible endpoints:grpc:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App gRPC Endpoint
67
- aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
68
- aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
69
- aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
70
- aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
71
- aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
72
- aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
73
- aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
74
- aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
75
- aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
76
- aptible environment:list # List all environments
77
- aptible environment:rename OLD_HANDLE NEW_HANDLE # Rename an environment handle. In order for the new environment handle to appear in log drain/metric destinations, you must restart the apps/databases in this environment.
78
- aptible help [COMMAND] # Describe available commands or one specific command
79
- aptible log_drain:create:datadog HANDLE --url DATADOG_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Datadog Log Drain
80
- aptible log_drain:create:elasticsearch HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create an Elasticsearch Log Drain
81
- aptible log_drain:create:https HANDLE --url URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a HTTPS Drain
82
- aptible log_drain:create:logdna HANDLE --url LOGDNA_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a LogDNA Log Drain
83
- aptible log_drain:create:papertrail HANDLE --host PAPERTRAIL_HOST --port PAPERTRAIL_PORT --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
84
- aptible log_drain:create:sumologic HANDLE --url SUMOLOGIC_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Sumologic Drain
85
- aptible log_drain:create:syslog HANDLE --host SYSLOG_HOST --port SYSLOG_PORT [--token TOKEN] --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
86
- aptible log_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a log drain
87
- aptible log_drain:list # List all Log Drains
88
- aptible login # Log in to Aptible
89
- aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
90
- aptible logs_from_archive --bucket NAME --region REGION --stack NAME [ --decryption-keys ONE [OR MORE] ] [ --download-location LOCATION ] [ [ --string-matches ONE [OR MORE] ] | [ --app-id ID | --database-id ID | --endpoint-id ID | --container-id ID ] [ --start-date YYYY-MM-DD --end-date YYYY-MM-DD ] ] --bucket=BUCKET --region=REGION --stack=STACK # Retrieves container logs from an S3 archive in your own AWS account. You must provide your AWS credentials via the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
91
- aptible maintenance:apps # List Apps impacted by maintenance schedules where restarts are required
92
- aptible maintenance:dbs # List Databases impacted by maintenance schedules where restarts are required
93
- aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
94
- aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
95
- aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
96
- aptible metric_drain:create:influxdb:customv2 HANDLE --org ORGANIZATION --token INFLUX_TOKEN --url URL_INCLUDING_PORT --bucket INFLUX_BUCKET_NAME --environment ENVIRONMENT # Create an InfluxDB v2 Metric Drain
97
- aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
98
- aptible metric_drain:list # List all Metric Drains
99
- aptible operation:cancel OPERATION_ID # Cancel a running operation
100
- aptible operation:follow OPERATION_ID # Follow logs of a running operation
101
- aptible operation:logs OPERATION_ID # View logs for given operation
102
- aptible rebuild # Rebuild an app, and restart its services
103
- aptible restart # Restart all services associated with an app
104
- aptible services # List Services for an App
105
- aptible services:settings SERVICE [--force-zero-downtime|--no-force-zero-downtime] [--simple-health-check|--no-simple-health-check] # Modifies the zero-downtime deploy setting for a service
106
- aptible ssh [COMMAND] # Run a command against an app
107
- aptible version # Print Aptible CLI version
29
+ aptible apps # List all applications
30
+ aptible apps:create HANDLE # Create a new application
31
+ aptible apps:deprovision # Deprovision an app
32
+ aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename an app handle. In order for the new app handle to appear in log drain and metric drain destinations, you must restart the app.
33
+ aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE] # Scale a service
34
+ aptible backup:list DB_HANDLE # List backups for a database
35
+ aptible backup:orphaned # List backups associated with deprovisioned databases
36
+ aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
37
+ aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Restore a backup
38
+ aptible backup_retention_policy [ENVIRONMENT_HANDLE] # Show the current backup retention policy for the environment
39
+ aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] [--force] # Change the environment's backup retention policy
40
+ aptible config # Print an app's current configuration
41
+ aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
+ aptible config:get [VAR1] # Print a specific key within an app's current configuration
43
+ aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
44
+ aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
45
+ aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
46
+ aptible db:backup HANDLE # Backup a database
47
+ aptible db:clone SOURCE DEST # Clone a database to create a new one
48
+ aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Create a new database
49
+ aptible db:deprovision HANDLE # Deprovision a database
50
+ aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
51
+ aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
52
+ aptible db:list # List all databases
53
+ aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
54
+ aptible db:reload HANDLE # Reload a database
55
+ aptible db:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename a database handle. In order for the new database handle to appear in log drain and metric drain destinations, you must reload the database.
56
+ aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
57
+ aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
58
+ aptible db:tunnel HANDLE # Create a local tunnel to a database
59
+ aptible db:url HANDLE # Display a database URL
60
+ aptible db:versions # List available database versions
61
+ aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
62
+ aptible endpoints:database:create DATABASE # Create a Database Endpoint
63
+ aptible endpoints:database:modify --database DATABASE ENDPOINT_HOSTNAME # Modify a Database Endpoint
64
+ aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
65
+ aptible endpoints:grpc:create [--app APP] SERVICE # Create an App gRPC Endpoint
66
+ aptible endpoints:grpc:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App gRPC Endpoint
67
+ aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
68
+ aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
69
+ aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
70
+ aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
71
+ aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
72
+ aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
73
+ aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
74
+ aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
75
+ aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
76
+ aptible environment:list # List all environments
77
+ aptible environment:rename OLD_HANDLE NEW_HANDLE # Rename an environment handle. In order for the new environment handle to appear in log drain/metric destinations, you must restart the apps/databases in this environment.
78
+ aptible help [COMMAND] # Describe available commands or one specific command
79
+ aptible log_drain:create:datadog HANDLE --url DATADOG_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Datadog Log Drain
80
+ aptible log_drain:create:elasticsearch HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create an Elasticsearch Log Drain
81
+ aptible log_drain:create:https HANDLE --url URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a HTTPS Drain
82
+ aptible log_drain:create:logdna HANDLE --url LOGDNA_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a LogDNA Log Drain
83
+ aptible log_drain:create:papertrail HANDLE --host PAPERTRAIL_HOST --port PAPERTRAIL_PORT --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
84
+ aptible log_drain:create:sumologic HANDLE --url SUMOLOGIC_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Sumologic Drain
85
+ aptible log_drain:create:syslog HANDLE --host SYSLOG_HOST --port SYSLOG_PORT [--token TOKEN] --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
86
+ aptible log_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a log drain
87
+ aptible log_drain:list # List all Log Drains
88
+ aptible login # Log in to Aptible
89
+ aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
90
+ aptible logs_from_archive --bucket NAME --region REGION --stack NAME [ --decryption-keys ONE [OR MORE] ] [ --download-location LOCATION ] [ [ --string-matches ONE [OR MORE] ] | [ --app-id ID | --database-id ID | --endpoint-id ID | --container-id ID ] [ --start-date YYYY-MM-DD --end-date YYYY-MM-DD ] ] --bucket=BUCKET --region=REGION --stack=STACK # Retrieves container logs from an S3 archive in your own AWS account. You must provide your AWS credentials via the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
91
+ aptible maintenance:apps # List Apps impacted by maintenance schedules where restarts are required
92
+ aptible maintenance:dbs # List Databases impacted by maintenance schedules where restarts are required
93
+ aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
94
+ aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
95
+ aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
96
+ aptible metric_drain:create:influxdb:customv2 HANDLE --org ORGANIZATION --token INFLUX_TOKEN --url URL_INCLUDING_PORT --bucket INFLUX_BUCKET_NAME --environment ENVIRONMENT # Create an InfluxDB v2 Metric Drain
97
+ aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
98
+ aptible metric_drain:list # List all Metric Drains
99
+ aptible operation:cancel OPERATION_ID # Cancel a running operation
100
+ aptible operation:follow OPERATION_ID # Follow logs of a running operation
101
+ aptible operation:logs OPERATION_ID # View logs for given operation
102
+ aptible rebuild # Rebuild an app, and restart its services
103
+ aptible restart # Restart all services associated with an app
104
+ aptible services # List Services for an App
105
+ aptible services:settings SERVICE [--force-zero-downtime|--no-force-zero-downtime] [--simple-health-check|--no-simple-health-check] # Modifies the zero-downtime deploy setting for a service
106
+ aptible services:sizing_policy SERVICE # Returns the associated sizing policy, if any
107
+ aptible services:sizing_policy:set SERVICE --autoscaling-type (horizontal|vertical) [--metric-lookback-seconds SECONDS] [--percentile PERCENTILE] [--post-scale-up-cooldown-seconds SECONDS] [--post-scale-down-cooldown-seconds SECONDS] [--post-release-cooldown-seconds SECONDS] [--mem-cpu-ratio-r-threshold RATIO] [--mem-cpu-ratio-c-threshold RATIO] [--mem-scale-up-threshold THRESHOLD] [--mem-scale-down-threshold THRESHOLD] [--minimum-memory MEMORY] [--maximum-memory MEMORY] [--min-cpu-threshold THRESHOLD] [--max-cpu-threshold THRESHOLD] [--min-containers CONTAINERS] [--max-containers CONTAINERS] [--scale-up-step STEPS] [--scale-down-step STEPS] # Sets the sizing (autoscaling) policy for a service. This is not incremental, all arguments must be sent at once or they will be set to defaults.
108
+ aptible ssh [COMMAND] # Run a command against an app
109
+ aptible version # Print Aptible CLI version
108
110
  ```
109
111
  <!-- END USAGE -->
110
112
 
@@ -270,6 +270,35 @@ module Aptible
270
270
  attach_account(node, account)
271
271
  end
272
272
 
273
+ def inject_service_sizing_policy(node, policy, service)
274
+ node.value('autoscaling_type', policy.autoscaling)
275
+ node.value('metric_lookback_seconds', policy.metric_lookback_seconds)
276
+ node.value('percentile', policy.percentile)
277
+ node.value('post_scale_up_cooldown_seconds',
278
+ policy.post_scale_up_cooldown_seconds)
279
+ node.value('post_scale_down_cooldown_seconds',
280
+ policy.post_scale_down_cooldown_seconds)
281
+ node.value('post_release_cooldown_seconds',
282
+ policy.post_release_cooldown_seconds)
283
+ node.value('mem_cpu_ratio_r_threshold',
284
+ policy.mem_cpu_ratio_r_threshold)
285
+ node.value('mem_cpu_ratio_c_threshold',
286
+ policy.mem_cpu_ratio_c_threshold)
287
+ node.value('mem_scale_up_threshold', policy.mem_scale_up_threshold)
288
+ node.value('mem_scale_down_threshold',
289
+ policy.mem_scale_down_threshold)
290
+ node.value('minimum_memory', policy.minimum_memory)
291
+ node.value('maximum_memory', policy.maximum_memory)
292
+ node.value('min_cpu_threshold', policy.min_cpu_threshold)
293
+ node.value('max_cpu_threshold', policy.max_cpu_threshold)
294
+ node.value('min_containers', policy.min_containers)
295
+ node.value('max_containers', policy.max_containers)
296
+ node.value('scale_up_step', policy.scale_up_step)
297
+ node.value('scale_down_step', policy.scale_down_step)
298
+
299
+ attach_service(node, service)
300
+ end
301
+
273
302
  private
274
303
 
275
304
  def attach_account(node, account)
@@ -44,6 +44,154 @@ module Aptible
44
44
 
45
45
  service.update!(**updates) if updates.any?
46
46
  end
47
+
48
+ desc 'services:sizing_policy SERVICE',
49
+ 'Returns the associated sizing policy, if any'
50
+ app_options
51
+ define_method 'services:sizing_policy' do |service|
52
+ service = ensure_service(options, service)
53
+ policy = service.service_sizing_policy
54
+
55
+ unless policy
56
+ raise Thor::Error, "Service #{service} does not have a " \
57
+ 'service sizing policy set'
58
+ end
59
+
60
+ Formatter.render(Renderer.current) do |root|
61
+ root.object do |node|
62
+ ResourceFormatter.inject_service_sizing_policy(
63
+ node, policy, service
64
+ )
65
+ end
66
+ end
67
+ end
68
+
69
+ desc 'services:sizing_policy:set SERVICE '\
70
+ '--autoscaling-type (horizontal|vertical) '\
71
+ '[--metric-lookback-seconds SECONDS] '\
72
+ '[--percentile PERCENTILE] '\
73
+ '[--post-scale-up-cooldown-seconds SECONDS] '\
74
+ '[--post-scale-down-cooldown-seconds SECONDS] '\
75
+ '[--post-release-cooldown-seconds SECONDS] '\
76
+ '[--mem-cpu-ratio-r-threshold RATIO] '\
77
+ '[--mem-cpu-ratio-c-threshold RATIO] '\
78
+ '[--mem-scale-up-threshold THRESHOLD] '\
79
+ '[--mem-scale-down-threshold THRESHOLD] '\
80
+ '[--minimum-memory MEMORY] '\
81
+ '[--maximum-memory MEMORY] '\
82
+ '[--min-cpu-threshold THRESHOLD] '\
83
+ '[--max-cpu-threshold THRESHOLD] '\
84
+ '[--min-containers CONTAINERS] '\
85
+ '[--max-containers CONTAINERS] '\
86
+ '[--scale-up-step STEPS] '\
87
+ '[--scale-down-step STEPS] ',
88
+ 'Sets the sizing (autoscaling) policy for a service.'\
89
+ ' This is not incremental, all arguments must be sent'\
90
+ ' at once or they will be set to defaults.'
91
+ app_options
92
+ option :autoscaling_type,
93
+ type: :string,
94
+ desc: 'The type of autoscaling. Must be either '\
95
+ '"horizontal" or "vertical"'
96
+ option :metric_lookback_seconds,
97
+ type: :numeric,
98
+ desc: '(Default: 1800) The duration in seconds for '\
99
+ 'retrieving past performance metrics.'
100
+ option :percentile,
101
+ type: :numeric,
102
+ desc: '(Default: 99) The percentile for evaluating metrics.'
103
+ option :post_scale_up_cooldown_seconds,
104
+ type: :numeric,
105
+ desc: '(Default: 60) The waiting period in seconds after '\
106
+ 'an automated scale-up before another scaling action can '\
107
+ 'be considered.'
108
+ option :post_scale_down_cooldown_seconds,
109
+ type: :numeric,
110
+ desc: '(Default: 300) The waiting period in seconds after '\
111
+ 'an automated scale-down before another scaling action can '\
112
+ 'be considered.'
113
+ option :post_release_cooldown_seconds,
114
+ type: :numeric,
115
+ desc: '(Default: 300) The time in seconds to wait '\
116
+ 'following a deploy before another scaling action can '\
117
+ 'be considered.'
118
+ option :mem_cpu_ratio_r_threshold,
119
+ type: :numeric,
120
+ desc: '(Default: 4.0) Establishes the ratio of Memory '\
121
+ '(in GB) to CPU (in CPUs) at which values exceeding the '\
122
+ 'threshold prompt a shift to an R (Memory Optimized) '\
123
+ 'profile.'
124
+ option :mem_cpu_ratio_c_threshold,
125
+ type: :numeric,
126
+ desc: '(Default: 2.0) Sets the Memory-to-CPU ratio '\
127
+ 'threshold, below which the service is transitioned to a '\
128
+ 'C (Compute Optimized) profile.'
129
+ option :mem_scale_up_threshold,
130
+ type: :numeric,
131
+ desc: '(Default: 0.9) Vertical autoscaling only - '\
132
+ 'Specifies the percentage of the current memory limit '\
133
+ 'at which the service’s memory usage triggers an '\
134
+ 'up-scaling action.'
135
+ option :mem_scale_down_threshold,
136
+ type: :numeric,
137
+ desc: '(Default: 0.75) Vertical autoscaling only - '\
138
+ 'Specifies the percentage of the current memory limit at '\
139
+ 'which the service’s memory usage triggers a '\
140
+ 'down-scaling action.'
141
+ option :minimum_memory,
142
+ type: :numeric,
143
+ desc: '(Default: 2048) Vertical autoscaling only - Sets '\
144
+ 'the lowest memory limit to which the service can be '\
145
+ 'scaled down by Autoscaler.'
146
+ option :maximum_memory,
147
+ type: :numeric,
148
+ desc: 'Vertical autoscaling only - Defines the upper '\
149
+ 'memory threshold, capping the maximum memory allocation'\
150
+ ' possible through Autoscaler. If blank, the container can'\
151
+ ' scale to the largest size available.'
152
+ option :min_cpu_threshold,
153
+ type: :numeric,
154
+ desc: 'Horizontal autoscaling only - Specifies the '\
155
+ 'percentage of the current CPU usage at which a '\
156
+ 'down-scaling action is triggered.'
157
+ option :max_cpu_threshold,
158
+ type: :numeric,
159
+ desc: 'Horizontal autoscaling only - Specifies the '\
160
+ 'percentage of the current CPU usage at which an '\
161
+ 'up-scaling action is triggered.'
162
+ option :min_containers,
163
+ type: :numeric,
164
+ desc: 'Horizontal autoscaling only - Sets the lowest'\
165
+ ' container count to which the service can be scaled down.'
166
+ option :max_containers,
167
+ type: :numeric,
168
+ desc: 'Horizontal autoscaling only - Sets the highest '\
169
+ 'container count to which the service can be scaled up to.'
170
+ option :scale_up_step,
171
+ type: :numeric,
172
+ desc: '(Default: 1) Horizontal autoscaling only - Sets '\
173
+ 'the amount of containers to add when autoscaling (ex: a '\
174
+ 'value of 2 will go from 1->3->5). Container count will '\
175
+ 'never exceed the configured maximum.'
176
+ option :scale_down_step,
177
+ type: :numeric,
178
+ desc: '(Default: 1) Horizontal autoscaling only - Sets '\
179
+ 'the amount of containers to remove when autoscaling (ex:'\
180
+ ' a value of 2 will go from 4->2->1). Container count '\
181
+ 'will never exceed the configured minimum.'
182
+ define_method 'services:sizing_policy:set' do |service|
183
+ service = ensure_service(options, service)
184
+ ignored_attrs = %i(autoscaling_type app environment remote)
185
+ args = options.except(*ignored_attrs)
186
+ args[:autoscaling] = options[:autoscaling_type]
187
+
188
+ sizing_policy = service.service_sizing_policy
189
+ if sizing_policy
190
+ sizing_policy.update!(**args)
191
+ else
192
+ service.create_service_sizing_policy!(**args)
193
+ end
194
+ end
47
195
  end
48
196
  end
49
197
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.22.0'.freeze
3
+ VERSION = '0.23.0'.freeze
4
4
  end
5
5
  end
@@ -79,6 +79,90 @@ describe Aptible::CLI::Agent do
79
79
  end
80
80
  end
81
81
 
82
+ describe '#services:sizing_policy' do
83
+ let(:base_options) { { app: app.handle } }
84
+
85
+ it 'returns the sizing policy' do
86
+ stub_options
87
+ service = Fabricate(:service, app: app, process_type: 'foo')
88
+ sizing_policy = Fabricate(:service_sizing_policy)
89
+ expect(service).to receive(:service_sizing_policy)
90
+ .and_return(sizing_policy)
91
+
92
+ subject.send('services:sizing_policy', 'foo')
93
+
94
+ out = captured_output_text
95
+ expect(out).to match(/Autoscaling Type: vertical/i)
96
+ expect(out).to match(/Metric Lookback Seconds: 1800/i)
97
+ expect(out).to match(/Percentile: 99.0/i)
98
+ expect(out).to match(/Post Scale Up Cooldown Seconds: 60/i)
99
+ expect(out).to match(/Post Scale Down Cooldown Seconds: 300/i)
100
+ expect(out).to match(/Post Release Cooldown Seconds: 300/i)
101
+ expect(out).to match(/Mem Cpu Ratio R Threshold: 4/i)
102
+ expect(out).to match(/Mem Cpu Ratio C Threshold: 2/i)
103
+ expect(out).to match(/Mem Scale Up Threshold: 0.9/i)
104
+ expect(out).to match(/Mem Scale Down Threshold: 0.75/i)
105
+ expect(out).to match(/Minimum Memory: 2048/i)
106
+ expect(out).to match(/Maximum Memory:/i)
107
+ expect(out).to match(/Min Cpu Threshold: 0.4/i)
108
+ expect(out).to match(/Max Cpu Threshold: 0.9/i)
109
+ expect(out).to match(/Min Containers: 2/i)
110
+ expect(out).to match(/Max Containers: 5/i)
111
+ expect(out).to match(/Scale Up Step: 1/i)
112
+ expect(out).to match(/Scale Down Step: 1/i)
113
+ end
114
+
115
+ it 'raises an error if the environment has no policy' do
116
+ stub_options
117
+ service = Fabricate(:service, app: app, process_type: 'foo')
118
+ expect(service).to receive(:service_sizing_policy).and_return(nil)
119
+ expect { subject.send('services:sizing_policy', 'foo') }
120
+ .to raise_error(/does not have a service sizing policy set/)
121
+ end
122
+ end
123
+
124
+ describe '#services:sizing_policy:set' do
125
+ let(:base_options) { { app: app.handle } }
126
+ let(:args) do
127
+ {
128
+ autoscaling_type: 'vertical',
129
+ mem_scale_down_threshold: 0.5,
130
+ scale_up_step: 2,
131
+ post_scale_down_cooldown_seconds: 3,
132
+ percentile: 93.2
133
+ }
134
+ end
135
+
136
+ it 'updates existing sizing policy' do
137
+ stub_options(**args)
138
+ service = Fabricate(:service, app: app, process_type: 'foo')
139
+ sizing_policy = double(sizing_policy)
140
+ expect(service).to receive(:service_sizing_policy)
141
+ .and_return(sizing_policy)
142
+
143
+ api_args = args.except(:autoscaling_type)
144
+ api_args[:autoscaling] = args[:autoscaling_type]
145
+
146
+ expect(sizing_policy).to receive(:update!)
147
+ .with(**api_args)
148
+
149
+ subject.send('services:sizing_policy:set', 'foo')
150
+ end
151
+
152
+ it 'creates a new sizing policy if necessary' do
153
+ stub_options(**args)
154
+ service = Fabricate(:service, app: app, process_type: 'foo')
155
+
156
+ api_args = args.except(:autoscaling_type)
157
+ api_args[:autoscaling] = args[:autoscaling_type]
158
+
159
+ expect(service).to receive(:create_service_sizing_policy!)
160
+ .with(**api_args)
161
+
162
+ subject.send('services:sizing_policy:set', 'foo')
163
+ end
164
+ end
165
+
82
166
  def stub_options(**opts)
83
167
  allow(subject).to receive(:options).and_return(base_options.merge(opts))
84
168
  end
@@ -0,0 +1,22 @@
1
+ class StubServiceSizingPolicy < OpenStruct; end
2
+
3
+ Fabricator(:service_sizing_policy, from: :stub_service_sizing_policy) do
4
+ autoscaling 'vertical'
5
+ metric_lookback_seconds 1800
6
+ percentile 99.0
7
+ post_scale_up_cooldown_seconds 60
8
+ post_scale_down_cooldown_seconds 300
9
+ post_release_cooldown_seconds 300
10
+ mem_cpu_ratio_r_threshold 4
11
+ mem_cpu_ratio_c_threshold 2
12
+ mem_scale_up_threshold 0.9
13
+ mem_scale_down_threshold 0.75
14
+ minimum_memory 2048
15
+ maximum_memory nil
16
+ min_cpu_threshold 0.4
17
+ max_cpu_threshold 0.9
18
+ min_containers 2
19
+ max_containers 5
20
+ scale_up_step 1
21
+ scale_down_step 1
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-10 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -455,6 +455,7 @@ files:
455
455
  - spec/fabricators/metric_drain_fabricator.rb
456
456
  - spec/fabricators/operation_fabricator.rb
457
457
  - spec/fabricators/service_fabricator.rb
458
+ - spec/fabricators/service_sizing_policy_fabricator.rb
458
459
  - spec/fabricators/stack_fabricator.rb
459
460
  - spec/fabricators/vhost_fabricator.rb
460
461
  - spec/mock/git
@@ -541,6 +542,7 @@ test_files:
541
542
  - spec/fabricators/metric_drain_fabricator.rb
542
543
  - spec/fabricators/operation_fabricator.rb
543
544
  - spec/fabricators/service_fabricator.rb
545
+ - spec/fabricators/service_sizing_policy_fabricator.rb
544
546
  - spec/fabricators/stack_fabricator.rb
545
547
  - spec/fabricators/vhost_fabricator.rb
546
548
  - spec/mock/git