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

Commit

Permalink
pkg/policy: fix panic in get policy by job and group
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcatominey committed Sep 25, 2019
1 parent 7ad44ee commit 3857923
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/policy/backend/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (p *PolicyBackend) GetJobGroupPolicy(job, group string) (*policy.GroupScali
return nil, err
}

if kv == nil {
return nil, nil
}

out := &policy.GroupScalingPolicy{}

if err := json.Unmarshal(kv.Value, out); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/policy/v1/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (p *Policy) GetJobGroupPolicy(w http.ResponseWriter, r *http.Request) {
return
}

if *gPolicy == (policy.GroupScalingPolicy{}) || gPolicy == nil {
if gPolicy == nil || *gPolicy == (policy.GroupScalingPolicy{}) {
http.NotFound(w, r)
return
}
Expand Down

0 comments on commit 3857923

Please sign in to comment.