Skip to content

feat(app-configs): warn when persistent volume label is used by other apps - #226

Merged
githubsaturn merged 4 commits into
caprover:masterfrom
bestony:feat/volume-label-duplicate-warning
Jul 31, 2026
Merged

feat(app-configs): warn when persistent volume label is used by other apps#226
githubsaturn merged 4 commits into
caprover:masterfrom
bestony:feat/volume-label-duplicate-warning

Conversation

@bestony

@bestony bestony commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When editing Persistent Directories on App Configs, warn if the volume Label resolves to a Docker volume name already used by other CapRover apps.
  • Frontend-only: derive conflicts from the existing getAllApps() / app-definitions response (already loaded on App Details). No new backend endpoint, no getAllVolumes, no captain inventory route.
  • Warn-only (never blocks Save). Alert includes an intentional-share description.

Screenshot

image image

Supersedes PR #223 inventory approach

This PR supersedes the data/backend path in #223.

That produces the same warning inputs without another request, backend route, API contract, aggregation implementation, or backward-compatibility fallback.

What we reuse from #223: Alert presentation (type="warning" showIcon), padding, and i18n key naming for the primary message.
What we do not ship: GET /user/system/volumes/, ApiManager.getAllVolumes, inventory DTOs, or AppConfigs self-fetch.

Implementation

  1. src/utils/volumeHelpers.tsbuildVolumeUsageIndex, getOtherAppsUsingVolumeLabel, resolvePhysicalVolumeName, formatLocalized (+ unit tests, including mixed-era same logical Label → no false positive).
  2. AppDetails.reFetchData builds volumeUsageIndex from the full appDefinitions list before selecting the current app; passes index only into AppConfigs.
  3. AppConfigs shows warning under volume rows when other apps share the physical name.
  4. i18n: apps.app_config_vol_in_use_warning + apps.app_config_vol_in_use_warning_desc in all 16 locales (including ja-JP).

Test plan

  • App without persistent data: no volume section / no warning path.
  • Unique Label → no alert.
  • Two modern apps share Label → alert lists the other app name(s).
  • Mixed-era same logical Label (data on legacy + modern) → no alert (captain--datadata).
  • Switch row to host path (including residual Label in draft) → no alert.
  • Save still succeeds while warning is visible.
  • Locale switch (en-US / zh-CN / ja-JP) shows translated message + description.
  • yarn test --watchAll=false --testPathPattern=volumeHelpers
  • yarn formatter / yarn tslint

Summary by CodeRabbit

  • New Features

    • Added volume configuration guidance distinguishing bind mounts from managed volumes.
    • Added warnings when managed volumes are used by other applications, with support for intentional sharing.
    • Added localized warnings and guidance across supported languages.
  • Bug Fixes

    • Improved volume name resolution and usage tracking across current and legacy application configurations.
  • Tests

    • Added coverage for volume detection, filtering, deduplication, legacy handling, and localized messages.

bestony added 3 commits July 31, 2026 08:33
…finitions

Build a volume usage index from getAllApps() app definitions and resolve
legacy labels as captain--{name}. Pure helpers with unit tests including
mixed-era non-collision.
Build volumeUsageIndex in AppDetails.reFetchData from the full getAllApps()
list and pass it only into AppConfigs. Show a warn-only Ant Design Alert
when the Label resolves to a physical volume used by other apps.
Add apps.app_config_vol_in_use_warning and
apps.app_config_vol_in_use_warning_desc to all 16 locale files,
including ja-JP.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added volume usage indexing for modern and legacy app definitions, passed the index through AppDetails, and displayed localized warnings in AppConfigs when managed volumes are shared by other applications. Added helper tests and translations across supported locales.

Changes

Volume usage warnings

Layer / File(s) Summary
Volume usage indexing and validation
src/utils/volumeHelpers.ts, src/utils/volumeHelpers.test.ts
Volume helpers resolve physical names, index managed-volume usage, identify other applications, format localized messages, and test these behaviors.
AppDetails usage-index wiring
src/containers/apps/appDetails/AppDetails.tsx
AppDetails builds a volume usage index from all application definitions and passes it to AppConfigs.
Volume-row warnings and localization
src/containers/apps/appDetails/AppConfigs.tsx, src/locales/*.json
Volume rows distinguish bind mounts from managed volumes and display translated warnings for shared managed volume labels.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AppDetails
  participant volumeHelpers
  participant AppConfigs
  AppDetails->>volumeHelpers: buildVolumeUsageIndex(appDefinitions)
  volumeHelpers-->>AppDetails: VolumeUsageIndex
  AppDetails->>AppConfigs: pass volumeUsageIndex
  AppConfigs->>volumeHelpers: getOtherAppsUsingVolumeLabel(volumeLabel, index)
  volumeHelpers-->>AppConfigs: other application names
  AppConfigs-->>AppDetails: render localized volume warning
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: warning when persistent volume labels are used by other applications.
Description check ✅ Passed The description is detailed, on-topic, and covers the implementation, scope, screenshots, localization, and testing plan.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/locales/tr-TR.json`:
- Around line 56-57: Update the warning message/description pairs for
consistency: in src/locales/tr-TR.json lines 56-57, use the same term for
“volume” in both strings, replacing “volume'u” with the established Turkish
term; in src/locales/nl-NL.json lines 56-57, change the description to the
informal “je” form used by neighboring volume strings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a3dec3f-7183-45c3-8fc9-e4a75a60bb8b

📥 Commits

Reviewing files that changed from the base of the PR and between 92f529e and 3aa7f36.

📒 Files selected for processing (20)
  • src/containers/apps/appDetails/AppConfigs.tsx
  • src/containers/apps/appDetails/AppDetails.tsx
  • src/locales/ar-EG.json
  • src/locales/de-DE.json
  • src/locales/en-US.json
  • src/locales/es-ES.json
  • src/locales/fa-IR.json
  • src/locales/fr-FR.json
  • src/locales/hr-HR.json
  • src/locales/id-ID.json
  • src/locales/ja-JP.json
  • src/locales/ko-KR.json
  • src/locales/nl-NL.json
  • src/locales/pt-BR.json
  • src/locales/ru-RU.json
  • src/locales/sv-SE.json
  • src/locales/tr-TR.json
  • src/locales/zh-CN.json
  • src/utils/volumeHelpers.test.ts
  • src/utils/volumeHelpers.ts

Comment thread src/locales/tr-TR.json Outdated
Use consistent "birim" in Turkish description, and informal "je" in
Dutch description to match neighboring volume strings.
@githubsaturn
githubsaturn merged commit f49c284 into caprover:master Jul 31, 2026
4 checks passed
@githubsaturn

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants