Commit Graph

99 Commits

Author SHA1 Message Date
Federico Bosi 2d5663b83c
Don't bind to ipv4 if prefer-ipv6 is true
Following https://tracker.ceph.com/issues/52867 we need to tell the OSD
which address family to use via the ms_bind_ipv4/6 config flags.
I added them to the ceph.conf template and updated the config hook.
Launchpad: https://bugs.launchpad.net/charm-ceph-osd/+bug/2056337

Change-Id: Ifbd59c204a82109e2b71991078f59537f6db42d3
2024-04-10 09:00:15 +02:00
Peter Sabaini bd57a326e9 Sync charmhelpers
Prep for noble/caracal, unit test fix

Change-Id: I5ad6b618bb3a5660a61ac3c536430c8e380e655c
2024-04-09 13:26:14 +02:00
Zuul 5bba68b2b2 Merge "Update command references to juju 3.x syntax" 2023-12-07 15:10:49 +00:00
Nobuto Murata c4209b3965 Allow ceph device scrape-health-metrics
Ceph has a function to collect health metrics through smartctl or nvme
command out of the box. And it relies on sudo spawned from the ceph-osd
process so it needs to be considered in the apparmor policy.

[/etc/sudoers.d/ceph-smartctl in ceph-base package]
> ## allow ceph daemons (which run as user ceph) to collect device
> ## health metrics
>
> ceph ALL=NOPASSWD: /usr/sbin/smartctl -x --json=o /dev/*
> ceph ALL=NOPASSWD: /usr/sbin/nvme * smart-log-add --json /dev/*

Also sync charmhelpers and mock platform info

Closes-Bug: #2031637
Change-Id: I981a5db0fd49eca83aa8a619f0cbd0d34a533842
2023-11-06 20:18:36 +01:00
Peter Sabaini 1bac66ee50 Remove FileStore support
Remove support for creating FileStore OSDs. Also prevent upgrade
attempts to Reef if a FileStore OSD is detected

Change-Id: I9609bc0222365cb1f4059312b466a12ef4e0397f
2023-10-06 09:03:51 +02:00
Samuel Walladge ceb8187284 Warn in status if tune-osd-memory-target invalid
This is useful, because if an invalid value is set,
the value is ignored and not overridden,
and an error logged.
So now we warn about this in the status to be more obvious to the user.

Change-Id: Idc4a7706f30cbcea8aee83a1406fa84139fe510d
2023-09-29 13:39:08 +09:30
Jake Nabasny 2380ad7cde Update command references to juju 3.x syntax
Change-Id: I4f1e1bbcf43a55b465382af914a0951aedf8c62b

Change "relate" to "integrate" in README juju cmd

Change-Id: I4f1e1bbcf43a55b465382af914a0951aedf8c62b
2023-09-20 12:07:47 -04:00
Samuel Walladge ba6186e5de Add config option for tuning osd memory target
Closes-Bug: #1934143

Depends-On: https://review.opendev.org/c/openstack/charm-ceph-mon/+/869896

Change-Id: I22dfc25c4ac2737f5d872ca2bdab3c533533dbff
2023-08-15 15:16:52 +09:30
Zuul cc9bceca32 Merge "Add mock to make unit tests work on Kinetic" 2023-03-28 12:47:40 +00:00
Peter Sabaini 8c7ae6889a Fix: increase timeout for remove-disk
The `ceph osd purge` command used for the remove-disk action can take
several minutes to run. Increase the timeout for this to avoid
spurious errors.

Change-Id: I3a7fafa42c4a2ecaf45ba476e0157937e468ca33
2023-03-20 17:33:03 +01:00
utkarshbhatthere 470be74771
Adds timeout for ceph command calls.
Change-Id: I8c81b1f0042181d814d5f268282b082c8a5fc217
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/989
2023-03-10 17:42:53 +05:30
Zuul f50e64fb33 Merge "Enable users to start/stop Crimson OSD's" 2022-11-08 15:08:26 +00:00
Luciano Lo Giudice dbe3ee52bc Enable users to start/stop Crimson OSD's
This patchset modifies the add-disk action so that it now
can optionally start a Crimson OSD daemon.

Change-Id: I59bf4e41f1f56c6bda2352b5613289ff73113342
Depends-On: If58bde4d5445ed5de420abc007db6bf8b8e43269
2022-10-18 18:11:47 -03:00
Chris MacNaughton aa64bbcbcd Add mock to make unit tests work on Kinetic
Change-Id: I0740c4ad27da89b9dbfbc49af4aaf3e3443af012
2022-09-12 14:24:29 -04:00
Chris MacNaughton ea56c2c197 Ensure add-disk and hooks handle disks the same way
Depends-On: I2ea119f5a1b2a36ccd36df4db094f208a1db100e
Depends-On: Ie19e5318ea35c38e5d02963260b85fec0f233df6
Change-Id: Idebe45504233fb5559a3e9ddd9b2d6534cba7bb2
Closes-Bug: #1820271
2022-09-12 09:29:05 -04:00
Luciano Lo Giudice 55720fa087 Implement the 'remove-disk' action
This new action allows users to either purge an OSD, or remove it,
opening up the possibility of recycling the previous OSD id. In
addition, this action will clean up any bcache devices that were
created in previous steps.

Change-Id: If3566031ba3f02dac0bc86938dcf9e85a66a66f0
Depends-On: Ib959e81833eb2094d02c7bdd507b1c8b7fbcd3db
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/683
2022-03-31 18:50:22 +00:00
Luciano Lo Giudice 65207967cf Enhance the 'add-disk' action for disk replacement
As part of the task to improve disk replacement, the 'add-disk' action
needs some changes. This includes:
- Creating 'bcache' devices to accelerate disk access.
- Creating caching partitions of a specified size.
- Recycling previously deactivated OSD ids.

Change-Id: Id5027f30d51c23d2be4c34f82867d65a50b35137
Depends-On: I43d0a0bc11664c37532c0117711affc93c9d1ad1
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/675
2022-02-18 12:43:46 -03:00
James Troup 73fe60b3df Spelling fixes from codespell with additional consistency cleanups.
Includes a resync of charms.ceph.

Change-Id: I281fe17acaea826b79bfa902a8d9e7a8b59482a9
2021-12-20 13:21:33 +00:00
Hervé Beraud 4cbac58ba1 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: Ib658c7f61fe4aceafc1919e366d24ce81ec1dd63
2021-12-15 09:39:12 +00:00
Zuul e8a6a4f5c7 Merge "Add an action to provide information about AZ" 2021-09-07 12:11:00 +00:00
Zuul 02ce3954a3 Merge "Only consider mounted OSD directories" 2021-09-06 03:15:40 +00:00
Robert Gildein d0d3d3edf5 Add an action to provide information about AZ
The 'get-availability-zone' action will get information about an
availability zone that will contain information about the CRUSH
structure. Specifically 'rack' and 'row'.

Closes-Bug: #1911006
Change-Id: I99ebbef5f23d6efe3c848b089c7f2b0d26ad0077
2021-09-03 09:48:24 +02:00
Luciano Lo Giudice 93e9885aa7 Only consider mounted OSD directories
When gathering the list of local OSD ids, the charm would consider
the entries under '/var/lib/ceph/osd/ceph-XXX' where 'XXX" was the
OSD id. However, if an entry under that directory isn't mounted,
then the OSD that would represent that entry should be discarded,
as it's no longer active. This patchset thus filters those entries
by looking for them in the mount points.

Closes-Bug: #1934938
Change-Id: I69c6356e450cc0c96de4afe571b438d4a2ea5177
2021-09-02 18:55:18 -03:00
Nikhil Kshirsagar 489a4ede69 Do not zap a disk if it is used by lvm2
If the disk being zapped is used by lvm (if it contains the
lvm label and hasn't been pvremove'd) it's safer to simply
bail out of zapping it than attempt teardown through a force
pvremove, because the disk being zapped might be in fact in
use by some LV.

Closes-Bug: 1858519
Change-Id: I111475c5a4584a3e367c604ab51ce2ef3789ff7f
2021-08-25 11:34:42 +05:30
Robert Gildein e928f1376c Add `osds` argument to the osd-in/osd-out action
The `osds` parameter has been copied from function start/stop to preserve
the same functionality. By default, osd-in/osd-out needs list of IDs as
an argument or it will not do anything (previously, it applied the change
to all the osds). It's possible to take in/out *all* with provided `osds`
parameter as `all`.

Closes-Bug: #1910150
Change-Id: I0275f015e2d0bbbb661d2b7dea59c320ba6c021c
2021-01-15 15:13:29 +01:00
Martin Kalcok e22f602544 Added `start` and `stop` actions for management of ceph OSDs
Change-Id: If8b83ab06364903548c5841487034bc1bb9aaf0c
Closes-Bug: #1477731
func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/473
2020-12-15 17:29:24 +01:00
Robert Gildein bc071cd208 add function to check if device exists
- if the device does not exists, the action failed with message:
  '/dev/<device>: Device does not exists.'

Closes-Bug: #1885336
Change-Id: I417c0074fe64c2afceecdfb09b8673930087f65f
2020-11-25 12:54:49 +01:00
Frode Nordahl b49468fc10
Add BlueStore Compression support
Sync in updates from charm-helpers and charms.ceph.

Depends-On: I153c22efb952fc38c5e3d36eed5d85c953e695f7
Depends-On: Ibec4e3221387199adbc1a920e130975d7b25343c
Change-Id: I028440002cdd36be13aaee4a0f50c6a0bca7abda
2020-08-26 16:30:24 +02:00
Liam Young ad656e515d Provides unit_name to secrets provider
Pass the unit name to the secrets provider via relation data. The
unit name is not available in CMRs so needs to be passes this way.

Change-Id: I9fa162bbf45144d0827c669fc9b37d7b336366cd
2020-07-11 08:44:17 +00:00
Liam Young 3e795f6a62 Apply OSD settings from mons.
Apply OSD settings requested by the mons via the juju relation.
Add the OSD settings to config too. Before applying the settings
config-flags is checked to ensure there is no overlap.

Change-Id: Id69222217a1c99d0269831913abdf488791cb572
2020-05-04 08:23:00 +00:00
Corey Bryant fcfa499f11 Rename lib/ceph to lib/charms_ceph
The new python3-ceph-common deb package (introduced in ceph octopus)
adds a new ceph directory (a parent package in python terms) in
/usr/lib/python3/dist-packages/ceph/. This results in a conflict with
charm-ceph-osd/lib/ceph/. For example, with the current import of
ceph.utils in hooks/ceph_hooks.py, Python finds no utils.py in
/usr/lib/python3/dist-packages/ceph/ and then stops searching.
Therefore, rename lib/ceph to lib/charms_ceph to avoid the conflict.

Depends-On: https://review.opendev.org/#/c/709226
Change-Id: I13ae7c048d8f1eef2ea64b13ae14b51dbfaaf3cd
2020-02-24 15:21:33 +00:00
Chris MacNaughton 01cb6acc48 Add mock for get_blacklist
Change-Id: I53a95911e47710db207721b6d6e5c556a33b0249
Closes-Bug: #1863636
2020-02-17 17:28:28 +01:00
Edward Hope-Morley 871b057335 Ensure bootstrapped-osds count updated after add-disk
When we add/zap disks it may change the overall osd
count so need to ensure this is kept up-to-date.

Change-Id: Ib55547f88316e80a8948ce808ea992c1402458f5
Closes-Bug: #1861293
2020-02-03 15:45:56 +00:00
taodd 8ca701eb87 Fix list-disk action wrongly report osd journal as the non-pristine device
Change-Id: Ib117fc5797447ade75d50a7ff7dae5de473fe7b9
Closes-Bug: #1847988
2019-10-23 15:27:17 +08:00
Felipe Reyes 0a0b9ba316 Fix bdev-enable-discard to honor the documentation
When the user provides an unexpected value in this configuration option
a warning message is logged and the workload is set to blocked.

Closes-Bug: #1835145
Change-Id: I10cac1cf43c11cf11fde196244820ac28b5a47d0
2019-07-03 17:01:16 -04:00
Zachary Zehring 28ca5957b3 Notify ceph-mon relations on version upgrade.
This notification is added to allow ceph-mon to know
when ceph-osd units have upgraded in order to run
post-upgrade commands (required for certain upgrades).

- Add notify_mon_of_upgrade function that sets
ceph_release to release version.

- Refactor some hard coded strings to vars

- Set relation ceph_release when setting bootstrapped-osd

Change-Id: I708b33cafc8818af7e3c63a7fa80c02978e66f65
Partial-Bug: #1828630
2019-05-21 15:30:00 -04:00
Andre Ruiz 56495eecba Implement new option to enable discard on SSDs
This change implements a new option called 'bdev-enable-discard' to control
behaviour of issuing discards to SSDs on ceph bluestore. The new code tries
to autodetect cases where it should be enabled by default but will allow
forcing if desired.

Change-Id: I7b83605c827eb4058bc4b46c92eb114c11108c93
Closes-Bug: #1788433
2019-03-01 15:26:56 +01:00
Pete Vander Giessen 7b242ebbc3 Don't clobber apparmor profiles.
The charm attempts to avoid restarts of the ceph-osd processes
by asssessing whether new or changed apparmor profiles have
been installed.

The charm always copies apparmor files from the charm to
/etc/apparmor.d which overwrites any local changes made to the
profile - specifically if the profile is in complain mode.

As the content of the profile then changes the restart_on_change
decorator then fires the aa_profile_changed function which
switches the profile back into enforce mode.

This change only overwrites apparmor profiles in the event
that the hash of the source file in the charm changes; if it
does then the current profile mode is re-asserted to ensure
that complain mode deployments don't switch to enforce by
mistake.

Change-Id: I8f8cbf17af6219bd9fbdcf71a7000cba4c63f3f3
Closes-Bug: 1783373
Co-Authored-By: James Page <james.page@ubuntu.com>
2019-02-19 09:29:02 +00:00
Felipe Reyes 336581efeb Update cloud-archive.list when upgrading from Pike to Queens
ceph-osd charm only upgrades when the ceph version changes, for the
case of upgrading from Pike to Queens the charm is skipping any
upgrades, because the Cloud Archive has Luminous for those 2 releases.

This patch checks if the requested ceph version is luminous and if the
'source' changed from pike to queens to then upgrade
/etc/apt/sources.list.d/cloud-archive.list via add_source()

Change-Id: I27c2d7648a1add6528924724a03682060d2d6007
Closes-Bug: 1778823
2019-02-01 11:47:05 -03:00
David Ames 1e0c6548b8 Rename pause/resume osd-out/osd-in
The actions pause and resume actually take all osds on a unit out of the
cluster. This is incredibly misleading.

This change renames to osd-out and osd-in to better describe what the
actions actually do.

Change-Id: I76793999f5d3382563eff308a5d7c4db18d065a0
Closes-Bug: #1793507
2018-11-27 14:48:47 -08:00
Zuul f2b1b942f7 Merge "Avoid unnecessary rewrites of ceph.conf" 2018-11-07 09:53:35 +00:00
Ryan Beisner 8939e57d05
Fix lint in unit tests re: py3-first and py2 compat
Change-Id: Id4a78f4f98b3fc93c42018fc9616b2482a4ff80a
2018-11-01 22:44:08 -05:00
Edward Hope-Morley 42c9b7a625 Avoid unnecessary rewrites of ceph.conf
Charm should avoid writing ceph.conf unless it absolutely needs
to since this can clash with other processes that might be
reading the file (such as ceph-disk called by udev).

Change-Id: I3790b5b16fa1473f1c3271b795b3d32c5e8d2fad
Closes-Bug: #1783113
2018-10-29 08:55:56 -06:00
James Page 488f7dffef Use provided device paths
Ensure that device paths provided by end users are used for OSD's,
rather than the link target device as this may change between
reboots. The specific use case is bcache, where:

   /dev/bcacheX:
        changes between reboots
   /dev/disk/by-dname/bcacheX:
        udev managed and consistent

This change also ensures that any unit data is updated to switch
back to using the provided block device path, rather than the
actual target which may have been used in prior charm revisions.

Change-Id: If5e88d93b9323052ea762d3a4b66f2442d4a19be
Depends-On: If0e1fbc62bfe7d0f9e21db9bfdeee761060de846
Closes-Bug: 1782439
2018-07-27 13:51:55 +01:00
Dmitrii Shcherbakov e340cc851c ignore devices that have already been processed
Similar to how osdize in charms.ceph checks for already processed
devices we need to avoid checking if they are pristine or not.

Additionally, mapped LUKS devices need to be filtered from being zapped
as they may hold valuable data. They are only used as underlying devices
for device mapper and dmcrypt to provide a decrypted block device
abstration so if they really need to be zapped a mapping needs to be
removed first.

This change also pulls charms.ceph modifications.

Change-Id: I96b3d40b3f9e56681be142377e454b15f9e22be3
Co-Authored-By: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
Co-Authored-By: Chris Procter <chris.procter@canonical.com>
Closes-Bug: 1781453
2018-07-17 14:30:51 +03:00
James Page dd42690347 Skip udev rule install in containers
Ensure that udev rules are not installed and reloaded
when running in a container; this is not permitted and
the udev rules are used for block devices, which are
not supported within container based deployments.

Change-Id: I9a580172fcbbf8cec63af7adccb0808915184658
Closes-Bug: 1776713
2018-07-04 04:57:33 +01:00
Zuul 1514ea0c3e Merge "Fix osd object name restriction" 2018-06-05 08:14:42 +00:00
Edward Hope-Morley a777297594 Fix osd object name restriction
The list of devices provided to the charm is currently incorrectly
parsed such that object names are always limited to 256 chars. This
patch ensures that the expected criteria is met.

Change-Id: Ic5b25af614c77b35484b12dc654df5ac595d9d80
Closes-Bug: 1775029
2018-06-04 16:39:51 +01:00
Frode Nordahl 352d699387
Add pre-flight check for device pristinity
Add `non-pristine` key to `list-disks` action.

No longer attempt to do initializtion of `osd-journal` devices.

Make py27 test noop

Flip pep8 test to py3

Partial-Bug: #1698154
Change-Id: I0ca574fa7f0683b4e8a693b9f62fbf6b39689789
Depends-On: I90a866aa138d18e4242783c42d4c7c587f696d7d
2018-06-04 17:02:11 +02:00
Chris MacNaughton 487658abe0 Add action to zap disk(s)
This action includes configuration for disk(s) to
zap, as well as an additional required flag for
the administrator to acknowledge pending data loss

Change-Id: I3106e2f10cf132a628aad025f73161b04215598e
Related-Bug: #1698154
2018-06-04 13:08:45 +02:00