diff --git a/pkg/policy/backend/consul/consul.go b/pkg/policy/backend/consul/consul.go index 18cb49e..10eb625 100644 --- a/pkg/policy/backend/consul/consul.go +++ b/pkg/policy/backend/consul/consul.go @@ -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 { diff --git a/pkg/policy/v1/policies.go b/pkg/policy/v1/policies.go index 5ffac8f..88008cc 100644 --- a/pkg/policy/v1/policies.go +++ b/pkg/policy/v1/policies.go @@ -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 }