Browse Source

cmd/k8s-operator: don't proceed with Ingress that has no valid backends (#10919)

Do not provision resources for a tailscale Ingress that has no valid backends.

Updates tailscale/tailscale#10910

Signed-off-by: Irbe Krumina <[email protected]>
Irbe Krumina 2 years ago
parent
commit
370ec6b46b
1 changed files with 6 additions and 0 deletions
  1. 6 0
      cmd/k8s-operator/ingress.go

+ 6 - 0
cmd/k8s-operator/ingress.go

@@ -230,6 +230,12 @@ func (a *IngressReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
 		}
 	}
 
+	if len(web.Handlers) == 0 {
+		logger.Warn("Ingress contains no valid backends")
+		a.recorder.Eventf(ing, corev1.EventTypeWarning, "NoValidBackends", "no valid backends")
+		return nil
+	}
+
 	crl := childResourceLabels(ing.Name, ing.Namespace, "ingress")
 	var tags []string
 	if tstr, ok := ing.Annotations[AnnotationTags]; ok {