Skip to content

fix: create the folders and links an empty /opt/containerbase misses - #8393

Open
viceice wants to merge 1 commit into
mainfrom
viceice/fix/volume-folders
Open

viceice wants to merge 1 commit into
mainfrom
viceice/fix/volume-folders

Conversation

@viceice

@viceice viceice commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Changes

  • lib and env.d are created with the other base folders. A symlink to a folder there is kept; anything else only warns.
  • mono creates ssl/mono and docker creates lib/docker/cli-plugins in their initialize step, not only in prepare.
  • The buildx and compose docker plugin links point at their command shims instead of a version binary; docker's initialize step creates them again.
  • java keeps the JRE cacerts link to /opt/containerbase/ssl/cacerts; its initialize step recreates ssl/cacerts -> /var/lib/containerbase/cacerts when it's missing.
  • No change without a volume. Layer 1 of Make /opt/containerbase usable as a volume mount #7956.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Code and tests written by Claude Opus 5.5 (Claude Code).

Use of AI in replying to PR comments

Who answers review comments:

  • @viceice will read and reply directly. Name the account.
  • An agent will draft replies and @viceice will read them before they are posted. Name the account.
  • An agent will draft replies and reply autonomously. This is heavily discouraged, and we prefer that there are humans in the loop
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified tests

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@viceice
viceice added this pull request to stack #8398 November 20, 2026 10:00
@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Restore missing folders and links with an empty /opt/containerbase volume

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Create lib and env.d when an empty volume hides the image’s base folders.
• Restore Docker plugin links, Mono’s certificate folder, and Java’s shared certificate link during
 initialization.
• Add tests for missing paths, repeated initialization, and Docker’s read-only-folder warning.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 3 capabilities

  • 3 affected capabilities span independent functional scopes: Docker CLI plugin integration, Java trust-store integration, containerbase filesystem setup.
  • The changed behavior is the shared base-path setup invoked by install and prepare lifecycle services.
  • The affected outcome is availability of the base directories themselves; no evidence showed a distinct independent consumer capability that should be split from this bounded filesystem setup behavior.
  • Buildx and Compose are distinct plugin commands but share the bounded Docker CLI plugin integration: both are delivered through the same cache/global plugin discovery path and the same shim-linking helper.
  • Their separate command names do not establish independent functional scopes.
  • The changed paths all determine one Java end-to-end behavior: which certificate store Java runtimes use.
  • The readiness check, initialization link, and preparation fallback are implementation hops within that bounded integration, not independent capabilities.
Sources

src/cli/tools/docker/index.ts[43-60]

    const plugins = join(this.pathSvc.cachePath, '.docker', 'cli-plugins');
    await this.pathSvc.createDir(plugins);

    for (const { plugin, command } of cliPlugins) {
      if (await pathExists(join(this.pathSvc.binDir, command), 'file')) {
        await linkCliPlugin(this.pathSvc, plugin, command);
      }
    }

    const globalDocker = join(this.envSvc.rootDir, 'usr/local/lib/docker');
    try {
      await fs.mkdir(globalDocker, { recursive: true });
      await this.pathSvc.createSymlink(
        plugins,
        join(globalDocker, 'cli-plugins'),
      );
    } catch (err) {
      logger.warn({ err }, 'cannot link the docker cli plugins folder');

src/cli/tools/docker/utils.ts[21-34]

export async function linkCliPlugin(
  pathSvc: PathService,
  plugin: string,
  command: string,
): Promise<void> {
  const dir = join(pathSvc.cachePath, '.docker/cli-plugins');
  const tgt = join(dir, plugin);
  const shim = join(pathSvc.binDir, command);
  if ((await fs.readlink(tgt).catch(() => null)) === shim) {
    return;
  }
  await pathSvc.createDir(dir);
  await fs.rm(tgt, { force: true });
  await fs.symlink(shim, tgt);

src/cli/tools/java/index.ts[111-117]

    const varCerts = path.join(this.pathSvc.varPath, 'cacerts');
    if (await this.pathSvc.fileExists(varCerts)) {
      await this.pathSvc.createSymlink(
        varCerts,
        path.join(this.pathSvc.sslPath, 'cacerts'),
      );
    }

src/cli/tools/java/index.ts[41-49]

    const cacerts = path.join(this.pathSvc.sslPath, 'cacerts');
    // before the initialize, which links an existing cacerts of the image
    const hasCacerts = await this.pathSvc.fileExists(cacerts);

    await this.initialize();

    if (hasCacerts) {
      // cert store already there
      return;
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before, each installer linked the plugin directly to a version binary.
  • After, the plugin must point to a shim, the shim must exist in the global bin directory, the cache plugin directory must be exposed through the global Docker directory, and existing direct links/files must be replaced while correct shim links are retained.
  • The new correctness condition is that these old/new filesystem states and initialization ordering all converge on the selected tool version for both Docker plugin names.
  • The helper's basic symlink operation is simple; the added compatibility and state interaction is the material complexity.
Sources

src/cli/tools/docker/index.ts[43-60]

    const plugins = join(this.pathSvc.cachePath, '.docker', 'cli-plugins');
    await this.pathSvc.createDir(plugins);

    for (const { plugin, command } of cliPlugins) {
      if (await pathExists(join(this.pathSvc.binDir, command), 'file')) {
        await linkCliPlugin(this.pathSvc, plugin, command);
      }
    }

    const globalDocker = join(this.envSvc.rootDir, 'usr/local/lib/docker');
    try {
      await fs.mkdir(globalDocker, { recursive: true });
      await this.pathSvc.createSymlink(
        plugins,
        join(globalDocker, 'cli-plugins'),
      );
    } catch (err) {
      logger.warn({ err }, 'cannot link the docker cli plugins folder');

src/cli/tools/docker/utils.ts[21-34]

export async function linkCliPlugin(
  pathSvc: PathService,
  plugin: string,
  command: string,
): Promise<void> {
  const dir = join(pathSvc.cachePath, '.docker/cli-plugins');
  const tgt = join(dir, plugin);
  const shim = join(pathSvc.binDir, command);
  if ((await fs.readlink(tgt).catch(() => null)) === shim) {
    return;
  }
  await pathSvc.createDir(dir);
  await fs.rm(tgt, { force: true });
  await fs.symlink(shim, tgt);
Potential damage 🟡 Medium 🩹 Temporary loss

  • A missing lib or env.d directory can prevent affected shell/tool environment setup from working, but the failure is localized to filesystem setup and can be repaired by correcting the path and rerunning initialization.
  • Reverting the code does not remove a partially created directory, but no persistent user-data corruption or external effect is indicated.
  • Equal business importance is assumed because no business-criticality declaration was supplied.
  • Recoverable after filesystem permissions/links are corrected and the lifecycle is rerun.
  • The new warning behavior can mask the immediate setup failure, so callers do not necessarily receive an exception.
Assessed commit 7367071
Diagram

graph TD
  A["Tool setup"] --> B["Ensure base paths"] --> C["lib and env.d"]
  A --> D["Tool initialization"] --> E["Docker plugins"]
  D --> F["Mono cert store"]
  D --> G["Shared cacerts"]
  H["Image cacerts"] --> G
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Seed the entire volume from the image
  • ➕ Could restore other image-provided paths without tool-specific handling.
  • ➖ Copies more data than needed and couples startup to the image’s full directory layout.

Recommendation: Prefer the targeted repairs: base paths are created centrally, while tool-owned paths are restored during their per-container initialization. This avoids copying the full image layout into the volume.

Files changed (8) +147 / -14

Bug fix (4) +73 / -14
path.service.tsCreate lib and env.d during base-path setup +16/-0

Create lib and env.d during base-path setup

• Adds path getters and ensures both directories exist when base paths are created.

src/cli/services/path.service.ts

index.tsRestore Docker’s global plugin link during initialization +20/-4

Restore Docker’s global plugin link during initialization

• Initialization now links the global CLI plugin path to the cache. It preserves existing paths and logs a warning if global-path setup fails.

src/cli/tools/docker/index.ts

mono.tsCreate Mono’s certificate folder during initialization +9/-3

Create Mono’s certificate folder during initialization

• Moves creation of the certificate-store directory into per-container initialization. Preparation checks whether it existed beforehand to retain its one-time certificate-hook behavior.

src/cli/tools/dotnet/mono.ts

index.tsRestore Java’s shared certificate link +28/-7

Restore Java’s shared certificate link

• Initialization links a missing shared cacerts path to the image’s certificate store. Preparation checks the shared path before initialization, and the prepared-state check also accepts the image’s store.

src/cli/tools/java/index.ts

Tests (4) +74 / -0
path.service.spec.tsVerify new base directories +4/-0

Verify new base directories

• Checks that base-path setup creates lib and env.d under /opt/containerbase.

src/cli/services/path.service.spec.ts

index.spec.tsTest Docker plugin-link restoration +28/-0

Test Docker plugin-link restoration

• Verifies initialization recreates the global CLI plugin link and warns rather than failing when its directory cannot be created.

src/cli/tools/docker/index.spec.ts

mono.spec.tsTest Mono certificate-folder initialization +13/-0

Test Mono certificate-folder initialization

• Verifies initialization creates a missing certificate-store directory and tolerates a second run.

src/cli/tools/dotnet/mono.spec.ts

index.spec.tsTest Java certificate recovery from the image +29/-0

Test Java certificate recovery from the image

• Verifies that the image’s certificate store counts as prepared and that initialization restores a missing shared link without replacing it on a second run.

src/cli/tools/java/index.spec.ts

@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


Remediation recommended

1. Docker plugins stay unavailable after a failed link 🐞 Bug
Description
DockerPrepareService.initialize() catches a failure to create the global plugin link and returns
normally, allowing the preparation service to mark Docker as initialized. If the destination is
temporarily unwritable, later initialization calls skip Docker even after it becomes writable,
leaving the plugin search path absent.
Code

src/cli/tools/docker/index.ts[R59-61]

+    } catch (err) {
+      logger.warn({ err }, 'cannot link the docker cli plugins folder');
+    }
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed global Docker plugin link is warned about but recorded as successful initialization, so later runs do not retry it.

## Fix Focus Areas
- src/cli/tools/docker/index.ts[52-61]
- src/cli/prepare-tool/prepare-tool.service.ts[110-151]

## Recommended Fix
Keep the nonfatal warning where needed, but do not record Docker initialization as complete when its global plugin link could not be created. Ensure a later initialization retries the missing link.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Resolved findings
1. Java preparation fails on empty volumes ✓ Resolved High

Resolving commit: 366f2cc

Resolution reason
The author replaced the unconditional fs.symlink(varCerts, cacerts) in JavaPrepareService.prepare()
with this.pathSvc.createSymlink(varCerts, cacerts) and added a comment that initialize may already
have linked the image cacerts. This avoids the EEXIST failure when initialize has already created
the link at the same path. It does not return early after initialize as the suggested fix describes,
but it addresses the same failure at the same location, and a regression test was added for the case
of var/cacerts present with ssl/cacerts absent.
Description
JavaPrepareService.prepare() records that ssl/cacerts is missing before initialize() creates a
link there, then continues to an unconditional fs.symlink() at the same path. When the image has
var/cacerts but a mounted volume hides ssl/cacerts, an explicit prepare without an existing
prepare marker downloads the store and then fails with EEXIST.

2. Mono misses later certificate updates ✓ Resolved Medium

Resolving commit: 42db97b

Resolution reason
Replaced the hasStore check (captured before initialize) with a check on the hook file's existence
after initialize, so the hook is installed whenever it is missing. Added a test covering initialize
followed by prepare.
Description
MonoPrepareService.prepare() installs the certificate-update hook only when ssl/mono was absent
before initialization, but initialize() now creates that folder without installing the hook. If a
tool is explicitly initialized before it is prepared, the later prepare skips the hook, so
subsequent system certificate updates do not trigger Mono's certificate sync.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/cli/tools/java/index.ts Resolved
@viceice
viceice force-pushed the viceice/fix/volume-folders branch 3 times, most recently from 42db97b to a076457 Compare November 20, 2026 14:48
@viceice

viceice commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Qodo finding "Docker plugins stay unavailable after a failed link" is declined: the warning is on purpose for a read-only root, and the init markers live in the temp folder, so a new container tries again.

Drafted by Claude Code (Claude Opus 5.5, medium effort) on behalf of @viceice.

@viceice
viceice force-pushed the viceice/fix/volume-folders branch from a076457 to 4c1e2b1 Compare November 23, 2026 13:03
Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
@viceice
viceice force-pushed the viceice/fix/volume-folders branch from 4c1e2b1 to 7367071 Compare November 23, 2026 16:10
@viceice
viceice enabled stacked auto-merge November 23, 2026 16:16
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.

1 participant