Skip to content

Commit

Permalink
handled the case when there is no running pod available
Browse files Browse the repository at this point in the history
  • Loading branch information
rvarunrathod committed Jan 25, 2024
1 parent c73fd37 commit 847b710
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/forward/kubernetes/forwarder.go
Expand Up @@ -190,13 +190,19 @@ func (f *Forwarder) forwardLocal(ctx context.Context, selector string) error {
}

var runningPod apiv1.Pod
foundRunningPod := false

for _, pod := range pods.Items {
if isPodRunning(&pod) {
runningPod = pod
foundRunningPod = true
break
}
}

if !foundRunningPod {
return fmt.Errorf("No runnning pod available for selector '%s'", selector)
}

request := f.restClient.Post().Resource("pods").Namespace(f.namespace).Name(runningPod.Name).SubResource("portforward")

Expand Down

0 comments on commit 847b710

Please sign in to comment.