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

No pods running error #254

Open
giulianob opened this issue Feb 21, 2023 · 0 comments
Open

No pods running error #254

giulianob opened this issue Feb 21, 2023 · 0 comments

Comments

@giulianob
Copy link

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
        }
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant