Fix panic on multiple non-matching canary

This commit is contained in:
Per Bernhardt 2019-03-04 11:20:54 +00:00 committed by Per Bernhardt
parent 79c52cf094
commit 8a40e82ffb
3 changed files with 56 additions and 1 deletions

View file

@ -1162,7 +1162,7 @@ func nonCanaryIngressExists(ingresses []*ingress.Ingress, canaryIngresses []*ing
// 2) primary name is not the default upstream
// 3) the primary has a server
func canMergeBackend(primary *ingress.Backend, alternative *ingress.Backend) bool {
return primary.Name != alternative.Name && primary.Name != defUpstreamName && !primary.NoServer
return alternative != nil && primary.Name != alternative.Name && primary.Name != defUpstreamName && !primary.NoServer
}
// Performs the merge action and checks to ensure that one two alternative backends do not merge into each other
@ -1224,6 +1224,11 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
altUps := upstreams[upsName]
if altUps == nil {
klog.Errorf("alternative backend %s has already be removed", upsName)
continue
}
merged := false
server, ok := servers[rule.Host]