@@ -34,8 +34,10 @@ import (
34
34
"github.com/weaveworks/weave-gitops/pkg/s3"
35
35
"github.com/weaveworks/weave-gitops/pkg/validate"
36
36
"github.com/weaveworks/weave-gitops/pkg/version"
37
+ corev1 "k8s.io/api/core/v1"
37
38
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
38
39
"k8s.io/apimachinery/pkg/types"
40
+ "k8s.io/apimachinery/pkg/util/wait"
39
41
"k8s.io/cli-runtime/pkg/genericclioptions"
40
42
"k8s.io/client-go/discovery"
41
43
"k8s.io/client-go/rest"
@@ -897,12 +899,26 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
897
899
// get pod from specMap
898
900
namespacedName := types.NamespacedName {Namespace : specMap .Namespace , Name : specMap .Name }
899
901
900
- pod , err := run .GetPodFromResourceDescription (thisCtx , namespacedName , specMap .Kind , kubeClient )
901
- if err != nil {
902
- log .Failuref ("Error getting pod from specMap: %v" , err )
902
+ var (
903
+ pod * corev1.Pod
904
+ podErr error
905
+ )
906
+
907
+ if pollErr := wait .PollImmediate (2 * time .Second , flags .Timeout , func () (bool , error ) {
908
+ pod , podErr = run .GetPodFromResourceDescription (thisCtx , namespacedName , specMap .Kind , kubeClient )
909
+ if pod != nil && podErr == nil {
910
+ return true , nil
911
+ }
912
+
913
+ log .Waitingf ("Waiting for a pod from specMap: %v" , podErr )
914
+ return false , nil
915
+ }); pollErr != nil {
916
+ log .Failuref ("Waiting for a pod from specMap: %v" , pollErr )
903
917
}
904
918
905
- if pod != nil {
919
+ if pod == nil {
920
+ log .Failuref ("Error getting pod from specMap" )
921
+ } else /* pod is available */ {
906
922
waitFwd := make (chan struct {}, 1 )
907
923
readyChannel := make (chan struct {})
908
924
cancelPortFwd = func () {
0 commit comments