Additional logging could be useful when a service has no endpoints defined
I think there could be some benefit to adding a log line to the sync method inside of k8s.go
In that method there is some processing done on the endpoints retrieved from Kubernetes. In the case of an error retrieving the key a log line is printed however if the key is successfully retrieved but has no available endpoints there are no logs printed that indicate that there was is an issue that would prevent metallb from advertising the load balancer ip that was assigned to the service.
The actual issue this log would help identify is a configuration error in the service definition where the selector does not match a label in the deployment. When this happens a kubectl get all will show the service with an external ip defined but metallb doesn't respond to arp requests. The issue is apparent if you run kubectl get endpoints however as someone who is trying to learn Kubernetes this wasn't something I was familiar with at the time. With the log line I'm suggesting it could provide a hint at where to look for someone like myself.
Since I resolved my issue I encountered someone else on slack within a few days that ran into the same issue that I did.
My suggestion is to add a log line inside the if !exists block in the sync method. I did some testing by deploying my custom speaker and as far as I can tell this doesn't print off any logs when the service is defined correctly.
I can submit a pull request if this sound like a reasonable thing to add.
James
@Matoch Making MetalLB easier to troubleshoot, even if it's not directly an issue in MetalLB is always reasonable, please send a PR
Closing this, we are propagating the delete reason in the logs: https://github.com/metallb/metallb/blob/909c0ca5d6eca570fadc339bcddb1902a3326dea/speaker/main.go#L453