@@ -44,6 +44,9 @@ export class WorkspaceGarbageCollector {
44
44
this . deleteWorkspaceContentAfterRetentionPeriod ( ) . catch ( ( err ) =>
45
45
log . error ( "wsgc: error during content deletion" , err ) ,
46
46
) ;
47
+ this . purgeWorkspacesAfterPurgeRetentionPeriod ( ) . catch ( ( err ) =>
48
+ log . error ( "wsgc: error during hard deletion of workspaces" , err ) ,
49
+ ) ;
47
50
this . deleteOldPrebuilds ( ) . catch ( ( err ) => log . error ( "wsgc: error during prebuild deletion" , err ) ) ;
48
51
this . deleteOutdatedVolumeSnapshots ( ) . catch ( ( err ) =>
49
52
log . error ( "wsgc: error during volume snapshot gc deletion" , err ) ,
@@ -105,6 +108,34 @@ export class WorkspaceGarbageCollector {
105
108
}
106
109
}
107
110
111
+ /**
112
+ * This method is meant to purge all traces of a Workspace and it's WorkspaceInstances from the DB
113
+ */
114
+ protected async purgeWorkspacesAfterPurgeRetentionPeriod ( ) {
115
+ const span = opentracing . globalTracer ( ) . startSpan ( "purgeWorkspacesAfterPurgeRetentionPeriod" ) ;
116
+ try {
117
+ const now = new Date ( ) ;
118
+ const workspaces = await this . workspaceDB
119
+ . trace ( { span } )
120
+ . findWorkspacesForPurging (
121
+ this . config . workspaceGarbageCollection . purgeRetentionPeriodDays ,
122
+ this . config . workspaceGarbageCollection . purgeChunkLimit ,
123
+ now ,
124
+ ) ;
125
+ const deletes = await Promise . all (
126
+ workspaces . map ( ( ws ) => this . deletionService . hardDeleteWorkspace ( { span } , ws . id ) ) ,
127
+ ) ;
128
+
129
+ log . info ( `wsgc: successfully purged ${ deletes . length } workspaces` ) ;
130
+ span . addTags ( { nrOfCollectedWorkspaces : deletes . length } ) ;
131
+ } catch ( err ) {
132
+ TraceContext . setError ( { span } , err ) ;
133
+ throw err ;
134
+ } finally {
135
+ span . finish ( ) ;
136
+ }
137
+ }
138
+
108
139
protected async deleteOldPrebuilds ( ) {
109
140
const span = opentracing . globalTracer ( ) . startSpan ( "deleteOldPrebuilds" ) ;
110
141
try {
@@ -128,7 +159,7 @@ export class WorkspaceGarbageCollector {
128
159
}
129
160
}
130
161
131
- // finds volume snapshots that have been superceded by newer volume snapshot and removes them
162
+ // finds volume snapshots that have been superseded by newer volume snapshot and removes them
132
163
protected async deleteOutdatedVolumeSnapshots ( ) {
133
164
const span = opentracing . globalTracer ( ) . startSpan ( "deleteOutdatedVolumeSnapshots" ) ;
134
165
try {
0 commit comments