When a new service comes up but the pods are still starting up, I get a no pods error as the watcher tries too quickly to start forwarding ports. I added a retry and fixes it for me. Is this something I could PR or is there a better solution?
func (svcFwd *ServiceFWD) SyncPodForwards(force bool) {
sync := func() {
defer func() { svcFwd.LastSyncedAt = time.Now() }()
var k8sPods []v1.Pod;
for i := 1; i <= 3 || len(k8sPods) > 0; i++ {
k8sPods = svcFwd.GetPodsForService()
if len(k8sPods) > 0 {
break;
}
log.Debugf("No Running Pods returned for service %s, attempt %d", svcFwd, i)
time.Sleep(5 * time.Second)
}
// If no pods are found currently. Will try again next re-sync period.
if len(k8sPods) == 0 {
log.Warnf("WARNING: No Running Pods returned for service %s", svcFwd)
return
}
....
When a new service comes up but the pods are still starting up, I get a no pods error as the watcher tries too quickly to start forwarding ports. I added a retry and fixes it for me. Is this something I could PR or is there a better solution?