Controller: Fix panic in alternative backend merging. (#11789)

This commit is contained in:
chengjoey 2024-08-13 16:37:37 +08:00 committed by GitHub
parent f19e9265b0
commit e5c29d1ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 78 additions and 2 deletions

View file

@ -1594,7 +1594,11 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
altEqualsPri := false
for _, loc := range servers[defServerName].Locations {
priUps := upstreams[loc.Backend]
priUps, ok := upstreams[loc.Backend]
if !ok {
klog.Warningf("cannot find primary backend %s for location %s%s", loc.Backend, servers[defServerName].Hostname, loc.Path)
continue
}
altEqualsPri = altUps.Name == priUps.Name
if altEqualsPri {
klog.Warningf("alternative upstream %s in Ingress %s/%s is primary upstream in Other Ingress for location %s%s!",
@ -1653,7 +1657,11 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
// find matching paths
for _, loc := range server.Locations {
priUps := upstreams[loc.Backend]
priUps, ok := upstreams[loc.Backend]
if !ok {
klog.Warningf("cannot find primary backend %s for location %s%s", loc.Backend, server.Hostname, loc.Path)
continue
}
altEqualsPri = altUps.Name == priUps.Name
if altEqualsPri {
klog.Warningf("alternative upstream %s in Ingress %s/%s is primary upstream in Other Ingress for location %s%s!",