Skip to content

Commit 94e4cc7

Browse files
committed
Add capability to disable fallback in a phpa config
1 parent 8d84465 commit 94e4cc7

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

examples/graphite-config-example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 'v1'
22
kind: 'PHPAConfig'
33
verbose: 'true'
44
dryRun: 'true'
5+
fallbackEnabled: 'false'
56
# cool down time(in seconds) after performing an action
67
actionCooldown: '300'
78
# interval (in seconds) between consecutive checks of phpa for this deployment

examples/influx-config-example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ kind: 'PHPAConfig'
44
verbose: 'true'
55
# interval (in seconds) between consecutive checks of phpa for this deployment
66
interval: '300'
7+
fallbackEnabled: 'false'
78
deployment:
89
name: 'backend-staging-deployment'
910
namespace: 'backend-app'

lib/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config
2222
:deploy_name, :namespace, :adaptor, :server, \
2323
:min_replicas, :max_replicas, :fallback_replicas, \
2424
:metric_name, :metric_type, :metric_threshold, :metric_margin, \
25-
:interval
25+
:interval, :fallback_enabled
2626

2727
def initialize(file_path)
2828
config = YAML.load_file(file_path)
@@ -35,6 +35,7 @@ def initialize(file_path)
3535

3636
@verbose = config[:verbose] == 'true' ? true : false
3737
@dry_run = config[:dryRun] == 'true' ? true : false
38+
@fallback_enabled = config[:fallbackEnabled] == 'false' ? false : true
3839
action_cooldown = config[:actionCooldown] || DEFAULT_ACTION_COOLDOWN
3940
@action_cooldown = action_cooldown.to_i
4041
interval = config[:interval] || DEFAULT_INTERVAL

lib/kubernetes_runner.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def perform_action(config)
5050
result[:failed] = true
5151
return result
5252
when :unknown
53+
unless config.fallback_enabled
54+
log_txt "Action: #{action}, Not triggering fallback as "\
55+
"fallback is not enabled"
56+
scale_to = current
57+
end
5358
# we went to reach to fallback_replicas slowly
5459
scale_to = fallback_scale_to(current, config.fallback_replicas)
5560
log_txt "Action: #{action}, fallback to #{scale_to} replicas " \

0 commit comments

Comments
 (0)