From 36212e5133c559ef3cbaa88a62ad9d9850d4f700 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 18 Jan 2019 12:15:18 -0500 Subject: [PATCH] mgr/rook: wrap url fetch function in try/except block It's possible for the fetch of this object to fail if the service is being torn down. Handle that situation gracefully, but log a message. Signed-off-by: Jeff Layton --- src/pybind/mgr/rook/rook_cluster.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 1b0dbe2bad40b..862f623463464 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -106,9 +106,15 @@ class RookCluster(object): def get_nfs_conf_url(self, nfs_cluster, instance): # # Fetch cephnfs object for "nfs_cluster" and then return a rados:// - # URL for the instance within that cluster. + # URL for the instance within that cluster. If the fetch fails, just + # return None. # - ceph_nfs = self.rook_api_get("cephnfses/{0}".format(nfs_cluster)) + try: + ceph_nfs = self.rook_api_get("cephnfses/{0}".format(nfs_cluster)) + except ApiException as e: + log.info("Unable to fetch cephnfs object: {}".format(e.status)) + return None + pool = ceph_nfs['spec']['rados']['pool'] namespace = ceph_nfs['spec']['rados'].get('namespace', None) -- 2.39.5