@@ -1135,36 +1135,51 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
11351135 if extra_ssl_cert_provided and spec .generate_cert :
11361136 raise OrchestratorError ("Cannot provide ssl_certificate in combination with generate_cert" )
11371137
1138+ # pick ip RGW should bind to
1139+ ip_to_bind_to = ''
1140+ if spec .only_bind_port_on_networks and spec .networks :
1141+ assert daemon_spec .host is not None
1142+ ip_to_bind_to = self .mgr .get_first_matching_network_ip (daemon_spec .host , spec ) or ''
1143+ if ip_to_bind_to :
1144+ daemon_spec .port_ips = {str (port ): ip_to_bind_to }
1145+ else :
1146+ logger .warning (
1147+ f'Failed to find ip in { spec .networks } for host { daemon_spec .host } . '
1148+ f'{ daemon_spec .name ()} will bind to all IPs'
1149+ )
1150+ elif daemon_spec .ip :
1151+ ip_to_bind_to = daemon_spec .ip
1152+
11381153 if ftype == 'beast' :
11391154 if spec .ssl :
1140- if daemon_spec . ip :
1155+ if ip_to_bind_to :
11411156 args .append (
1142- f"ssl_endpoint={ build_url (host = daemon_spec . ip , port = port ).lstrip ('/' )} " )
1157+ f"ssl_endpoint={ build_url (host = ip_to_bind_to , port = port ).lstrip ('/' )} " )
11431158 else :
11441159 args .append (f"ssl_port={ port } " )
11451160 if spec .generate_cert :
11461161 args .append (f"ssl_certificate=config://rgw/cert/{ daemon_spec .name ()} " )
11471162 elif not extra_ssl_cert_provided :
11481163 args .append (f"ssl_certificate=config://rgw/cert/{ spec .service_name ()} " )
11491164 else :
1150- if daemon_spec . ip :
1151- args .append (f"endpoint={ build_url (host = daemon_spec . ip , port = port ).lstrip ('/' )} " )
1165+ if ip_to_bind_to :
1166+ args .append (f"endpoint={ build_url (host = ip_to_bind_to , port = port ).lstrip ('/' )} " )
11521167 else :
11531168 args .append (f"port={ port } " )
11541169 elif ftype == 'civetweb' :
11551170 if spec .ssl :
1156- if daemon_spec . ip :
1171+ if ip_to_bind_to :
11571172 # note the 's' suffix on port
1158- args .append (f"port={ build_url (host = daemon_spec . ip , port = port ).lstrip ('/' )} s" )
1173+ args .append (f"port={ build_url (host = ip_to_bind_to , port = port ).lstrip ('/' )} s" )
11591174 else :
11601175 args .append (f"port={ port } s" ) # note the 's' suffix on port
11611176 if spec .generate_cert :
11621177 args .append (f"ssl_certificate=config://rgw/cert/{ daemon_spec .name ()} " )
11631178 elif not extra_ssl_cert_provided :
11641179 args .append (f"ssl_certificate=config://rgw/cert/{ spec .service_name ()} " )
11651180 else :
1166- if daemon_spec . ip :
1167- args .append (f"port={ build_url (host = daemon_spec . ip , port = port ).lstrip ('/' )} " )
1181+ if ip_to_bind_to :
1182+ args .append (f"port={ build_url (host = ip_to_bind_to , port = port ).lstrip ('/' )} " )
11681183 else :
11691184 args .append (f"port={ port } " )
11701185 else :
0 commit comments