Skip to content

fix: paginate JCloudsStore listKeys and listFolders - #23978

Merged
tonsV2 merged 16 commits into
masterfrom
fix/listKeys-listFolders-pagination
May 27, 2026
Merged

fix: paginate JCloudsStore listKeys and listFolders#23978
tonsV2 merged 16 commits into
masterfrom
fix/listKeys-listFolders-pagination

Conversation

@tonsV2

@tonsV2 tonsV2 commented May 23, 2026

Copy link
Copy Markdown
Contributor

Problem

JCloudsStore.listKeys and listFolders call getBlobStore().list(...) only once and convert the result to a list. JClouds returns a single PageSet per call, which is capped by the provider's default page size (1000 keys on S3-compatible stores). For containers with more than 1000 keys/folders, only the first page is returned and the rest is silently dropped.

Impact

JCloudsAppStorageService.deleteApp enumerates an app's files via blobStore.listKeys(folder.asPrefix()) and deletes each. For bundled apps that ship more than 1000 files (e.g. metadata-management-app has ~1788), the cleanup deletes only the first 1000 (alphabetically) and leaves the remaining ~787 behind. The first step of deleteApp removes manifest.webapp, so the leftover dir is invisible to discoverInstalledApps afterwards and is never cleaned up.

This is the root cause behind the orphan-app-dir accumulation we observed on long-running dev instances — filestores growing into the GBs with dozens of leftover copies of the same app under different random folder names.

Fix

Iterate every page returned by JClouds, following nextMarker via ListContainerOptions.afterMarker until the store reports no more results. Same treatment for both listKeys and listFolders.

Verification

Added a listKeys_paginatesPastDefaultPageSize test to BlobStoreServiceContractTest, which writes 1100 blobs and asserts listKeys returns all of them. The test runs against all three backends:

  • S3BlobStoreServiceContractTest - passes
  • FilesystemBlobStoreServiceContractTest - passes
  • TransientBlobStoreServiceContractTest - passes

Full contract suite stays green: 72 tests, 0 failures.

Locally reproduced the bundled-app cleanup bug end-to-end against MinIO in a testcontainers fixture before applying the fix - the old code left 787 blobs behind in the previous app dir after a reinstall; after the fix the previous dir is fully cleaned up.

@tonsV2 tonsV2 added the deploy Deploy DHIS2 instance with IM. label May 23, 2026
janhenrikoverland and others added 2 commits May 24, 2026 06:49
…occhino/sticky-pull-request-comment

GitHub blocked actions-cool's repositories for a TOS violation on
2026-05-19, causing the Deploy/Destroy instance workflows to fail in
"Set up job" with "Repository access blocked" before any step runs.
Swap to marocchino/sticky-pull-request-comment@v2, which provides the
same one-comment-per-PR semantics and supports delete: true.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pin marocchino/sticky-pull-request-comment to a full 40-char commit SHA
instead of a floating tag. Two reasons:

1. Correctness: there is no `v2` ref on this repo (only specific tags
   like v2.9.4); the previous `@v2` would have failed to resolve.
2. Defense against tag-replacement supply-chain attacks like the one
   that just hit actions-cool (every tag re-pointed to imposter commits
   exfiltrating Runner.Worker memory). A SHA pin cannot be silently
   moved.

The trailing `# v3.0.4` comment lets Dependabot continue to manage
version updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tonsV2
tonsV2 requested a review from a team as a code owner May 23, 2026 23:49
@tonsV2
tonsV2 removed the request for review from a team May 25, 2026 01:21
@tonsV2
tonsV2 requested review from david-mackessy and netroms May 26, 2026 09:00
@tonsV2
tonsV2 requested a review from david-mackessy May 27, 2026 10:51
@sonarqubecloud

Copy link
Copy Markdown

@tonsV2
tonsV2 enabled auto-merge (squash) May 27, 2026 10:58

@david-mackessy david-mackessy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR section Fix needs updating to reflect the newer commits (JClouds listAll vs our own)

@tonsV2
tonsV2 merged commit 9950136 into master May 27, 2026
18 checks passed
@tonsV2
tonsV2 deleted the fix/listKeys-listFolders-pagination branch May 27, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy Deploy DHIS2 instance with IM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants