44 "context"
55 "fmt"
66 "github.com/loft-sh/devspace/pkg/devspace/config/localcache"
7+ "github.com/loft-sh/devspace/pkg/devspace/kill"
78 "github.com/loft-sh/devspace/pkg/devspace/kubectl/util"
89 "github.com/loft-sh/devspace/pkg/devspace/upgrade"
910 "github.com/loft-sh/devspace/pkg/util/idle"
@@ -118,7 +119,7 @@ func NewClientFromContext(context, namespace string, switchContext bool, kubeLoa
118119 requestType : "Regular" ,
119120 callback : func (response * http.Response ) {
120121 if response .Header .Get ("X-DevSpace-Response-Type" ) == "Blocked" {
121- log . GetInstance (). Fatalf ("Targeted Kubernetes environment has begun sleeping. Please restart DevSpace to wake up the environment" )
122+ kill . StopDevSpace ("Targeted Kubernetes environment has begun sleeping. Please restart DevSpace to wake up the environment" )
122123 }
123124 },
124125 }
@@ -329,7 +330,7 @@ func wakeUpAndPing(ctx context.Context, client Client, log log.Logger) error {
329330 requestType : "Ping" ,
330331 callback : func (response * http.Response ) {
331332 if response .Header .Get ("X-DevSpace-Response-Type" ) == "Blocked" {
332- log . Fatalf ("Targeted Kubernetes environment has begun sleeping. Please restart DevSpace to wake up the environment" )
333+ kill . StopDevSpace ("Targeted Kubernetes environment has begun sleeping. Please restart DevSpace to wake up the environment" )
333334 }
334335 },
335336 }
@@ -356,7 +357,7 @@ func wakeUpAndPing(ctx context.Context, client Client, log log.Logger) error {
356357 if err != nil {
357358 log .Debugf ("Error pinging Kubernetes environment: %v" , err )
358359 }
359- }, time .Minute * 3 )
360+ }, time .Minute )
360361 }()
361362
362363 return nil
@@ -416,9 +417,16 @@ func wakeUp(ctx context.Context, client Client, log log.Logger) error {
416417 log .Infof ("DevSpace is waking up the Kubernetes environment, please wait a moment..." )
417418
418419 // wake up the environment
419- _ , err = kubeClient .CoreV1 ().Pods (client .Namespace ()).List (ctx , metav1.ListOptions {LabelSelector : "devspace=wakeup" })
420- if err != nil {
421- return errors .Wrap (err , "error waking up the environment" )
420+ waitErr := wait .PollImmediate (time .Second , time .Second * 30 , func () (done bool , err error ) {
421+ _ , err = kubeClient .CoreV1 ().Pods (client .Namespace ()).List (ctx , metav1.ListOptions {LabelSelector : "devspace=wakeup" })
422+ if err != nil {
423+ return false , nil
424+ }
425+
426+ return true , nil
427+ })
428+ if waitErr != nil {
429+ return errors .Wrap (err , "wake up environment" )
422430 }
423431
424432 return nil
0 commit comments