2 examples

Orphaned resource

Allocated resource not tracked or released, causing leaks.

[ FAQ1 ]

What is an orphaned resource?

An orphaned resource is an infrastructure component—such as a cloud server, database, storage bucket, or network resource—that exists independently without proper association or management by the provisioning or infrastructure-as-code tools originally responsible for creating it. Orphaned resources commonly occur due to incomplete cleanups, failed infrastructure updates, or errors in tools like Terraform. Left unaddressed, orphaned resources can lead to unnecessary costs, resource waste, and management difficulties in cloud environments or automated provisioning workflows.
[ FAQ2 ]

How to fix orphaned resources

To fix orphaned resources, first use automated scanning or detection tools to identify unmanaged or orphaned infrastructure within your environment. Clearly assess each identified resource to determine whether it should be re-associated, managed, or safely deleted. Update infrastructure-as-code tools like Terraform to properly track or manage existing resources, ensuring accurate state files and provisioning workflows. Regularly audit and monitor infrastructure environments, proactively detecting and cleaning up orphaned resources, minimizing cost, security risks, and complexity.
diff block
});
}
- async softDeleteWorkspace(id: string) {
+ async softDeleteWorkspace(
+ id: string,
+ withMetadataSchemaAndUserWorkspaceDeletion = true,
+ ) {
const workspace = await this.workspaceRepository.findOneBy({ id });
assert(workspace, 'Workspace not found');
+ if (!withMetadataSchemaAndUserWorkspaceDeletion) {
+ await this.userWorkspaceRepository.softDelete({ workspaceId: id });
+
+ return workspace;
+ }
Greptile
greptile
logic: This early return path skips billing subscription cleanup and workspace manager deletion, which could lead to orphaned resources
diff block
this.logger.log(chalk.yellow('Dry run mode: No changes will be applied'));
}
- try {
- for (const [index, workspaceId] of activeWorkspaceIds.entries()) {
- this.logger.log(
- `Running command on workspace ${workspaceId} ${index + 1}/${activeWorkspaceIds.length}`,
- );
+ const appVersion = this.environmentService.get('APP_VERSION');
- try {
- const dataSource =
- await this.twentyORMGlobalManager.getDataSourceForWorkspace(
- workspaceId,
- false,
- );
+ for (const [index, workspaceId] of activeWorkspaceIds.entries()) {
+ this.logger.log(
+ `Running command on workspace ${workspaceId} ${index + 1}/${activeWorkspaceIds.length}`,
+ );
- await this.runOnWorkspace({
- options,
+ try {
+ const dataSource =
+ await this.twentyORMGlobalManager.getDataSourceForWorkspace(
workspaceId,
- dataSource,
- index: index,
- total: activeWorkspaceIds.length,
- });
- } catch (error) {
- this.logger.warn(
- chalk.red(`Error in workspace ${workspaceId}: ${error.message}`),
+ false,
);
- }
+ await this.runOnWorkspace({
+ options,
+ workspaceId,
+ dataSource,
+ index: index,
+ total: activeWorkspaceIds.length,
+ appVersion,
+ });
+ this.migrationReport.success.push({
+ workspaceId,
+ });
+ } catch (error) {
+ this.migrationReport.fail.push({
+ error,
+ workspaceId,
+ });
+ this.logger.warn(
+ chalk.red(`Error in workspace ${workspaceId}: ${error.message}`),
+ );
+ }
+
+ try {
await this.twentyORMGlobalManager.destroyDataSourceForWorkspace(
workspaceId,
);
+ } catch (error) {
+ this.logger.error(error);
}
Greptile
greptile
style: Cleanup error is only logged but not included in migration report - could lead to orphaned resources