Skip to content

Commit 483db2e

Browse files
committed
wip
1 parent 81862b5 commit 483db2e

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

components/content-service/pkg/layer/provider.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,13 @@ func (s *Provider) GetContentLayerPVC(ctx context.Context, owner, workspaceID st
288288
if err != nil {
289289
return nil, nil, err
290290
}
291+
// we also need to place ready file
292+
layerReady, err := workspaceReadyLayerPVC(csapi.WorkspaceInitFromOther)
293+
if err != nil {
294+
return nil, nil, err
295+
}
291296

292-
l = []Layer{*layer}
297+
l = []Layer{*layer, *layerReady}
293298
return l, manifest, nil
294299
}
295300
return s.getSnapshotContentLayer(ctx, gis)
@@ -301,8 +306,14 @@ func (s *Provider) GetContentLayerPVC(ctx context.Context, owner, workspaceID st
301306
if err != nil {
302307
return nil, nil, err
303308
}
309+
// we also need to place ready file
310+
layerReady, err := workspaceReadyLayerPVC(csapi.WorkspaceInitFromPrebuild)
311+
if err != nil {
312+
return nil, nil, err
313+
}
314+
315+
l = []Layer{*layer, *layerReady}
304316

305-
l = []Layer{*layer}
306317
return l, manifest, nil
307318
}
308319
l, manifest, err = s.getPrebuildContentLayer(ctx, pis, true)
@@ -513,6 +524,8 @@ git log --pretty=%H -n 1 > /.workspace/prestophookdata/git_log_2.txt
513524
cp /workspace/.gitpod/prebuild-log* /.workspace/prestophookdata/
514525
`
515526

527+
var pvcEnabledFile = `PVC`
528+
516529
// version of this function for persistent volume claim feature
517530
// we cannot use /workspace folder as when mounting /workspace folder through PVC
518531
// it will mask anything that was in container layer, hence we are using /.workspace instead here
@@ -521,6 +534,7 @@ func contentDescriptorToLayerPVC(cdesc []byte) (*Layer, error) {
521534
layers := []fileInLayer{
522535
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil},
523536
{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil},
537+
{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/pvc", Uid: 0, Gid: 0, Mode: 0775, Size: int64(len(pvcEnabledFile))}, []byte(pvcEnabledFile)},
524538
{&tar.Header{Typeflag: tar.TypeReg, Name: "/.supervisor/prestophook.sh", Uid: 0, Gid: 0, Mode: 0775, Size: int64(len(prestophookScript))}, []byte(prestophookScript)},
525539
}
526540
if len(cdesc) > 0 {
@@ -530,6 +544,23 @@ func contentDescriptorToLayerPVC(cdesc []byte) (*Layer, error) {
530544
return layerFromContent(layers...)
531545
}
532546

547+
func workspaceReadyLayerPVC(src csapi.WorkspaceInitSource) (*Layer, error) {
548+
log.Infof("workspaceReadyLayerPVC: %v", src)
549+
msg := csapi.WorkspaceReadyMessage{
550+
Source: src,
551+
}
552+
ctnt, err := json.Marshal(msg)
553+
if err != nil {
554+
return nil, err
555+
}
556+
557+
return layerFromContent(
558+
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil},
559+
fileInLayer{&tar.Header{Typeflag: tar.TypeDir, Name: "/.workspace/.gitpod", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755}, nil},
560+
fileInLayer{&tar.Header{Typeflag: tar.TypeReg, Name: "/.workspace/.gitpod/ready", Uid: initializer.GitpodUID, Gid: initializer.GitpodGID, Mode: 0755, Size: int64(len(ctnt))}, []byte(ctnt)},
561+
)
562+
}
563+
533564
func workspaceReadyLayer(src csapi.WorkspaceInitSource) (*Layer, error) {
534565
log.Infof("workspaceReadyLayer: %v", src)
535566
msg := csapi.WorkspaceReadyMessage{

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,10 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst
13271327

13281328
fn := "/workspace/.gitpod/content.json"
13291329
fnReady := "/workspace/.gitpod/ready"
1330-
if _, err := os.Stat("/.workspace/.gitpod/content.json"); !os.IsNotExist(err) {
1330+
if _, err := os.Stat("/.workspace/.gitpod/pvc"); !os.IsNotExist(err) {
13311331
fn = "/.workspace/.gitpod/content.json"
1332-
log.Info("Detected content.json in /.workspace folder, assuming PVC feature enabled")
1332+
fnReady = "/.workspace/.gitpod/ready"
1333+
log.Info("Detected pvc file in /.workspace folder, assuming PVC feature enabled")
13331334
}
13341335

13351336
var contentFile *os.File

0 commit comments

Comments
 (0)