Skip to content

Add docker migrate-storage-driver command#613

Merged
sairon merged 2 commits into
masterfrom
docker-migrate-storage
Nov 27, 2025
Merged

Add docker migrate-storage-driver command#613
sairon merged 2 commits into
masterfrom
docker-migrate-storage

Conversation

@sairon
Copy link
Copy Markdown
Member

@sairon sairon commented Nov 27, 2025

Implement CLI for home-assistant/supervisor#6361. Without any extra argument, the command migrates to the overlayfs Containerd snapshotter, but the driver can be specified and will be validated by the Supervisor API - no need for another validation layer here. The list of driver is only used for shell completion.

Summary by CodeRabbit

  • New Features
    • Added a new docker migrate-storage-driver command to schedule storage driver migration for the next reboot.
    • Users can choose supported drivers (overlayfs, overlay2) and benefit from shell completion for those options.
    • Command prompts for confirmation before proceeding and reports when the operation is aborted or completed.

✏️ Tip: You can customize this high-level summary in your review settings.

Implement CLI for home-assistant/supervisor#6361. Without any extra
argument, the command migrates to the overlayfs Containerd snapshotter,
but the driver can be specified and will be validated by the Supervisor
API - no need for another validation layer here. The list of driver is
only used for shell completion.
@sairon sairon requested a review from agners November 27, 2025 15:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a new Cobra CLI command docker migrate-storage-driver that accepts an optional storage driver (default overlayfs), prompts for user confirmation, and posts a JSON payload with storage_driver to a helper endpoint to schedule a migration on next reboot.

Changes

Cohort / File(s) Summary
New storage driver migration command
cmd/docker_migrate_storage_driver.go
Defines dockerMigrateStorageCmd Cobra command (Use, Short, Long, Example, ValidArgsFunction, Args, Run). Accepts optional [driver] (default overlayfs), provides shell completion (overlayfs, overlay2), prompts for confirmation, sends JSON { "storage_driver": "<driver>" } via GenericJSONPost to helper endpoint, handles errors and user abort, and registers under dockerCmd in init().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the POST request payload structure and helper endpoint path.
  • Confirm shell completion and default driver behavior.
  • Review user confirmation prompt and error/exit handling.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add docker migrate-storage-driver command' clearly and accurately summarizes the main change—a new CLI command implementation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docker-migrate-storage

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

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new CLI command docker migrate-storage-driver to schedule Docker storage driver migration on the next system reboot. The command defaults to migrating to overlayfs (Containerd snapshotter) but allows specifying alternative drivers, with validation handled by the Supervisor API.

  • Implements interactive confirmation prompt for destructive operation
  • Provides shell completion for supported storage drivers (overlayfs, overlay2)
  • Uses standard GenericJSONPost helper for API communication

Comment thread cmd/docker_migrate_storage_driver.go
Copy link
Copy Markdown
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM!

This will schedule a Docker storage driver migration to "`+storageDriver+`".
The migration will be applied on the next system reboot. It is strongly
recommended to back up your data before and have at least 50% of free storage.
Are you sure you want to proceed?`, 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would also add that Internet connectivity is required to re-download all the container image.

Maybe writing the message separately before calling the AskForConfirmation is better?

Copy link
Copy Markdown
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM!

@sairon sairon merged commit 2c2df8f into master Nov 27, 2025
8 of 9 checks passed
@sairon sairon deleted the docker-migrate-storage branch November 27, 2025 16:36
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
cmd/docker_migrate_storage_driver.go (1)

42-56: Confirmation prompt looks good with the Internet connectivity note.

The prompt now includes the important details: backup recommendation, internet connectivity requirement, and storage space recommendation.

One minor observation: tries: 0 relies on the helper's internal default of 2. Consider using an explicit value for clarity, though the current behavior is correct.

-	`, 0)
+	`, 2)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between dddb1f1 and 3b23561.

📒 Files selected for processing (1)
  • cmd/docker_migrate_storage_driver.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)

⚙️ CodeRabbit configuration file

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.

  • Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • Use sentence-style capitalization also in headings.

do not comment on HTML used for icons

Avoid flagging inline HTML for embedding videos in future reviews for this repository.

Files:

  • cmd/docker_migrate_storage_driver.go
🧬 Code graph analysis (1)
cmd/docker_migrate_storage_driver.go (3)
client/helper.go (3)
  • AskForConfirmation (203-230)
  • PrintError (314-316)
  • ShowJSONResponse (131-178)
cmd/root.go (1)
  • ExitWithError (27-27)
client/client.go (1)
  • GenericJSONPost (79-81)
🔇 Additional comments (4)
cmd/docker_migrate_storage_driver.go (4)

9-22: LGTM!

The command definition is well-structured with clear documentation. The Use, Short, Long, and Example fields provide comprehensive guidance for users.


23-29: LGTM!

The shell completion function correctly limits suggestions to the first argument and returns the intended driver options for completion purposes.


76-78: LGTM!

Standard Cobra pattern for registering the subcommand under the parent dockerCmd.


69-72: Verify: Setting ExitWithError on deliberate user abort.

When the user explicitly declines the confirmation (enters "no"), ExitWithError is set to true, resulting in a non-zero exit code. A deliberate abort is typically not considered an error condition, and scripts checking exit codes might misinterpret this as a failure.

Verification of the codebase convention could not be completed due to repository access issues. Manual verification is needed to:

  • Check how other commands in the codebase handle user abort scenarios
  • Confirm whether setting ExitWithError on deliberate user abort is consistent with established patterns
  • Determine if this behavior aligns with project conventions for exit codes

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants