Skip to content

Commit

Permalink
Improve log output for Services with no LoadBalancer IP (#14788)
Browse files Browse the repository at this point in the history
  • Loading branch information
lou-lan authored Jan 15, 2024
1 parent 564e72b commit 752314e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/default-domain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func lookupConfigMap(ctx context.Context, kubeClient kubernetes.Interface, name
return kubeClient.CoreV1().ConfigMaps(system.Namespace()).Get(ctx, name, metav1.GetOptions{})
}

func findGatewayAddress(ctx context.Context, kubeclient kubernetes.Interface, client *netclient.Clientset) (*corev1.LoadBalancerIngress, error) {
func findGatewayAddress(ctx context.Context, kubeclient kubernetes.Interface, client *netclient.Clientset, logging *zap.SugaredLogger) (*corev1.LoadBalancerIngress, error) {
netCM, err := lookupConfigMap(ctx, kubeclient, netcfg.ConfigMapName)
if err != nil {
return nil, err
Expand Down Expand Up @@ -154,6 +154,9 @@ func findGatewayAddress(ctx context.Context, kubeclient kubernetes.Interface, cl
if err != nil {
return true, err
}
if len(svc.Status.LoadBalancer.Ingress) == 0 {
logging.Warnf("Service %s/%s does not have an ingress IP assigned to its LoadBalancer yet", namespace, name)
}
return len(svc.Status.LoadBalancer.Ingress) != 0, nil
}); err != nil {
return nil, err
Expand Down Expand Up @@ -196,7 +199,7 @@ func main() {
go server.ListenAndServe()

// Determine the address of the gateway service.
address, err := findGatewayAddress(ctx, kubeClient, client)
address, err := findGatewayAddress(ctx, kubeClient, client, logger)
if err != nil {
logger.Fatalw("Error finding gateway address", zap.Error(err))
}
Expand Down

0 comments on commit 752314e

Please sign in to comment.