feat:fs s3 integration and tilesDeletionStartegy(MAPCO-9806)#24
Open
almog8k wants to merge 20 commits into
Open
feat:fs s3 integration and tilesDeletionStartegy(MAPCO-9806)#24almog8k wants to merge 20 commits into
almog8k wants to merge 20 commits into
Conversation
- Added "@aws-sdk/client-s3" dependency to package.json for S3 interactions. - Introduced STORAGE_PROVIDERS constant in constants.ts for future storage provider implementations.
Co-authored-by: Copilot <copilot@github.com>
…pe imports Co-authored-by: Copilot <copilot@github.com>
… strategy Co-authored-by: Copilot <copilot@github.com>
|
🎫 Related Jira Issue: MAPCO-9806 |
Co-authored-by: Copilot <copilot@github.com>
- upgraded @map-colonies/mc-priority-queue from ^9.0.2 to ^9.1.0 - upgraded @map-colonies/raster-shared from ^8.1.0-alpha.2 to ^8.1.0-alpha.3
CL-SHLOMIKONCHA
requested changes
May 7, 2026
| "delay": "exponential", | ||
| "shouldResetTimeout": true | ||
| }, | ||
| "s3": { |
There was a problem hiding this comment.
check if Storage Class is needed
Collaborator
Author
There was a problem hiding this comment.
We don't need to specify the Storage Class when deleting an object because S3 only needs the object's exact "address" to find and destroy it.
| private async cleanupEmptyDirs(relativePaths: string[], storageTarget: string): Promise<void> { | ||
| const dirsByLevel = new Map<number, Set<string>>(); | ||
|
|
||
| for (const relativePath of relativePaths) { |
There was a problem hiding this comment.
try to add more comment to explain what going on here
| public constructor( | ||
| @inject(SERVICES.LOGGER) private readonly logger: Logger, | ||
| @inject(SERVICES.CONFIG) config: ConfigType, | ||
| @inject(SERVICES.STORAGE_PROVIDERS) private readonly storageProviders: Map<string, IStorageProvider>, |
There was a problem hiding this comment.
check if changed string to SourceType
| if (provider === undefined) { | ||
| throw new UnrecoverableError(`Unknown storage provider: ${params.sourceProvider}`); | ||
| } | ||
| const storageTarget = params.sourceProvider === 'S3' ? this.s3Bucket : this.fsBasePath; |
| } | ||
|
|
||
| private countTiles(params: TilesDeletionParams): number { | ||
| return params.ranges.reduce((sum, r) => sum + (r.maxX - r.minX + 1) * (r.maxY - r.minY + 1), 0); |
There was a problem hiding this comment.
add comment to explain this code line
Collaborator
Author
There was a problem hiding this comment.
Added comment explaining the countTiles func
| } | ||
|
|
||
| private async flushBatches(provider: IStorageProvider, storageTarget: string, pendingBatches: string[][], failedPaths: string[]): Promise<number> { | ||
| const flushedCount = pendingBatches.reduce((sum, b) => sum + b.length, 0); |
|
|
||
| if (failedPaths.length > 0) { | ||
| const sample = failedPaths.slice(0, this.failureSampleSize); | ||
| this.logger.warn({ |
| pendingBatches.push(batch); | ||
| batch = []; | ||
| if (pendingBatches.length === this.concurrency) { | ||
| processedTiles += await this.flushBatches(provider, storageTarget, pendingBatches, failedPaths); |
There was a problem hiding this comment.
add info log indicate for x/total deleted
| useFactory: instancePerContainerCachingFactory((container) => { | ||
| const config = container.resolve<ConfigType>(SERVICES.CONFIG); | ||
| const logger = container.resolve<Logger>(SERVICES.LOGGER); | ||
| return new Map<string, IStorageProvider>([ |
| "@godaddy/terminus": "^4.12.1", | ||
| "@map-colonies/config": "^4.0.1", | ||
| "@map-colonies/jobnik-sdk": "^0.1.0", | ||
| "@map-colonies/js-logger": "^3.0.2", |
…orkerBoilerplateV2
…viders Co-authored-by: Copilot <copilot@github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a complete implementation of a provider-agnostic tiles deletion strategy, supporting both S3 and filesystem backends. It adds new storage provider interfaces and implementations, integrates them into the DI container, and exposes configuration for provider-specific settings. The tiles deletion strategy now efficiently deletes tiles in batches, handles partial failures, and reports progress.
Tiles Deletion Strategy Implementation:
TilesDeletionStrategyto support deleting tiles from both S3 and filesystem backends, including batching, concurrency, error handling, and progress reporting. The strategy uses provider abstraction and is fully configurable.Storage Provider Abstraction:
IStorageProviderinterface and concrete implementations:S3StorageProvider(using@aws-sdk/client-s3) andFsStorageProvider(using Node.js file system APIs). These providers handle batch deletions and error handling specific to their storage type. [1] [2] [3] [4]STORAGE_PROVIDERSsymbol. [1] [2] [3] [4]Configuration and Environment:
config/default.json,config/custom-environment-variables.json, and Helm charts. [1] [2] [3] [4]Dependency and Schema Updates:
@aws-sdk/client-s3and updated to use the tiles deletion schema and types from@map-colonies/raster-shared. [1] [2]