Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Fix issue when autoscaling job with mix of groups w/wo policies.
Browse files Browse the repository at this point in the history
Jobs which had 2 groups, one which had a scaling policy and one
which did not would panic when running through the autoscaler.
This was caused by an unsafe check to see if an allocation was
part of a group which had a scaling policy.

Closes #70
  • Loading branch information
jrasell committed Oct 11, 2019
1 parent 6f829f6 commit 2866310
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/autoscale/autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func (a *AutoScale) getJobAllocations(jobID string, policies map[string]*policy.

for i := range allocs {

if !policies[allocs[i].TaskGroup].Enabled {
// GH-70: jobs can have a mix of groups with scaling policies, and groups without. We need
// to safely check the policy.
if v, ok := policies[allocs[i].TaskGroup]; !ok {
break
} else {
if !v.Enabled {
break
}
}

if !(allocs[i].ClientStatus == nomad.AllocClientStatusRunning || allocs[i].ClientStatus == nomad.AllocClientStatusPending) {
Expand Down

0 comments on commit 2866310

Please sign in to comment.