@@ -165,9 +165,12 @@ func (m *Manager) Close() {
165
165
166
166
// StartWorkspace creates a new running workspace within the manager's cluster
167
167
func (m * Manager ) StartWorkspace (_ context.Context , req * api.StartWorkspaceRequest ) (res * api.StartWorkspaceResponse , err error ) {
168
+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Minute )
169
+ defer cancel ()
170
+
168
171
owi := log .LogContext (req .Metadata .Owner , req .Metadata .MetaId , req .Id , req .Metadata .GetProject (), req .Metadata .GetTeam ())
169
172
clog := log .WithFields (owi )
170
- span , ctx := tracing .FromContext (context . Background () , "StartWorkspace" )
173
+ span , ctx := tracing .FromContext (ctx , "StartWorkspace" )
171
174
tracing .LogRequestSafe (span , req )
172
175
tracing .ApplyOWI (span , owi )
173
176
defer tracing .FinishSpan (span , & err )
@@ -314,8 +317,12 @@ func (m *Manager) StartWorkspace(_ context.Context, req *api.StartWorkspaceReque
314
317
return nil , err
315
318
}
316
319
317
- err = wait .PollWithContext (ctx , 100 * time .Millisecond , 10 * time .Minute , podRunning (m .Clientset , pod .Name , pod .Namespace ))
320
+ // if we reach this point the pod is created
321
+ // in case the context is canceled or a timeout happens we should delete the pod?
322
+
323
+ err = wait .PollImmediateWithContext (ctx , 100 * time .Millisecond , 7 * time .Minute , podRunning (m .Clientset , pod .Name , pod .Namespace ))
318
324
if err != nil {
325
+ clog .WithError (err ).WithField ("req" , req ).WithField ("pod" , pod .Name ).Warn ("was unable to start workspace" )
319
326
return nil , xerrors .Errorf ("workspace pod never reached Running state: %w" , err )
320
327
}
321
328
@@ -326,7 +333,7 @@ func (m *Manager) StartWorkspace(_ context.Context, req *api.StartWorkspaceReque
326
333
return nil , xerrors .Errorf ("unable to get workspace pod %s: %w" , pod .Name , err )
327
334
}
328
335
329
- err = wait .PollWithContext (ctx , 100 * time .Millisecond , 5 * time .Minute , pvcRunning (m .Clientset , pvc .Name , pvc .Namespace ))
336
+ err = wait .PollImmediateWithContext (ctx , 100 * time .Millisecond , 5 * time .Minute , pvcRunning (m .Clientset , pvc .Name , pvc .Namespace ))
330
337
if err != nil {
331
338
if startContext .VolumeSnapshot != nil && startContext .VolumeSnapshot .VolumeSnapshotName != "" {
332
339
m .eventRecorder .Eventf (pod , corev1 .EventTypeWarning , "PersistentVolumeClaim" , "PVC %q restore from volume snapshot %q failed %v" , pvc .Name , startContext .VolumeSnapshot .VolumeSnapshotName , err )
0 commit comments