From: John Mulligan Date: Tue, 21 Mar 2023 15:42:25 +0000 (-0400) Subject: mgr/nfs: add support for selecting between haproxy ingress modes X-Git-Tag: v19.0.0~1098^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=322c109f6bd6fa9c4449b4f938d907e1bc75629d;p=ceph.git mgr/nfs: add support for selecting between haproxy ingress modes When the haproxy-standard mode is selected, the haproxy ingress will behave as in previous versions of ceph. When the haproxy-protocol mode is selected, we need to enable protocol support on the ingress service and nfs service. While were at it, make a few organization tweaks to improve readability. Fixes: https://tracker.ceph.com/issues/58933 Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index 3bd36ff3e9958..d558a3a37a1f3 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -73,25 +73,42 @@ class NFSCluster: # run NFS on non-standard port if not ingress_mode: ingress_mode = IngressType.default + ingress_mode = ingress_mode.canonicalize() pspec = PlacementSpec.from_string(placement) if ingress_mode == IngressType.keepalive_only: # enforce count=1 for nfs over keepalive only pspec.count = 1 + + ganesha_port = 10000 + port # semi-arbitrary, fix me someday + frontend_port: Optional[int] = port + virtual_ip_for_ganesha: Optional[str] = None + keepalive_only: bool = False + enable_haproxy_protocol: bool = False + if ingress_mode == IngressType.haproxy_protocol: + enable_haproxy_protocol = True + elif ingress_mode == IngressType.keepalive_only: + keepalive_only = True + virtual_ip_for_ganesha = virtual_ip.split('/')[0] + ganesha_port = port + frontend_port = None + spec = NFSServiceSpec(service_type='nfs', service_id=cluster_id, placement=pspec, # use non-default port so we don't conflict with ingress - port=10000 + port if ingress_mode != IngressType.keepalive_only else port, # semi-arbitrary, fix me someday - virtual_ip=virtual_ip.split('/')[0] if ingress_mode == IngressType.keepalive_only else None) + port=ganesha_port, + virtual_ip=virtual_ip_for_ganesha, + enable_haproxy_protocol=enable_haproxy_protocol) completion = self.mgr.apply_nfs(spec) orchestrator.raise_if_exception(completion) ispec = IngressSpec(service_type='ingress', service_id='nfs.' + cluster_id, backend_service='nfs.' + cluster_id, placement=pspec, - frontend_port=port if ingress_mode != IngressType.keepalive_only else None, + frontend_port=frontend_port, monitor_port=7000 + port, # semi-arbitrary, fix me someday virtual_ip=virtual_ip, - keepalive_only=(ingress_mode == IngressType.keepalive_only)) + keepalive_only=keepalive_only, + enable_haproxy_protocol=enable_haproxy_protocol) completion = self.mgr.apply_ingress(ispec) orchestrator.raise_if_exception(completion) else: diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 0d8d17b587efa..976e841e3686a 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -178,8 +178,8 @@ class IngressType(enum.Enum): def canonicalize(self) -> "IngressType": if self == self.default: - return self.haproxy_standard - return self + return IngressType(self.haproxy_standard) + return IngressType(self) def to_format(what: Any, format: Format, many: bool, cls: Any) -> Any: