Skip to content

Commit aaf5f33

Browse files
authored
[supervisor] fix #3714: return partial worksapce info if content is not ready (#3716)
1 parent 9d25b25 commit aaf5f33

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

components/supervisor/pkg/supervisor/services.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ func (rt *remoteTokenProvider) GetToken(ctx context.Context, req *api.GetTokenRe
558558

559559
// InfoService implements the api.InfoService
560560
type InfoService struct {
561-
cfg *Config
561+
cfg *Config
562+
ContentState ContentState
562563
}
563564

564565
// RegisterGRPC registers the gRPC info service
@@ -591,14 +592,17 @@ func (is *InfoService) WorkspaceInfo(context.Context, *api.WorkspaceInfoRequest)
591592
}
592593
}
593594

594-
stat, err := os.Stat(is.cfg.WorkspaceRoot)
595-
if err != nil {
596-
return nil, status.Error(codes.Internal, err.Error())
597-
}
598-
if stat.IsDir() {
599-
resp.WorkspaceLocation = &api.WorkspaceInfoResponse_WorkspaceLocationFolder{WorkspaceLocationFolder: is.cfg.WorkspaceRoot}
600-
} else {
601-
resp.WorkspaceLocation = &api.WorkspaceInfoResponse_WorkspaceLocationFile{WorkspaceLocationFile: is.cfg.WorkspaceRoot}
595+
_, contentReady := is.ContentState.ContentSource()
596+
if contentReady {
597+
stat, err := os.Stat(is.cfg.WorkspaceRoot)
598+
if err != nil {
599+
return nil, status.Error(codes.Internal, err.Error())
600+
}
601+
if stat.IsDir() {
602+
resp.WorkspaceLocation = &api.WorkspaceInfoResponse_WorkspaceLocationFolder{WorkspaceLocationFolder: is.cfg.WorkspaceRoot}
603+
} else {
604+
resp.WorkspaceLocation = &api.WorkspaceInfoResponse_WorkspaceLocationFile{WorkspaceLocationFile: is.cfg.WorkspaceRoot}
605+
}
602606
}
603607

604608
resp.UserHome, err = os.UserHomeDir()

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func Run(options ...RunOption) {
165165
termMuxSrv,
166166
RegistrableTokenService{tokenService},
167167
notificationService,
168-
&InfoService{cfg: cfg},
168+
&InfoService{cfg: cfg, ContentState: cstate},
169169
&ControlService{portsManager: portMgmt},
170170
}
171171
apiServices = append(apiServices, additionalServices...)

0 commit comments

Comments
 (0)