From: Joshua Schmid Date: Thu, 30 Apr 2020 13:27:49 +0000 (+0200) Subject: python-common: do not pass affinity to ceph_volume when None X-Git-Tag: v15.2.4~73^2~77 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8194e3c958895867c72a2f29de32bb4efc9b89d5;p=ceph.git python-common: do not pass affinity to ceph_volume when None Signed-off-by: Joshua Schmid (cherry picked from commit fbed226327ea67ea56513568213101f7a8ef51b7) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 833f93fa10f8..07cf44ef0d24 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2061,20 +2061,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): return [self._apply(spec) for spec in specs] def get_osdspec_affinity(self, osd_id: str) -> str: - ret, out, err = self.mon_command({ - 'prefix': 'osd metadata', - 'id': int(osd_id), - 'format': 'json' - }) - if ret != 0: - self.log.warning(f"Caught error on calling 'osd metadata {osd_id}' -> {err}") - return '' - try: - metadata = json.loads(out) - except json.decoder.JSONDecodeError: - self.log.error(f"Could not decode json -> {out}") - return '' - return metadata.get('osdspec_affinity', '') + return self.get('osd_metadata').get(osd_id, {}).get('osdspec_affinity', '') def find_destroyed_osds(self) -> Dict[str, List[str]]: osd_host_map: Dict[str, List[str]] = dict() diff --git a/src/python-common/ceph/deployment/translate.py b/src/python-common/ceph/deployment/translate.py index 1431836b2ae9..3e82a7889769 100644 --- a/src/python-common/ceph/deployment/translate.py +++ b/src/python-common/ceph/deployment/translate.py @@ -101,6 +101,7 @@ class to_ceph_volume(object): cmd += " --report" cmd += " --format json" - cmd = f"CEPH_VOLUME_OSDSPEC_AFFINITY={self.spec.service_id} " + cmd + if self.spec.service_id is not None: + cmd = f"CEPH_VOLUME_OSDSPEC_AFFINITY={self.spec.service_id} " + cmd return cmd