Skip to content

Commit

Permalink
Fix threhold plugin logic when there are not enough metrics within bo…
Browse files Browse the repository at this point in the history
…unds (#537)
  • Loading branch information
lgfa29 authored Nov 15, 2021
1 parent 9bb87f1 commit c4c48b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ IMPROVEMENTS:

BUG FIXES:
* scaleutils: Fixed `least_busy` node selector on clusters running servers older than v1.0.0 [[GH-508](https://github.com/hashicorp/nomad-autoscaler/pull/508)]
* plugins/strategy/threshold: Fixed an issue where the wrong scaling action was taken even when the threshold was no met [[GH-537](https://github.com/hashicorp/nomad-autoscaler/pull/537)]

## 0.3.3 (May 03, 2021)

Expand Down
3 changes: 2 additions & 1 deletion plugins/builtin/strategy/threshold/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func (s *StrategyPlugin) Run(eval *sdk.ScalingCheckEvaluation, count int64) (*sd
// Check if we have enough data points within bounds.
if !withinBounds(logger, eval.Metrics, config) {
logger.Trace("not enough data points within bounds")
return nil, nil
eval.Action.Direction = sdk.ScaleDirectionNone
return eval, nil
}

// Calculate new count.
Expand Down
4 changes: 3 additions & 1 deletion plugins/builtin/strategy/threshold/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ func TestThresholdPlugin(t *testing.T) {
"upper_bound": "20",
"delta": "1",
},
expectedAction: nil,
expectedAction: &sdk.ScalingAction{
Direction: sdk.ScaleDirectionNone,
},
},
{
name: "custom trigger value",
Expand Down

0 comments on commit c4c48b3

Please sign in to comment.