Skip to content

Commit e8bfc3e

Browse files
authored
Merge pull request #831 from autonomic-ai/fix-ingress-no-http-crash
Fix crash due to missing ingress http block
2 parents 6513ae2 + 4d0d772 commit e8bfc3e

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

internal/store/ingress.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,14 @@ var (
104104
GenerateFunc: wrapIngressFunc(func(i *v1beta1.Ingress) *metric.Family {
105105
ms := []*metric.Metric{}
106106
for _, rule := range i.Spec.Rules {
107-
for _, path := range rule.HTTP.Paths {
108-
ms = append(ms, &metric.Metric{
109-
LabelKeys: []string{"host", "path", "service_name", "service_port"},
110-
LabelValues: []string{rule.Host, path.Path, path.Backend.ServiceName, path.Backend.ServicePort.String()},
111-
Value: 1,
112-
})
107+
if rule.HTTP != nil {
108+
for _, path := range rule.HTTP.Paths {
109+
ms = append(ms, &metric.Metric{
110+
LabelKeys: []string{"host", "path", "service_name", "service_port"},
111+
LabelValues: []string{rule.Host, path.Path, path.Backend.ServiceName, path.Backend.ServicePort.String()},
112+
Value: 1,
113+
})
114+
}
113115
}
114116
}
115117
return &metric.Family{

internal/store/ingress_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ func TestIngressStore(t *testing.T) {
139139
},
140140
},
141141
},
142+
{
143+
Host: "somehost2",
144+
},
142145
},
143146
},
144147
},

0 commit comments

Comments
 (0)