feat: resolve tiles-deletion storage locators from task params (MAPCO-11295) - #37
feat: resolve tiles-deletion storage locators from task params (MAPCO-11295)#37almog8k wants to merge 7 commits into
Conversation
Temporary pointer to a locally packed tarball while the reshaped deletion schemas are unreleased. Must be swapped for a published 8.3.0-alpha before merge: the tarball reports the same version as the published alpha, so a plain install on CI would resolve the older package instead.
…ms (MAPCO-11295)
Tiles deletion read its storage locator from
strategies.tilesDeletion.{s3Bucket,fsSubPath}, which pinned every task in a
deployment to one bucket and one sub path. The reshaped raster-shared deletion
schemas carry the locator in the task params, so each task now brings its own.
- storageProvider replaces sourceProvider and tilesRelativePath replaces
tilesPath, following the shared schemas
- an FS storage target is now a sub path of the configured base path.
FsStorageProvider joins its own base path and rejects a sub path that falls
outside the configured deletion sub paths, so the strategy holds no
filesystem knowledge at all and reads only its batching knobs from config
- REDIS joined both shared unions but has no provider here yet, so tiles
deletion rejects it as unrecoverable (MAPCO-11261)
Producers of tiles-deletion and artifacts-deletion tasks must now send the
bucket or subPath in the task parameters.
isPathWithinAllowedSubPaths holds the rule that a path must sit strictly under one of the configured sub paths and still resolve inside the base path, which makes it unit testable on its own rather than only through the provider. FsStorageProvider's private check becomes an assertion instead of a boolean, so a caller cannot forget to act on the result, and the thrown message now names the offending paths, the base path and the allowed sub paths.
delete(storageTarget, paths) now reads the same way as targetExists(storageTarget, relativePath).
strategies.tilesDeletion.s3Bucket and .fsSubPath are no longer read now that the locator travels with the task, so they go along with their configmap entries (TILES_DELETION_S3_BUCKET, TILES_DELETION_FS_SUB_PATH) and the s3.tilesBucket value that fed the former. storage.fs.subPaths stays: it is the allowlist FS deletion targets are checked against. cleanupStorageProviders now defaults to empty so a deployment states its providers explicitly.
|
🎫 Related Jira Issue: MAPCO-11295 |
| * @param paths | ||
| * @returns boolean whether `paths` are valid and pass all checks | ||
| * Gate for every path this provider is asked to touch. | ||
| * @param relativePaths - Paths relative to the configured base path, sub path included |
There was a problem hiding this comment.
in function def it is still called paths, use it or relativePaths
| expect(strategy.validate(redisParams)).toEqual(redisParams); | ||
| }); | ||
|
|
||
| it('should throw ValidationError when paths is an empty array', () => { |
There was a problem hiding this comment.
there was a test checking if paths failed on empty string
please add it as well
| const s3Params: DeleteStoredResourcesParams = { storageProvider: SourceType.S3, paths: ['layer1'], bucket: S3_BUCKET }; | ||
| const fsParams: DeleteStoredResourcesParams = { storageProvider: SourceType.FS, paths: ['layer2'], subPath: FS_SUB_PATH }; | ||
| const s3Params: S3DeleteStoredResourcesParams = { storageProvider: SourceType.S3, paths: ['layer1'], bucket: S3_BUCKET }; | ||
| const fsParams: FsDeleteStoredResourcesParams = { storageProvider: SourceType.FS, paths: ['layer2'], subPath: FS_SUB_PATH }; |
| it('should throw ValidationError when tilesPath is empty string', () => { | ||
| expect(() => strategy.validate({ storageProvider: SourceType.S3, catalogId: '' })).toThrow(ValidationError); | ||
| it('should validate and return REDIS params, whose prefix is the locator', () => { | ||
| const redisParams = { storageProvider: 'REDIS', prefix: 'layer-redis_WorldCRS84' }; |
There was a problem hiding this comment.
reuse redisParams here
and move test closer to happy path of FS/S3 above
| it('should throw ValidationError when the FS subPath is missing', () => { | ||
| expect(() => strategy.validate({ storageProvider: SourceType.FS, paths: ['layer1'] })).toThrow(ValidationError); | ||
| }); | ||
|
|
There was a problem hiding this comment.
add test if redis prefix is missing and ValidationError is thrown
|
|
||
| const { s3Bucket: S3_BUCKET, fsBasePath: FS_BASE_PATH, fsSubPath: FS_SUB_PATH } = TILES_DELETION_CONFIG_DEFAULTS; | ||
| const S3_BUCKET = 'test-bucket'; | ||
| const FS_SUB_PATH = 'artifacts/tiles'; |
There was a problem hiding this comment.
'artifacts/tiles' can be extracted from FS_STORAGE_CONFIG_DEFAULTS
| it('should call S3 provider with s3Bucket as storage target', async () => { | ||
| await strategy.execute(s3Params); | ||
| it("should call S3 provider with the task's own bucket as storage target", async () => { | ||
| const params: S3TilesDeletionParams = { ...s3Params, bucket: 'per-task-bucket' }; |
There was a problem hiding this comment.
why can't we keep using s3Params without modification
| expect(MockS3Provider.delete).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should pass the subPath through untouched rather than resolving it', async () => { |
There was a problem hiding this comment.
this case is not so different from the happy path
Related issues: MAPCO-11295 (epic MAPCO-11261)
Further information:
Adapts the cleaner to the reshaped
raster-shareddeletion schemas and moves the tiles-deletion storage locator out of deployment config into the task parameters.What changed
TilesDeletionStrategytakes the S3 bucket and the FS sub path from the task params instead ofstrategies.tilesDeletion.{s3Bucket,fsSubPath}, so a single deployment is no longer pinned to one bucket and one sub path.storageProviderreplacessourceProviderandtilesRelativePathreplacestilesPath, following the shared schemas.FsStorageProviderjoins its own base path and rejects a sub path that falls outside the configured deletion sub paths, so the strategy holds no filesystem knowledge and reads onlybatchSize/concurrencyfrom config.isPathWithinAllowedSubPathsincleaner/utils/path.ts, used by bothtargetExistsanddeleteResources, and is now an assertion rather than a boolean whose result could be ignored. The thrown message names the offending paths, the base path and the allowed sub paths.IStorageProvider.deletetakes the storage target first, matchingtargetExists.strategies.tilesDeletion.s3Bucketand.fsSubPath, their configmap entries (TILES_DELETION_S3_BUCKET,TILES_DELETION_FS_SUB_PATH) and thes3.tilesBucketvalue that fed the former.storage.fs.subPathsstays — it is the allowlist FS deletion targets are checked against.cleanupStorageProvidersnow defaults to empty so a deployment states its providers explicitly.The five commits are meant to be reviewed in order: dependency pointer, the feature, the validator extraction, the parameter reorder, then the config cleanup.
Breaking change
Producers of
tiles-deletionandartifacts-deletiontasks must now sendbucket(S3) orsubPath(FS) in the task parameters, and the twostrategies.tilesDeletionconfig keys above no longer exist. Thefeatcommit is not marked!, so release-please will cut a minor — say the word if this should be a major instead.