Skip to content

Commit 1c56a7b

Browse files
committed
wip
1 parent 1688cec commit 1c56a7b

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

components/ws-daemon/pkg/content/service.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,20 @@ func (s *WorkspaceService) InitWorkspace(ctx context.Context, req *api.InitWorks
241241
}
242242
}
243243

244-
// create a folder that is used to store data from running prestophook
245-
deamonDir := fmt.Sprintf("%s-daemon", req.Id)
246-
prestophookDir := filepath.Join(s.config.WorkingArea, deamonDir, "prestophookdata")
247-
_, err = exec.CommandContext(ctx, "mkdir", "-p", prestophookDir).CombinedOutput()
248-
if err != nil {
249-
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot create prestophookdata folder")
250-
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot create prestophookdata: %v", err))
251-
}
252-
_, err = exec.CommandContext(ctx, "chown", "-R", fmt.Sprintf("%d:%d", wsinit.GitpodUID, wsinit.GitpodGID), prestophookDir).CombinedOutput()
253-
if err != nil {
254-
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot chown prestophookdata folder")
255-
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot chown prestophookdata: %v", err))
244+
if req.PersistentVolumeClaim {
245+
// create a folder that is used to store data from running prestophook
246+
deamonDir := fmt.Sprintf("%s-daemon", req.Id)
247+
prestophookDir := filepath.Join(s.config.WorkingArea, deamonDir, "prestophookdata")
248+
_, err = exec.CommandContext(ctx, "mkdir", "-p", prestophookDir).CombinedOutput()
249+
if err != nil {
250+
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot create prestophookdata folder")
251+
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot create prestophookdata: %v", err))
252+
}
253+
_, err = exec.CommandContext(ctx, "chown", "-R", fmt.Sprintf("%d:%d", wsinit.GitpodUID, wsinit.GitpodGID), prestophookDir).CombinedOutput()
254+
if err != nil {
255+
log.WithError(err).WithField("workspaceId", req.Id).Error("cannot chown prestophookdata folder")
256+
return nil, status.Error(codes.FailedPrecondition, fmt.Sprintf("cannot chown prestophookdata: %v", err))
257+
}
256258
}
257259

258260
// Tell the world we're done

components/ws-manager/pkg/manager/monitor.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,8 @@ func actOnPodEvent(ctx context.Context, m actingManager, status *api.WorkspaceSt
383383

384384
_, gone := wso.Pod.Annotations[wsk8s.ContainerIsGoneAnnotation]
385385
_, alreadyFinalized := wso.Pod.Annotations[disposalStatusAnnotation]
386-
log.Infof("alreadyFinalize: %v, annotations: %v", alreadyFinalized, wso.Pod.Annotations)
387386

388387
if (terminated || gone) && !alreadyFinalized {
389-
log.Infof("about to call finalizeWorkspaceContent: %v and %v", terminated, gone)
390388
// We start finalizing the workspace content only after the container is gone. This way we ensure there's
391389
// no process modifying the workspace content as we create the backup.
392390
go m.finalizeWorkspaceContent(ctx, wso)
@@ -825,8 +823,6 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
825823
defer tracing.FinishSpan(span, nil)
826824
log := log.WithFields(wso.GetOWI())
827825

828-
log.Infof("finalizeWorkspaceContent called")
829-
830826
workspaceID, ok := wso.WorkspaceID()
831827
if !ok {
832828
tracing.LogError(span, xerrors.Errorf("cannot find %s annotation", workspaceIDAnnotation))
@@ -927,23 +923,6 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
927923
VolumeSnapshotClassName: &snapshotClassname,
928924
},
929925
}
930-
//volumesnapshotRes := schema.GroupVersionResource{Group: "snapshot.storage.k8s.io", Version: "v1", Resource: "volumesnapshots"}
931-
/*snapshot := &unstructured.Unstructured{
932-
Object: map[string]interface{}{
933-
"apiVersion": "snapshot.storage.k8s.io/v1",
934-
"kind": "VolumeSnapshot",
935-
"metadata": map[string]interface{}{
936-
"name": snapshotName,
937-
"namespace": m.manager.Config.Namespace,
938-
},
939-
"spec": map[string]interface{}{
940-
"volumeSnapshotClassName": "csi-gce-pd-snapshot-class",
941-
"source": map[string]interface{}{
942-
"persistentVolumeClaimName": pvcName,
943-
},
944-
},
945-
},
946-
}*/
947926

948927
err = m.manager.Clientset.Create(ctx, volumeSnapshot)
949928
if err != nil {

0 commit comments

Comments
 (0)