From 0712b6e15d52f0f35588501d312492d04a53fa5a Mon Sep 17 00:00:00 2001 From: Michal Flendrich Date: Wed, 24 May 2023 14:11:53 +0200 Subject: [PATCH] feat: LB IP missing no longer an error After this commit a LoadBalancer service that has no external IP addresses listed in the status is no longer a reconciliation error. We're changing the semtantics from "KIC failed to reconcile" to "KIC reconciled this publish service okay, it just happens to have zero public IP addresses". Why are we making this change? To allow for a more user-friendly message than this: [kong-controller-75896f8d9b-4hwbq] time="2023-05-24T11:26:03Z" level=error msg="Reconciler error" error="waiting for addresses to be provisioned for publish service kong/kong-proxy-proxy" logger=controllers.Ingress.netv1 reconcileID="\"f97e4634-0d72-4882-bdd9-9a5b2e5339b6\"" --- internal/manager/setup.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/manager/setup.go b/internal/manager/setup.go index 62c6d2f93d..c8d7bef78e 100644 --- a/internal/manager/setup.go +++ b/internal/manager/setup.go @@ -197,11 +197,11 @@ func setupDataplaneAddressFinder(mgrc client.Client, c *Config, log logr.Logger) return nil, nil, nil } - defaultAddressFinder, err := buildDataplaneAddressFinder(mgrc, c.PublishStatusAddress, c.PublishService) + defaultAddressFinder, err := buildDataplaneAddressFinder(mgrc, c.PublishStatusAddress, c.PublishService, log) if err != nil { return nil, nil, fmt.Errorf("status updates enabled but no method to determine data-plane addresses: %w", err) } - udpAddressFinder, err := buildDataplaneAddressFinder(mgrc, c.PublishStatusAddressUDP, c.PublishServiceUDP) + udpAddressFinder, err := buildDataplaneAddressFinder(mgrc, c.PublishStatusAddressUDP, c.PublishServiceUDP, log) if err != nil { log.Info("falling back to a default address finder for UDP", "reason", err.Error()) udpAddressFinder = defaultAddressFinder @@ -210,7 +210,7 @@ func setupDataplaneAddressFinder(mgrc client.Client, c *Config, log logr.Logger) return defaultAddressFinder, udpAddressFinder, nil } -func buildDataplaneAddressFinder(mgrc client.Client, publishStatusAddress []string, publishServiceNN OptionalNamespacedName) (*dataplane.AddressFinder, error) { +func buildDataplaneAddressFinder(mgrc client.Client, publishStatusAddress []string, publishServiceNN OptionalNamespacedName, logger logr.Logger) (*dataplane.AddressFinder, error) { addressFinder := dataplane.NewAddressFinder() if len(publishStatusAddress) > 0 { @@ -218,14 +218,14 @@ func buildDataplaneAddressFinder(mgrc client.Client, publishStatusAddress []stri return addressFinder, nil } if serviceNN, ok := publishServiceNN.Get(); ok { - addressFinder.SetGetter(generateAddressFinderGetter(mgrc, serviceNN)) + addressFinder.SetGetter(generateAddressFinderGetter(mgrc, serviceNN, logger)) return addressFinder, nil } return nil, errors.New("no publish status address or publish service were provided") } -func generateAddressFinderGetter(mgrc client.Client, publishServiceNn k8stypes.NamespacedName) func(context.Context) ([]string, error) { +func generateAddressFinderGetter(mgrc client.Client, publishServiceNn k8stypes.NamespacedName, logger logr.Logger) func(context.Context) ([]string, error) { return func(ctx context.Context) ([]string, error) { svc := new(corev1.Service) if err := mgrc.Get(ctx, publishServiceNn, svc); err != nil { @@ -243,14 +243,14 @@ func generateAddressFinderGetter(mgrc client.Client, publishServiceNn k8stypes.N addrs = append(addrs, lbaddr.Hostname) } } + + if len(svc.Status.LoadBalancer.Ingress) == 0 { + logger.Info("LoadBalancer service has no external address", "service", publishServiceNn) + } default: addrs = append(addrs, svc.Spec.ClusterIPs...) } - if len(addrs) == 0 { - return nil, fmt.Errorf("waiting for addresses to be provisioned for publish service %s", publishServiceNn) - } - return addrs, nil } }