Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LB IP missing no longer an error #4066

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions internal/manager/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -210,22 +210,22 @@ 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 {
addressFinder.SetOverrides(publishStatusAddress)
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 {
Expand All @@ -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
}
}
Expand Down