Skip to content

fix: add checks before adding OSD, WAL, or DB devices#588

Merged
sabaini merged 4 commits intocanonical:mainfrom
sabaini:fix/check-mount
Jul 24, 2025
Merged

fix: add checks before adding OSD, WAL, or DB devices#588
sabaini merged 4 commits intocanonical:mainfrom
sabaini:fix/check-mount

Conversation

@sabaini
Copy link
Copy Markdown
Collaborator

@sabaini sabaini commented Jul 23, 2025

Description

Add checks for mounted devices and partitions. Also add/update some unit tests

Fixes: #507

Type of change

Delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Clean code (code refactor, test updates; does not introduce functional changes)

How has this been tested?

Unit tests

Contributor checklist

Please check that you have:

  • self-reviewed the code in this PR
  • added code comments, particularly in less straightforward areas
  • added tests to verify effectiveness of this change

sabaini added 3 commits July 23, 2025 23:02
This refactors the OSD management code by introducing an OSDManager struct that encapsulates OSD operations:

- Create OSDManager with configurable dependencies (filesystem, runner, storage, validator)
- Replace direct filesystem calls with afero.Fs interface for better testing
- Add PathValidator interface to abstract block device path validation
- Introduce StorageInterface to mock storage operations in tests
- Convert standalone functions to OSDManager methods for better encapsulation
- Add testing

New dep: github.com/spf13/afero

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
Also add unit tests to various OSD mgr methods

Fixes: canonical#507

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
@sabaini sabaini requested a review from lmlg July 23, 2025 21:07
Comment thread microceph/ceph/osd.go Outdated
Also make GetFileStat mock-able and fix mocking for devices

Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
@sabaini
Copy link
Copy Markdown
Collaborator Author

sabaini commented Jul 24, 2025

Thanks @lmlg care to take a look again?

@sabaini sabaini merged commit 9dfa0c7 into canonical:main Jul 24, 2025
32 of 33 checks passed
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.

microceph disk add can run mkfs against unavailable and in-use disks

2 participants