Skip to content

Commit 5702992

Browse files
committed
Remove the duplicate check logic
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent a8afac7 commit 5702992

File tree

1 file changed

+12
-50
lines changed

1 file changed

+12
-50
lines changed

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

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,22 +1070,20 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
10701070
return &csapi.GitStatus{}, nil
10711071
}
10721072

1073-
if pvcFeatureEnabled {
1074-
// only set status to started if we actually confirmed that workspace is ready and we are about to do actual disposal
1075-
// otherwise we risk overwriting previous disposal status
1076-
if !markedDisposalStatusStarted {
1077-
statusStarted := &workspaceDisposalStatus{
1078-
Status: DisposalStarted,
1079-
}
1080-
err = m.manager.markDisposalStatus(ctx, workspaceID, statusStarted)
1081-
if err != nil {
1082-
tracing.LogError(span, err)
1083-
log.WithError(err).Error("was unable to update pod's start disposal status - this might cause an incorrect disposal status")
1084-
} else {
1085-
markedDisposalStatusStarted = true
1086-
}
1073+
if !markedDisposalStatusStarted {
1074+
statusStarted := &workspaceDisposalStatus{
1075+
Status: DisposalStarted,
10871076
}
1077+
err = m.manager.markDisposalStatus(ctx, workspaceID, statusStarted)
1078+
if err != nil {
1079+
tracing.LogError(span, err)
1080+
log.WithError(err).Error("was unable to update pod's start disposal status - this might cause an incorrect disposal status")
1081+
} else {
1082+
markedDisposalStatusStarted = true
1083+
}
1084+
}
10881085

1086+
if pvcFeatureEnabled {
10891087
// pvc was created with the name of the pod. see createDefiniteWorkspacePod()
10901088
pvcName := wso.Pod.Name
10911089
if !createdVolumeSnapshot {
@@ -1241,48 +1239,12 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
12411239
deletedPVC = true
12421240
}
12431241
} else if doSnapshot {
1244-
// we're not yet finalizing - start the process
12451242
snc, err = m.manager.connectToWorkspaceDaemon(ctx, *wso)
12461243
if err != nil {
12471244
tracing.LogError(span, err)
12481245
return nil, status.Errorf(codes.Unavailable, "cannot connect to workspace daemon: %q", err)
12491246
}
12501247

1251-
var workspaceExistsResult *wsdaemon.IsWorkspaceExistsResponse
1252-
workspaceExistsResult, err = snc.IsWorkspaceExists(ctx, &wsdaemon.IsWorkspaceExistsRequest{Id: workspaceID})
1253-
if err != nil {
1254-
tracing.LogError(span, err)
1255-
return nil, err
1256-
}
1257-
if !workspaceExistsResult.Exists {
1258-
// nothing to backup, workspace does not exist
1259-
return nil, status.Error(codes.NotFound, "workspace does not exist")
1260-
}
1261-
1262-
// make sure that workspace was ready, otherwise there is no need to backup anything
1263-
// as we might backup corrupted workspace state
1264-
// this also ensures that if INITIALIZING still going, that we will wait for it to finish before disposing the workspace
1265-
_, err = snc.WaitForInit(ctx, &wsdaemon.WaitForInitRequest{Id: workspaceID})
1266-
if err != nil {
1267-
tracing.LogError(span, err)
1268-
return nil, err
1269-
}
1270-
1271-
// only set status to started if we actually confirmed that workspace is ready and we are about to do actual disposal
1272-
// otherwise we risk overwriting previous disposal status
1273-
if !markedDisposalStatusStarted {
1274-
statusStarted := &workspaceDisposalStatus{
1275-
Status: DisposalStarted,
1276-
}
1277-
err = m.manager.markDisposalStatus(ctx, workspaceID, statusStarted)
1278-
if err != nil {
1279-
tracing.LogError(span, err)
1280-
log.WithError(err).Error("was unable to update pod's start disposal status - this might cause an incorrect disposal status")
1281-
} else {
1282-
markedDisposalStatusStarted = true
1283-
}
1284-
}
1285-
12861248
// if this is a prebuild take a snapshot and mark the workspace
12871249
var res *wsdaemon.TakeSnapshotResponse
12881250
res, err = snc.TakeSnapshot(ctx, &wsdaemon.TakeSnapshotRequest{Id: workspaceID})

0 commit comments

Comments
 (0)