Skip to content

Commit

Permalink
Merge pull request #831 from autonomic-ai/fix-ingress-no-http-crash
Browse files Browse the repository at this point in the history
Fix crash due to missing ingress http block
  • Loading branch information
k8s-ci-robot committed Jul 18, 2019
2 parents 6513ae2 + 4d0d772 commit e8bfc3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/store/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ var (
GenerateFunc: wrapIngressFunc(func(i *v1beta1.Ingress) *metric.Family {
ms := []*metric.Metric{}
for _, rule := range i.Spec.Rules {
for _, path := range rule.HTTP.Paths {
ms = append(ms, &metric.Metric{
LabelKeys: []string{"host", "path", "service_name", "service_port"},
LabelValues: []string{rule.Host, path.Path, path.Backend.ServiceName, path.Backend.ServicePort.String()},
Value: 1,
})
if rule.HTTP != nil {
for _, path := range rule.HTTP.Paths {
ms = append(ms, &metric.Metric{
LabelKeys: []string{"host", "path", "service_name", "service_port"},
LabelValues: []string{rule.Host, path.Path, path.Backend.ServiceName, path.Backend.ServicePort.String()},
Value: 1,
})
}
}
}
return &metric.Family{
Expand Down
3 changes: 3 additions & 0 deletions internal/store/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func TestIngressStore(t *testing.T) {
},
},
},
{
Host: "somehost2",
},
},
},
},
Expand Down

0 comments on commit e8bfc3e

Please sign in to comment.