From: Jeff Layton Date: Mon, 25 Feb 2019 14:27:02 +0000 (-0500) Subject: mgr/rook: allow scaling nfs count X-Git-Tag: v14.1.1~40^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=32161b7699bd9c14f7eec9dfe57fe893b36b365b;p=ceph.git mgr/rook: allow scaling nfs count Allow rook to handle scaling the NFS server count up and down in an NFS cluster. We just manifest these changes as change to the spec.server.active field in the CRD. Signed-off-by: Jeff Layton --- diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 0aac98a23d79..1e032bd82e67 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -400,6 +400,16 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): lambda: self.rook_cluster.update_mon_count(num), None, "Updating mon count to {0}".format(num)) + def update_stateless_service(self, svc_type, spec): + # only nfs is currently supported + if svc_type != "nfs": + raise NotImplementedError(svc_type) + + num = spec.count + return RookWriteCompletion( + lambda: self.rook_cluster.update_nfs_count(spec.name, num), None, + "Updating NFS server count in {0} to {1}".format(spec.name, num)) + def create_osds(self, drive_group, all_hosts): # type: (orchestrator.DriveGroupSpec, List[str]) -> RookWriteCompletion diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index b180dcfb30e4..2e1efbff31a6 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -348,6 +348,19 @@ class RookCluster(object): return "Updated mon count to {0}".format(newcount) + def update_nfs_count(self, svc_id, newcount): + patch = [{"op": "replace", "path": "/spec/server/active", "value": newcount}] + + try: + self.rook_api_patch( + "cephnfses/{0}".format(svc_id), + body=patch) + except ApiException as e: + log.exception("API exception: {0}".format(e)) + raise ApplyException( + "Failed to update NFS server count for {0}: {1}".format(svc_id, e)) + return "Updated NFS server count for {0} to {1}".format(svc_id, newcount) + def add_osds(self, drive_group, all_hosts): # type: (orchestrator.DriveGroupSpec, List[str]) -> None """