| [--log-dir LOG_DIR] [--logrotate-dir LOGROTATE_DIR]
| [--unit-dir UNIT_DIR] [--verbose] [--timeout TIMEOUT]
| [--retry RETRY] [--no-container-init]
-| {version,pull,inspect-image,ls,list-networks,list-rdma,adopt,rm-daemon,rm-cluster,run,shell,enter,ceph-volume,unit,logs,bootstrap,deploy,check-host,prepare-host,prepare-host-sudo-hardening,setup-ssh-user,add-repo,rm-repo,install,list-images,update-osd-service}
+| {version,pull,inspect-image,ls,list-networks,list-rdma,adopt,rm-daemon,rm-cluster,run,shell,enter,ceph-volume,unit,logs,bootstrap,deploy,check-host,check-online,prepare-host,prepare-host-sudo-hardening,setup-ssh-user,add-repo,rm-repo,install,list-images,update-osd-service}
| ...
| **cephadm** **check-host** [-h] [--expect-hostname EXPECT_HOSTNAME]
+| **cephadm** **check-online**
+
| **cephadm** **prepare-host**
| **cephadm** **add-repo** [-h] [--release RELEASE] [--version VERSION]
* [--expect-hostname EXPECT_HOSTNAME] Check that hostname matches an expected value
+check-online
+------------
+
+check that the host is online by running ``true`` locally.
+
+This command is primarily intended for cephadm internals (for example, the
+offline host watcher), rather than direct operator workflows.
+
+
deploy
------
##################################
+def command_check_online(ctx: CephadmContext) -> int:
+ return 0
+
+
def command_prepare_host(ctx: CephadmContext) -> None:
logger.info('Verifying podman|docker is present...')
pkg = None
'--expect-hostname',
help='Check that hostname matches an expected value')
+ parser_check_online = subparsers.add_parser(
+ 'check-online', help='return true to indicate host is running')
+ parser_check_online.set_defaults(func=command_check_online)
+
parser_prepare_host = subparsers.add_parser(
'prepare-host', help='prepare a host for cephadm use')
parser_prepare_host.set_defaults(func=command_prepare_host)
if ctx.func not in \
[
command_check_host,
+ command_check_online,
command_prepare_host,
command_add_repo,
command_rm_repo,
import multiprocessing as mp
import threading
-from . import ssh
+from .serve import CephadmServe
+from .utils import cephadmNoImage
if TYPE_CHECKING:
from cephadm.module import CephadmOrchestrator
def check_host(self, host: str) -> None:
if host not in self.mgr.offline_hosts:
try:
- rcmd = ssh.RemoteCommand(ssh.Executables.TRUE)
- self.mgr.ssh.check_execute_command(host, rcmd, log_command=self.mgr.log_refresh_metadata)
+ with self.mgr.async_timeout_handler(host, 'cephadm check-online'):
+ self.mgr.wait_async(CephadmServe(self.mgr)._run_cephadm(
+ host, cephadmNoImage, 'check-online', [],
+ no_fsid=True, log_output=self.mgr.log_refresh_metadata))
except Exception:
logger.debug(f'OfflineHostDetector: detected {host} to be offline')
# kick serve loop in case corrective action must be taken for offline host
from cephadm import CephadmOrchestrator
from cephadm.serve import CephadmServe
from cephadm.tests.fixtures import with_host, wait, async_side_effect
+from cephadm.utils import cephadmNoImage
from orchestrator import OrchestratorError
'-rf',
'/tmp/blat',
]
+
+
+@mock.patch("cephadm.offline_watcher.CephadmServe._run_cephadm")
+def test_offline_watcher_uses_cephadm_check_online(run_cephadm, cephadm_module):
+ run_cephadm.side_effect = async_side_effect(([''], [''], 0))
+
+ with with_host(cephadm_module, 'test'):
+ run_cephadm.reset_mock()
+ cephadm_module.offline_watcher.check_host('test')
+
+ run_cephadm.assert_called_once_with(
+ 'test', cephadmNoImage, 'check-online', [],
+ no_fsid=True, log_output=cephadm_module.log_refresh_metadata
+ )