From 8315af1c5debf6aec99dda6eccb4d16854e49ffc Mon Sep 17 00:00:00 2001 From: Delyan Raychev Date: Fri, 11 Oct 2019 11:25:12 -0700 Subject: [PATCH] Avoid nil pointer exception when Ingress has no Backends (#578) --- pkg/appgw/certificates.go | 2 +- pkg/appgw/validators.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/appgw/certificates.go b/pkg/appgw/certificates.go index db3bffd26..9f2c0c4a3 100644 --- a/pkg/appgw/certificates.go +++ b/pkg/appgw/certificates.go @@ -38,7 +38,7 @@ func (c *appGwConfigBuilder) getSslCertificates(cbCtx *ConfigBuilderContext) *[] sslCertificates = append(sslCertificates, c.newCert(secretID, cert)) } - if cbCtx.EnvVariables.EnableBrownfieldDeployment { + if cbCtx.EnvVariables.EnableBrownfieldDeployment && c.appGw.SslCertificates != nil { // MergePools would produce unique list of pools based on Name. Blacklisted pools, which have the same name // as a managed pool would be overwritten. sslCertificates = brownfield.MergeCerts(*c.appGw.SslCertificates, sslCertificates) diff --git a/pkg/appgw/validators.go b/pkg/appgw/validators.go index 7b40800de..2e0f2ffe1 100644 --- a/pkg/appgw/validators.go +++ b/pkg/appgw/validators.go @@ -50,6 +50,9 @@ func validateServiceDefinition(eventRecorder record.EventRecorder, config *n.App continue } for pathIdx := range rule.HTTP.Paths { + if ingress.Spec.Backend == nil { + continue + } path := &rule.HTTP.Paths[pathIdx] backendIDs[generateBackendID(ingress, rule, path, &path.Backend)] = nil }