From 438eaec971774b2e30e97aa640abd5cfe8b3ef40 Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Wed, 5 Feb 2020 16:21:01 +0100 Subject: [PATCH 1/3] fix(helm): Don't wait for service to be ready when external IP are set Resolves #7513 As the externalIPs are not managed by k8s (according to the doc: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#servicespec-v1-core) helm should not wait for services which set al least one externalIPs. Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index f0005a61e..74b1fe6fb 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -188,12 +188,24 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { } // Make sure the service is not explicitly set to "None" before checking the IP - if (s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "") || - // This checks if the service has a LoadBalancer and that balancer has an Ingress defined - (s.Spec.Type == corev1.ServiceTypeLoadBalancer && s.Status.LoadBalancer.Ingress == nil) { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { return false } + + // This checks if the service has a LoadBalancer and that balancer has an Ingress defined + if s.Spec.Type == corev1.ServiceTypeLoadBalancer { + // do not wait when at least 1 external IP is set + if len(s.Spec.ExternalIPs) > 0 { + w.log("Service has externaIPs addresses: %s/%s (%v)", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) + return true + } + + if s.Status.LoadBalancer.Ingress == nil { + w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + return false + } + } + return true } From 077503f17502ea2ad59d73a08897f238dc72ebb0 Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Fri, 7 Feb 2020 19:28:30 +0100 Subject: [PATCH 2/3] fix(helm): Reworded logs for clarity Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 74b1fe6fb..7ea02d382 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -189,6 +189,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { // Make sure the service is not explicitly set to "None" before checking the IP if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { + w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } @@ -196,7 +197,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { if s.Spec.Type == corev1.ServiceTypeLoadBalancer { // do not wait when at least 1 external IP is set if len(s.Spec.ExternalIPs) > 0 { - w.log("Service has externaIPs addresses: %s/%s (%v)", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) + w.log("Service %s/%s has external IP addresses (%v), marking as ready", s.GetNamespace(), s.GetName(), s.Spec.ExternalIPs) return true } From af0007c9087c3e714aafc2bdac80bb55df6dbffd Mon Sep 17 00:00:00 2001 From: Federico Bevione Date: Tue, 11 Feb 2020 09:53:32 +0100 Subject: [PATCH 3/3] fix(helm): improved logs Signed-off-by: Federico Bevione --- pkg/kube/wait.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index 7ea02d382..0254a60bb 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -189,7 +189,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { // Make sure the service is not explicitly set to "None" before checking the IP if s.Spec.ClusterIP != corev1.ClusterIPNone && s.Spec.ClusterIP == "" { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + w.log("Service does not have cluster IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } @@ -202,7 +202,7 @@ func (w *waiter) serviceReady(s *corev1.Service) bool { } if s.Status.LoadBalancer.Ingress == nil { - w.log("Service does not have IP address: %s/%s", s.GetNamespace(), s.GetName()) + w.log("Service does not have load balancer ingress IP address: %s/%s", s.GetNamespace(), s.GetName()) return false } }