diff --git a/pkg/issuer/acme/http/ingress.go b/pkg/issuer/acme/http/ingress.go index fb53b1da9..81b92fc73 100644 --- a/pkg/issuer/acme/http/ingress.go +++ b/pkg/issuer/acme/http/ingress.go @@ -233,23 +233,30 @@ func (s *Solver) cleanupIngresses(ch *v1alpha1.Challenge) error { ingPathToDel := solverPathFn(ch.Spec.Token) var ingRules []extv1beta1.IngressRule for _, rule := range ing.Spec.Rules { - if rule.Host == ch.Spec.DNSName { - if rule.HTTP == nil { - ingRules = append(ingRules, rule) - continue - } - // check the rule for paths. If we find the ingress path we need to - // delete here, delete it - for i, path := range rule.HTTP.Paths { - if path.Path == ingPathToDel { - rule.HTTP.Paths = append(rule.HTTP.Paths[:i], rule.HTTP.Paths[i+1:]...) - } - } - // if there are still paths level on this rule, we should retain it - if len(rule.HTTP.Paths) > 0 { - ingRules = append(ingRules, rule) + // always retain rules that are not for the same DNSName + if rule.Host != ch.Spec.DNSName { + ingRules = append(ingRules, rule) + continue + } + + // always retain rules that don't specify `HTTP` + if rule.HTTP == nil { + ingRules = append(ingRules, rule) + continue + } + + // check the rule for paths. If we find the ingress path we need to + // delete here, delete it + for i, path := range rule.HTTP.Paths { + if path.Path == ingPathToDel { + rule.HTTP.Paths = append(rule.HTTP.Paths[:i], rule.HTTP.Paths[i+1:]...) } } + + // if there are still paths level on this rule, we should retain it + if len(rule.HTTP.Paths) > 0 { + ingRules = append(ingRules, rule) + } } ing.Spec.Rules = ingRules