Skip to content

feat: allow wiping disks when adding to ceph#655

Merged
hemanthnakkina merged 1 commit into
canonical:mainfrom
gboutry:feat/wipe-disks
Feb 17, 2026
Merged

feat: allow wiping disks when adding to ceph#655
hemanthnakkina merged 1 commit into
canonical:mainfrom
gboutry:feat/wipe-disks

Conversation

@gboutry
Copy link
Copy Markdown
Collaborator

@gboutry gboutry commented Feb 2, 2026

Add a per machine flag to tell microceph to wipe disks before adding them as OSD.

The flag will be: dangerous_i_acknowledge_i_will_lose_data_wipe_disks

Example:

core:
  config:
    microceph_config:
      bm0.res:
        osd_devices: /dev/sda,/dev/sdb
        dangerous_i_acknowledge_i_will_lose_data_wipe_disks: true
      bm1.res:
        osd_devices: /dev/sda,/dev/sdc
        dangerous_i_acknowledge_i_will_lose_data_wipe_disks: false

@gboutry gboutry marked this pull request as draft February 2, 2026 18:06
@gboutry gboutry force-pushed the feat/wipe-disks branch 2 times, most recently from 7cc45ec to 3815160 Compare February 2, 2026 18:11
@gboutry gboutry marked this pull request as ready for review February 12, 2026 08:18
Copy link
Copy Markdown

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 support for wiping disks before adding them as OSDs to MicroCeph. Users can enable this dangerous operation on a per-machine basis via the manifest configuration using the flag dangerous_i_acknowledge_i_will_lose_data_wipe_disks.

Changes:

  • Added a new boolean field dangerous_i_acknowledge_i_will_lose_data_wipe_disks to the manifest's _HostMicroCephConfig model
  • Extended ConfigureMicrocephOSDStep and MaasConfigureMicrocephOSDStep to read the wipe flag from the manifest and pass it to the microceph add-osd action
  • Added comprehensive test coverage for the wipe functionality in both step implementations

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sunbeam-python/sunbeam/core/manifest.py Added dangerous_i_acknowledge_i_will_lose_data_wipe_disks boolean field to _HostMicroCephConfig model with default value False
sunbeam-python/sunbeam/steps/microceph.py Added wipe instance variable and logic to read wipe flag from manifest and pass it to the add-osd action
sunbeam-python/sunbeam/provider/maas/steps.py Extended MaasConfigureMicrocephOSDStep to accept manifest parameter, added _wipe_requested() helper method, and updated run() to pass wipe parameter to add-osd action
sunbeam-python/sunbeam/provider/maas/commands.py Updated instantiation of MaasConfigureMicrocephOSDStep to pass the manifest parameter
sunbeam-python/tests/unit/sunbeam/steps/test_microceph.py Added tests for wipe=True and wipe=False scenarios, updated existing tests to set the wipe attribute
sunbeam-python/tests/unit/sunbeam/provider/maas/test_maas.py Added tests for _wipe_requested() method and wipe flag handling in run(), updated fixture to include manifest parameter, fixed tests to set unit_to_hostname mapping

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +89 to 90


Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The tests are missing coverage for the prompt() method of ConfigureMicrocephOSDStep, specifically for testing that the wipe flag is correctly read from the manifest. This would have caught the naming inconsistency bug in lines 322-324. Consider adding a test that verifies the prompt() method correctly reads the dangerous_i_acknowledge_i_will_lose_data_wipe_disks field from the manifest and sets self.wipe appropriately.

Suggested change
def test_prompt_reads_wipe_flag_true_from_manifest(self, cclient, jhelper):
"""Ensure prompt() sets wipe=True when manifest flag is True."""
step = ConfigureMicrocephOSDStep(cclient, "test-0", jhelper, "test-model")
# Simulate manifest containing the dangerous wipe flag set to True.
manifest = {
"dangerous_i_acknowledge_i_will_lose_data_wipe_disks": True,
}
# Set possible manifest attributes used by the implementation.
step.manifest = manifest
step._manifest = manifest
console = Mock()
step.prompt(console)
assert step.wipe is True
def test_prompt_reads_wipe_flag_false_from_manifest(self, cclient, jhelper):
"""Ensure prompt() sets wipe=False when manifest flag is False."""
step = ConfigureMicrocephOSDStep(cclient, "test-0", jhelper, "test-model")
manifest = {
"dangerous_i_acknowledge_i_will_lose_data_wipe_disks": False,
}
step.manifest = manifest
step._manifest = manifest
console = Mock()
step.prompt(console)
assert step.wipe is False

Copilot uses AI. Check for mistakes.
# Preseed can have osd_devices as list. If so, change to comma separated str
osd_devices = microceph_config.get(self.node_name, {}).get("osd_devices")
wipe_disks = microceph_config.get(self.node_name, {}).get(
"dangerous-i-acknowledge-i-will-lose-data-wipe-disks", False
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The field name in the manifest model uses underscores (dangerous_i_acknowledge_i_will_lose_data_wipe_disks) but this code is looking for hyphens (dangerous-i-acknowledge-i-will-lose-data-wipe-disks) in the dumped dictionary. Since the _HostMicroCephConfig model doesn't define an alias for this field, when model_dump(by_alias=True) is called on line 313, the dictionary will use the field name with underscores, not hyphens. This will cause the wipe_disks variable to always be False regardless of the actual manifest value, breaking the wipe functionality. Either add an alias to the manifest field or change the key lookup here to use underscores instead of hyphens.

Suggested change
"dangerous-i-acknowledge-i-will-lose-data-wipe-disks", False
"dangerous_i_acknowledge_i_will_lose_data_wipe_disks", False

Copilot uses AI. Check for mistakes.
Comment thread sunbeam-python/sunbeam/steps/microceph.py
Add a per machine flag to tell microceph to wipe disks before adding
them as OSD.

The flag will be: `dangerous_i_acknowledge_i_will_lose_data_wipe_disks`

Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
@hemanthnakkina hemanthnakkina merged commit e2c6e17 into canonical:main Feb 17, 2026
6 checks passed
@gboutry gboutry deleted the feat/wipe-disks branch February 17, 2026 21:25
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.

3 participants