From: Guillaume Abrioux Date: Thu, 9 Jun 2022 08:33:31 +0000 (+0200) Subject: ceph-volume: make is_valid() optional X-Git-Tag: v16.2.11~455^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=60b7b87e400223f4a8f35796e8ba2fdabc76405a;p=ceph.git ceph-volume: make is_valid() optional There are cases where `ceph-volume` doesn't have to require a `ceph.conf` file that has the `fsid` parameter. See: https://github.com/rook/rook/pull/10333#pullrequestreview-994958873 Fixes: https://tracker.ceph.com/issues/55970 Signed-off-by: Guillaume Abrioux (cherry picked from commit 7ffea899921dc9996f20ef88531bd1daf82d44aa) --- diff --git a/src/ceph-volume/ceph_volume/configuration.py b/src/ceph-volume/ceph_volume/configuration.py index 2fee47ffab91..e0f7ef1f0c65 100644 --- a/src/ceph-volume/ceph_volume/configuration.py +++ b/src/ceph-volume/ceph_volume/configuration.py @@ -86,13 +86,14 @@ class Conf(conf_parentclass): s = '_'.join(s.split()) return s - def get_safe(self, section, key, default=None): + def get_safe(self, section, key, default=None, check_valid=True): """ Attempt to get a configuration value from a certain section in a ``cfg`` object but returning None if not found. Avoids the need to be doing try/except {ConfigParser Exceptions} every time. """ - self.is_valid() + if check_valid: + self.is_valid() try: return self.get(section, key) except (configparser.NoSectionError, configparser.NoOptionError): diff --git a/src/ceph-volume/ceph_volume/util/encryption.py b/src/ceph-volume/ceph_volume/util/encryption.py index 2a2c03337b61..0639ab14a2cd 100644 --- a/src/ceph-volume/ceph_volume/util/encryption.py +++ b/src/ceph-volume/ceph_volume/util/encryption.py @@ -18,7 +18,7 @@ def get_key_size_from_conf(): key_size = conf.ceph.get_safe( 'osd', 'osd_dmcrypt_key_size', - default='512') + default='512', check_valid=False) if key_size not in ['256', '512']: logger.warning(("Invalid value set for osd_dmcrypt_key_size ({}). "