mirror of
https://github.com/ceph/ceph
synced 2025-01-10 13:10:46 +00:00
mgr/cephadm: apply hostname/addr checks to 'orch host set-addr' too
Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
parent
a8acc354dc
commit
b5d39be188
@ -1359,25 +1359,18 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
|
||||
)
|
||||
]
|
||||
|
||||
def _add_host(self, spec):
|
||||
# type: (HostSpec) -> str
|
||||
"""
|
||||
Add a host to be managed by the orchestrator.
|
||||
|
||||
:param host: host name
|
||||
"""
|
||||
assert_valid_host(spec.hostname)
|
||||
def _check_valid_addr(self, host: str, addr: str) -> None:
|
||||
# make sure hostname is resolvable before trying to make a connection
|
||||
try:
|
||||
utils.resolve_ip(spec.addr)
|
||||
utils.resolve_ip(addr)
|
||||
except OrchestratorError as e:
|
||||
msg = str(e) + f'''
|
||||
You may need to supply an address for {spec.addr}
|
||||
You may need to supply an address for {addr}
|
||||
|
||||
Please make sure that the host is reachable and accepts connections using the cephadm SSH key
|
||||
To add the cephadm SSH key to the host:
|
||||
> ceph cephadm get-pub-key > ~/ceph.pub
|
||||
> ssh-copy-id -f -i ~/ceph.pub {self.ssh_user}@{spec.addr}
|
||||
> ssh-copy-id -f -i ~/ceph.pub {self.ssh_user}@{addr}
|
||||
|
||||
To check that the host is reachable open a new shell with the --no-hosts flag:
|
||||
> cephadm shell --no-hosts
|
||||
@ -1386,19 +1379,30 @@ Then run the following:
|
||||
> ceph cephadm get-ssh-config > ssh_config
|
||||
> ceph config-key get mgr/cephadm/ssh_identity_key > ~/cephadm_private_key
|
||||
> chmod 0600 ~/cephadm_private_key
|
||||
> ssh -F ssh_config -i ~/cephadm_private_key {self.ssh_user}@{spec.addr}'''
|
||||
> ssh -F ssh_config -i ~/cephadm_private_key {self.ssh_user}@{addr}'''
|
||||
raise OrchestratorError(msg)
|
||||
|
||||
out, err, code = CephadmServe(self)._run_cephadm(spec.hostname, cephadmNoImage, 'check-host',
|
||||
['--expect-hostname', spec.hostname],
|
||||
addr=spec.addr,
|
||||
error_ok=True, no_fsid=True)
|
||||
out, err, code = CephadmServe(self)._run_cephadm(
|
||||
host, cephadmNoImage, 'check-host',
|
||||
['--expect-hostname', host],
|
||||
addr=addr,
|
||||
error_ok=True, no_fsid=True)
|
||||
if code:
|
||||
# err will contain stdout and stderr, so we filter on the message text to
|
||||
# only show the errors
|
||||
errors = [_i.replace("ERROR: ", "") for _i in err if _i.startswith('ERROR')]
|
||||
raise OrchestratorError('New host %s (%s) failed check(s): %s' % (
|
||||
spec.hostname, spec.addr, errors))
|
||||
raise OrchestratorError('Host %s (%s) failed check(s): %s' % (
|
||||
host, addr, errors))
|
||||
|
||||
def _add_host(self, spec):
|
||||
# type: (HostSpec) -> str
|
||||
"""
|
||||
Add a host to be managed by the orchestrator.
|
||||
|
||||
:param host: host name
|
||||
"""
|
||||
assert_valid_host(spec.hostname)
|
||||
self._check_valid_addr(spec.hostname, spec.addr)
|
||||
|
||||
# prime crush map?
|
||||
if spec.location:
|
||||
@ -1438,6 +1442,7 @@ Then run the following:
|
||||
|
||||
@handle_orch_error
|
||||
def update_host_addr(self, host: str, addr: str) -> str:
|
||||
self._check_valid_addr(host, addr)
|
||||
self.inventory.set_addr(host, addr)
|
||||
self._reset_con(host)
|
||||
self.event.set() # refresh stray health check
|
||||
|
Loading…
Reference in New Issue
Block a user