|
|
8637a1 |
diff --git a/SOURCES/cephadm b/SOURCES/cephadm
|
|
|
8637a1 |
index 524c038..a7b664c 100644
|
|
|
8637a1 |
--- a/SOURCES/cephadm
|
|
|
8637a1 |
+++ b/SOURCES/cephadm
|
|
|
8637a1 |
@@ -61,6 +61,7 @@ DATA_DIR = '/var/lib/ceph'
|
|
|
8637a1 |
LOG_DIR = '/var/log/ceph'
|
|
|
8637a1 |
LOCK_DIR = '/run/cephadm'
|
|
|
8637a1 |
LOGROTATE_DIR = '/etc/logrotate.d'
|
|
|
8637a1 |
+SYSCTL_DIR = '/usr/lib/sysctl.d'
|
|
|
8637a1 |
UNIT_DIR = '/etc/systemd/system'
|
|
|
8637a1 |
LOG_DIR_MODE = 0o770
|
|
|
8637a1 |
DATA_DIR_MODE = 0o700
|
|
|
8637a1 |
@@ -109,6 +110,7 @@ class BaseConfig:
|
|
|
8637a1 |
self.data_dir: str = DATA_DIR
|
|
|
8637a1 |
self.log_dir: str = LOG_DIR
|
|
|
8637a1 |
self.logrotate_dir: str = LOGROTATE_DIR
|
|
|
8637a1 |
+ self.sysctl_dir: str = SYSCTL_DIR
|
|
|
8637a1 |
self.unit_dir: str = UNIT_DIR
|
|
|
8637a1 |
self.verbose: bool = False
|
|
|
8637a1 |
self.timeout: Optional[int] = DEFAULT_TIMEOUT
|
|
|
8637a1 |
@@ -210,11 +212,9 @@ logging_config = {
|
|
|
8637a1 |
},
|
|
|
8637a1 |
'log_file': {
|
|
|
8637a1 |
'level': 'DEBUG',
|
|
|
8637a1 |
- 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
8637a1 |
+ 'class': 'logging.handlers.WatchedFileHandler',
|
|
|
8637a1 |
'formatter': 'cephadm',
|
|
|
8637a1 |
'filename': '%s/cephadm.log' % LOG_DIR,
|
|
|
8637a1 |
- 'maxBytes': 1024000,
|
|
|
8637a1 |
- 'backupCount': 1,
|
|
|
8637a1 |
}
|
|
|
8637a1 |
},
|
|
|
8637a1 |
'loggers': {
|
|
|
8637a1 |
@@ -249,6 +249,18 @@ class Ceph(object):
|
|
|
8637a1 |
##################################
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
+class OSD(object):
|
|
|
8637a1 |
+ @staticmethod
|
|
|
8637a1 |
+ def get_sysctl_settings() -> List[str]:
|
|
|
8637a1 |
+ return [
|
|
|
8637a1 |
+ '# allow a large number of OSDs',
|
|
|
8637a1 |
+ 'fs.aio-max-nr = 1048576',
|
|
|
8637a1 |
+ 'kernel.pid_max = 4194304',
|
|
|
8637a1 |
+ ]
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+##################################
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+
|
|
|
8637a1 |
class Monitoring(object):
|
|
|
8637a1 |
"""Define the configs for the monitoring containers"""
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -349,7 +361,7 @@ def populate_files(config_dir, config_files, uid, gid):
|
|
|
8637a1 |
config_file = os.path.join(config_dir, fname)
|
|
|
8637a1 |
config_content = dict_get_join(config_files, fname)
|
|
|
8637a1 |
logger.info('Write file: %s' % (config_file))
|
|
|
8637a1 |
- with open(config_file, 'w') as f:
|
|
|
8637a1 |
+ with open(config_file, 'w', encoding='utf-8') as f:
|
|
|
8637a1 |
os.fchown(f.fileno(), uid, gid)
|
|
|
8637a1 |
os.fchmod(f.fileno(), 0o600)
|
|
|
8637a1 |
f.write(config_content)
|
|
|
8637a1 |
@@ -491,36 +503,6 @@ class NFSGanesha(object):
|
|
|
8637a1 |
os.fchown(f.fileno(), uid, gid)
|
|
|
8637a1 |
f.write(self.rgw.get('keyring', ''))
|
|
|
8637a1 |
|
|
|
8637a1 |
- def get_rados_grace_container(self, action):
|
|
|
8637a1 |
- # type: (str) -> CephContainer
|
|
|
8637a1 |
- """Container for a ganesha action on the grace db"""
|
|
|
8637a1 |
- entrypoint = '/usr/bin/ganesha-rados-grace'
|
|
|
8637a1 |
-
|
|
|
8637a1 |
- assert self.pool
|
|
|
8637a1 |
- args = ['--pool', self.pool]
|
|
|
8637a1 |
- if self.namespace:
|
|
|
8637a1 |
- args += ['--ns', self.namespace]
|
|
|
8637a1 |
- if self.userid:
|
|
|
8637a1 |
- args += ['--userid', self.userid]
|
|
|
8637a1 |
- args += [action, self.get_daemon_name()]
|
|
|
8637a1 |
-
|
|
|
8637a1 |
- data_dir = get_data_dir(self.fsid, self.ctx.data_dir,
|
|
|
8637a1 |
- self.daemon_type, self.daemon_id)
|
|
|
8637a1 |
- volume_mounts = self.get_container_mounts(data_dir)
|
|
|
8637a1 |
- envs = self.get_container_envs()
|
|
|
8637a1 |
-
|
|
|
8637a1 |
- logger.info('Creating RADOS grace for action: %s' % action)
|
|
|
8637a1 |
- c = CephContainer(
|
|
|
8637a1 |
- self.ctx,
|
|
|
8637a1 |
- image=self.image,
|
|
|
8637a1 |
- entrypoint=entrypoint,
|
|
|
8637a1 |
- args=args,
|
|
|
8637a1 |
- volume_mounts=volume_mounts,
|
|
|
8637a1 |
- cname=self.get_container_name(desc='grace-%s' % action),
|
|
|
8637a1 |
- envs=envs
|
|
|
8637a1 |
- )
|
|
|
8637a1 |
- return c
|
|
|
8637a1 |
-
|
|
|
8637a1 |
##################################
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -732,6 +714,13 @@ class HAproxy(object):
|
|
|
8637a1 |
mounts[os.path.join(data_dir, 'haproxy')] = '/var/lib/haproxy'
|
|
|
8637a1 |
return mounts
|
|
|
8637a1 |
|
|
|
8637a1 |
+ @staticmethod
|
|
|
8637a1 |
+ def get_sysctl_settings() -> List[str]:
|
|
|
8637a1 |
+ return [
|
|
|
8637a1 |
+ '# IP forwarding',
|
|
|
8637a1 |
+ 'net.ipv4.ip_forward = 1',
|
|
|
8637a1 |
+ ]
|
|
|
8637a1 |
+
|
|
|
8637a1 |
##################################
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -811,12 +800,12 @@ class Keepalived(object):
|
|
|
8637a1 |
return envs
|
|
|
8637a1 |
|
|
|
8637a1 |
@staticmethod
|
|
|
8637a1 |
- def get_prestart():
|
|
|
8637a1 |
- return (
|
|
|
8637a1 |
- '# keepalived needs IP forwarding and non-local bind\n'
|
|
|
8637a1 |
- 'sysctl net.ipv4.ip_forward=1\n'
|
|
|
8637a1 |
- 'sysctl net.ipv4.ip_nonlocal_bind=1\n'
|
|
|
8637a1 |
- )
|
|
|
8637a1 |
+ def get_sysctl_settings() -> List[str]:
|
|
|
8637a1 |
+ return [
|
|
|
8637a1 |
+ '# IP forwarding and non-local bind',
|
|
|
8637a1 |
+ 'net.ipv4.ip_forward = 1',
|
|
|
8637a1 |
+ 'net.ipv4.ip_nonlocal_bind = 1',
|
|
|
8637a1 |
+ ]
|
|
|
8637a1 |
|
|
|
8637a1 |
def extract_uid_gid_keepalived(self):
|
|
|
8637a1 |
# better directory for this?
|
|
|
8637a1 |
@@ -1190,7 +1179,7 @@ class FileLock(object):
|
|
|
8637a1 |
lock_id, lock_filename, poll_intervall
|
|
|
8637a1 |
)
|
|
|
8637a1 |
time.sleep(poll_intervall)
|
|
|
8637a1 |
- except: # noqa
|
|
|
8637a1 |
+ except Exception:
|
|
|
8637a1 |
# Something did go wrong, so decrement the counter.
|
|
|
8637a1 |
self._lock_counter = max(0, self._lock_counter - 1)
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -2061,10 +2050,11 @@ def check_units(ctx, units, enabler=None):
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
def is_container_running(ctx: CephadmContext, name: str) -> bool:
|
|
|
8637a1 |
- out, err, ret = call_throws(ctx, [
|
|
|
8637a1 |
- ctx.container_engine.path, 'ps',
|
|
|
8637a1 |
- '--format', '{{.Names}}'])
|
|
|
8637a1 |
- return name in out
|
|
|
8637a1 |
+ out, err, ret = call(ctx, [
|
|
|
8637a1 |
+ ctx.container_engine.path, 'container', 'inspect',
|
|
|
8637a1 |
+ '--format', '{{.State.Status}}', name
|
|
|
8637a1 |
+ ])
|
|
|
8637a1 |
+ return out == 'running'
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
def get_legacy_config_fsid(cluster, legacy_dir=None):
|
|
|
8637a1 |
@@ -2163,7 +2153,6 @@ def create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid,
|
|
|
8637a1 |
|
|
|
8637a1 |
if daemon_type in Monitoring.components.keys():
|
|
|
8637a1 |
config_json: Dict[str, Any] = get_parm(ctx.config_json)
|
|
|
8637a1 |
- required_files = Monitoring.components[daemon_type].get('config-json-files', list())
|
|
|
8637a1 |
|
|
|
8637a1 |
# Set up directories specific to the monitoring component
|
|
|
8637a1 |
config_dir = ''
|
|
|
8637a1 |
@@ -2192,10 +2181,14 @@ def create_daemon_dirs(ctx, fsid, daemon_type, daemon_id, uid, gid,
|
|
|
8637a1 |
makedirs(os.path.join(data_dir_root, config_dir, 'data'), uid, gid, 0o755)
|
|
|
8637a1 |
|
|
|
8637a1 |
# populate the config directory for the component from the config-json
|
|
|
8637a1 |
- for fname in required_files:
|
|
|
8637a1 |
- if 'files' in config_json: # type: ignore
|
|
|
8637a1 |
+ if 'files' in config_json:
|
|
|
8637a1 |
+ for fname in config_json['files']:
|
|
|
8637a1 |
content = dict_get_join(config_json['files'], fname)
|
|
|
8637a1 |
- with open(os.path.join(data_dir_root, config_dir, fname), 'w') as f:
|
|
|
8637a1 |
+ if os.path.isabs(fname):
|
|
|
8637a1 |
+ fpath = os.path.join(data_dir_root, fname.lstrip(os.path.sep))
|
|
|
8637a1 |
+ else:
|
|
|
8637a1 |
+ fpath = os.path.join(data_dir_root, config_dir, fname)
|
|
|
8637a1 |
+ with open(fpath, 'w', encoding='utf-8') as f:
|
|
|
8637a1 |
os.fchown(f.fileno(), uid, gid)
|
|
|
8637a1 |
os.fchmod(f.fileno(), 0o600)
|
|
|
8637a1 |
f.write(content)
|
|
|
8637a1 |
@@ -2267,8 +2260,8 @@ def get_config_and_keyring(ctx):
|
|
|
8637a1 |
try:
|
|
|
8637a1 |
with open(ctx.config, 'r') as f:
|
|
|
8637a1 |
config = f.read()
|
|
|
8637a1 |
- except FileNotFoundError:
|
|
|
8637a1 |
- raise Error('config file: %s does not exist' % ctx.config)
|
|
|
8637a1 |
+ except FileNotFoundError as e:
|
|
|
8637a1 |
+ raise Error(e)
|
|
|
8637a1 |
|
|
|
8637a1 |
if 'key' in ctx and ctx.key:
|
|
|
8637a1 |
keyring = '[%s]\n\tkey = %s\n' % (ctx.name, ctx.key)
|
|
|
8637a1 |
@@ -2276,8 +2269,8 @@ def get_config_and_keyring(ctx):
|
|
|
8637a1 |
try:
|
|
|
8637a1 |
with open(ctx.keyring, 'r') as f:
|
|
|
8637a1 |
keyring = f.read()
|
|
|
8637a1 |
- except FileNotFoundError:
|
|
|
8637a1 |
- raise Error('keyring file: %s does not exist' % ctx.keyring)
|
|
|
8637a1 |
+ except FileNotFoundError as e:
|
|
|
8637a1 |
+ raise Error(e)
|
|
|
8637a1 |
|
|
|
8637a1 |
return config, keyring
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -2682,7 +2675,7 @@ def deploy_daemon_units(
|
|
|
8637a1 |
# cmd
|
|
|
8637a1 |
data_dir = get_data_dir(fsid, ctx.data_dir, daemon_type, daemon_id)
|
|
|
8637a1 |
with open(data_dir + '/unit.run.new', 'w') as f, \
|
|
|
8637a1 |
- open(data_dir + '/unit.meta.new', 'w') as metaf:
|
|
|
8637a1 |
+ open(data_dir + '/unit.meta.new', 'w') as metaf:
|
|
|
8637a1 |
f.write('set -e\n')
|
|
|
8637a1 |
|
|
|
8637a1 |
if daemon_type in Ceph.daemons:
|
|
|
8637a1 |
@@ -2718,18 +2711,11 @@ def deploy_daemon_units(
|
|
|
8637a1 |
memory_limit=ctx.memory_limit,
|
|
|
8637a1 |
)
|
|
|
8637a1 |
_write_container_cmd_to_bash(ctx, f, prestart, 'LVM OSDs use ceph-volume lvm activate')
|
|
|
8637a1 |
- elif daemon_type == NFSGanesha.daemon_type:
|
|
|
8637a1 |
- # add nfs to the rados grace db
|
|
|
8637a1 |
- nfs_ganesha = NFSGanesha.init(ctx, fsid, daemon_id)
|
|
|
8637a1 |
- prestart = nfs_ganesha.get_rados_grace_container('add')
|
|
|
8637a1 |
- _write_container_cmd_to_bash(ctx, f, prestart, 'add daemon to rados grace')
|
|
|
8637a1 |
elif daemon_type == CephIscsi.daemon_type:
|
|
|
8637a1 |
f.write(' '.join(CephIscsi.configfs_mount_umount(data_dir, mount=True)) + '\n')
|
|
|
8637a1 |
ceph_iscsi = CephIscsi.init(ctx, fsid, daemon_id)
|
|
|
8637a1 |
tcmu_container = ceph_iscsi.get_tcmu_runner_container()
|
|
|
8637a1 |
_write_container_cmd_to_bash(ctx, f, tcmu_container, 'iscsi tcmu-runnter container', background=True)
|
|
|
8637a1 |
- elif daemon_type == Keepalived.daemon_type:
|
|
|
8637a1 |
- f.write(Keepalived.get_prestart())
|
|
|
8637a1 |
|
|
|
8637a1 |
_write_container_cmd_to_bash(ctx, f, c, '%s.%s' % (daemon_type, str(daemon_id)))
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -2771,11 +2757,6 @@ def deploy_daemon_units(
|
|
|
8637a1 |
daemon_id),
|
|
|
8637a1 |
)
|
|
|
8637a1 |
_write_container_cmd_to_bash(ctx, f, poststop, 'deactivate osd')
|
|
|
8637a1 |
- elif daemon_type == NFSGanesha.daemon_type:
|
|
|
8637a1 |
- # remove nfs from the rados grace db
|
|
|
8637a1 |
- nfs_ganesha = NFSGanesha.init(ctx, fsid, daemon_id)
|
|
|
8637a1 |
- poststop = nfs_ganesha.get_rados_grace_container('remove')
|
|
|
8637a1 |
- _write_container_cmd_to_bash(ctx, f, poststop, 'remove daemon from rados grace')
|
|
|
8637a1 |
elif daemon_type == CephIscsi.daemon_type:
|
|
|
8637a1 |
# make sure we also stop the tcmu container
|
|
|
8637a1 |
ceph_iscsi = CephIscsi.init(ctx, fsid, daemon_id)
|
|
|
8637a1 |
@@ -2793,6 +2774,9 @@ def deploy_daemon_units(
|
|
|
8637a1 |
os.rename(data_dir + '/unit.image.new',
|
|
|
8637a1 |
data_dir + '/unit.image')
|
|
|
8637a1 |
|
|
|
8637a1 |
+ # sysctl
|
|
|
8637a1 |
+ install_sysctl(ctx, fsid, daemon_type)
|
|
|
8637a1 |
+
|
|
|
8637a1 |
# systemd
|
|
|
8637a1 |
install_base_units(ctx, fsid)
|
|
|
8637a1 |
unit = get_unit_file(ctx, fsid)
|
|
|
8637a1 |
@@ -2935,6 +2919,36 @@ def update_firewalld(ctx, daemon_type):
|
|
|
8637a1 |
firewall.apply_rules()
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
+def install_sysctl(ctx: CephadmContext, fsid: str, daemon_type: str) -> None:
|
|
|
8637a1 |
+ """
|
|
|
8637a1 |
+ Set up sysctl settings
|
|
|
8637a1 |
+ """
|
|
|
8637a1 |
+ def _write(conf: Path, lines: List[str]) -> None:
|
|
|
8637a1 |
+ lines = [
|
|
|
8637a1 |
+ '# created by cephadm',
|
|
|
8637a1 |
+ '',
|
|
|
8637a1 |
+ *lines,
|
|
|
8637a1 |
+ '',
|
|
|
8637a1 |
+ ]
|
|
|
8637a1 |
+ with open(conf, 'w') as f:
|
|
|
8637a1 |
+ f.write('\n'.join(lines))
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+ conf = Path(ctx.sysctl_dir).joinpath(f'90-ceph-{fsid}-{daemon_type}.conf')
|
|
|
8637a1 |
+ lines: Optional[List] = None
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+ if daemon_type == 'osd':
|
|
|
8637a1 |
+ lines = OSD.get_sysctl_settings()
|
|
|
8637a1 |
+ elif daemon_type == 'haproxy':
|
|
|
8637a1 |
+ lines = HAproxy.get_sysctl_settings()
|
|
|
8637a1 |
+ elif daemon_type == 'keepalived':
|
|
|
8637a1 |
+ lines = Keepalived.get_sysctl_settings()
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+ # apply the sysctl settings
|
|
|
8637a1 |
+ if lines:
|
|
|
8637a1 |
+ _write(conf, lines)
|
|
|
8637a1 |
+ call_throws(ctx, ['sysctl', '--system'])
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+
|
|
|
8637a1 |
def install_base_units(ctx, fsid):
|
|
|
8637a1 |
# type: (CephadmContext, str) -> None
|
|
|
8637a1 |
"""
|
|
|
8637a1 |
@@ -3102,13 +3116,13 @@ class CephContainer:
|
|
|
8637a1 |
'run',
|
|
|
8637a1 |
'--rm',
|
|
|
8637a1 |
'--ipc=host',
|
|
|
8637a1 |
+ # some containers (ahem, haproxy) override this, but we want a fast
|
|
|
8637a1 |
+ # shutdown always (and, more importantly, a successful exit even if we
|
|
|
8637a1 |
+ # fall back to SIGKILL).
|
|
|
8637a1 |
+ '--stop-signal=SIGTERM',
|
|
|
8637a1 |
]
|
|
|
8637a1 |
|
|
|
8637a1 |
if isinstance(self.ctx.container_engine, Podman):
|
|
|
8637a1 |
- # podman adds the container *name* to /etc/hosts (for 127.0.1.1)
|
|
|
8637a1 |
- # by default, which makes python's socket.getfqdn() return that
|
|
|
8637a1 |
- # instead of a valid hostname.
|
|
|
8637a1 |
- cmd_args.append('--no-hosts')
|
|
|
8637a1 |
if os.path.exists('/etc/ceph/podman-auth.json'):
|
|
|
8637a1 |
cmd_args.append('--authfile=/etc/ceph/podman-auth.json')
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -3966,11 +3980,7 @@ def command_bootstrap(ctx):
|
|
|
8637a1 |
except PermissionError:
|
|
|
8637a1 |
raise Error(f'Unable to create {dirname} due to permissions failure. Retry with root, or sudo or preallocate the directory.')
|
|
|
8637a1 |
|
|
|
8637a1 |
- if ctx.config and os.path.exists(ctx.config):
|
|
|
8637a1 |
- with open(ctx.config) as f:
|
|
|
8637a1 |
- user_conf = f.read()
|
|
|
8637a1 |
- else:
|
|
|
8637a1 |
- user_conf = None
|
|
|
8637a1 |
+ (user_conf, _) = get_config_and_keyring(ctx)
|
|
|
8637a1 |
|
|
|
8637a1 |
if not ctx.skip_prepare_host:
|
|
|
8637a1 |
command_prepare_host(ctx)
|
|
|
8637a1 |
@@ -4072,7 +4082,7 @@ def command_bootstrap(ctx):
|
|
|
8637a1 |
# the mgr (e.g. mgr/cephadm/container_image_prometheus)
|
|
|
8637a1 |
# they don't seem to be stored if there isn't a mgr yet.
|
|
|
8637a1 |
# Since re-assimilating the same conf settings should be
|
|
|
8637a1 |
- # idempotent we can just do it aain here.
|
|
|
8637a1 |
+ # idempotent we can just do it again here.
|
|
|
8637a1 |
with tempfile.NamedTemporaryFile(buffering=0) as tmp:
|
|
|
8637a1 |
tmp.write(user_conf.encode('utf-8'))
|
|
|
8637a1 |
cli(['config', 'assimilate-conf',
|
|
|
8637a1 |
@@ -4329,8 +4339,8 @@ def command_deploy(ctx):
|
|
|
8637a1 |
ports=daemon_ports)
|
|
|
8637a1 |
|
|
|
8637a1 |
elif daemon_type == NFSGanesha.daemon_type:
|
|
|
8637a1 |
- if not ctx.reconfig and not redeploy:
|
|
|
8637a1 |
- daemon_ports.extend(NFSGanesha.port_map.values())
|
|
|
8637a1 |
+ if not ctx.reconfig and not redeploy and not daemon_ports:
|
|
|
8637a1 |
+ daemon_ports = list(NFSGanesha.port_map.values())
|
|
|
8637a1 |
|
|
|
8637a1 |
config, keyring = get_config_and_keyring(ctx)
|
|
|
8637a1 |
# TODO: extract ganesha uid/gid (997, 994) ?
|
|
|
8637a1 |
@@ -4489,6 +4499,10 @@ def command_shell(ctx):
|
|
|
8637a1 |
os.path.join(home, f))
|
|
|
8637a1 |
mounts[home] = '/root'
|
|
|
8637a1 |
|
|
|
8637a1 |
+ for i in ctx.volume:
|
|
|
8637a1 |
+ a, b = i.split(':', 1)
|
|
|
8637a1 |
+ mounts[a] = b
|
|
|
8637a1 |
+
|
|
|
8637a1 |
c = CephContainer(
|
|
|
8637a1 |
ctx,
|
|
|
8637a1 |
image=ctx.image,
|
|
|
8637a1 |
@@ -5507,10 +5521,10 @@ def command_rm_cluster(ctx):
|
|
|
8637a1 |
_zap_osds(ctx)
|
|
|
8637a1 |
|
|
|
8637a1 |
# rm units
|
|
|
8637a1 |
- call_throws(ctx, ['rm', '-f', ctx.unit_dir + # noqa: W504
|
|
|
8637a1 |
- '/ceph-%s@.service' % ctx.fsid])
|
|
|
8637a1 |
- call_throws(ctx, ['rm', '-f', ctx.unit_dir + # noqa: W504
|
|
|
8637a1 |
- '/ceph-%s.target' % ctx.fsid])
|
|
|
8637a1 |
+ call_throws(ctx, ['rm', '-f', ctx.unit_dir
|
|
|
8637a1 |
+ + '/ceph-%s@.service' % ctx.fsid])
|
|
|
8637a1 |
+ call_throws(ctx, ['rm', '-f', ctx.unit_dir
|
|
|
8637a1 |
+ + '/ceph-%s.target' % ctx.fsid])
|
|
|
8637a1 |
call_throws(ctx, ['rm', '-rf',
|
|
|
8637a1 |
ctx.unit_dir + '/ceph-%s.target.wants' % ctx.fsid])
|
|
|
8637a1 |
# rm data
|
|
|
8637a1 |
@@ -5519,12 +5533,21 @@ def command_rm_cluster(ctx):
|
|
|
8637a1 |
if not ctx.keep_logs:
|
|
|
8637a1 |
# rm logs
|
|
|
8637a1 |
call_throws(ctx, ['rm', '-rf', ctx.log_dir + '/' + ctx.fsid])
|
|
|
8637a1 |
- call_throws(ctx, ['rm', '-rf', ctx.log_dir + # noqa: W504
|
|
|
8637a1 |
- '/*.wants/ceph-%s@*' % ctx.fsid])
|
|
|
8637a1 |
+ call_throws(ctx, ['rm', '-rf', ctx.log_dir
|
|
|
8637a1 |
+ + '/*.wants/ceph-%s@*' % ctx.fsid])
|
|
|
8637a1 |
|
|
|
8637a1 |
# rm logrotate config
|
|
|
8637a1 |
call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/ceph-%s' % ctx.fsid])
|
|
|
8637a1 |
|
|
|
8637a1 |
+ # rm cephadm logrotate config if last cluster on host
|
|
|
8637a1 |
+ if not os.listdir(ctx.data_dir):
|
|
|
8637a1 |
+ call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/cephadm'])
|
|
|
8637a1 |
+
|
|
|
8637a1 |
+ # rm sysctl settings
|
|
|
8637a1 |
+ sysctl_dir = Path(ctx.sysctl_dir)
|
|
|
8637a1 |
+ for p in sysctl_dir.glob(f'90-ceph-{ctx.fsid}-*.conf'):
|
|
|
8637a1 |
+ p.unlink()
|
|
|
8637a1 |
+
|
|
|
8637a1 |
# clean up config, keyring, and pub key files
|
|
|
8637a1 |
files = ['/etc/ceph/ceph.conf', '/etc/ceph/ceph.pub', '/etc/ceph/ceph.client.admin.keyring']
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -6712,16 +6735,6 @@ def command_gather_facts(ctx: CephadmContext):
|
|
|
8637a1 |
host = HostFacts(ctx)
|
|
|
8637a1 |
print(host.dump())
|
|
|
8637a1 |
|
|
|
8637a1 |
-##################################
|
|
|
8637a1 |
-
|
|
|
8637a1 |
-
|
|
|
8637a1 |
-def command_verify_prereqs(ctx: CephadmContext):
|
|
|
8637a1 |
- if ctx.service_type == 'haproxy' or ctx.service_type == 'keepalived':
|
|
|
8637a1 |
- out, err, code = call(
|
|
|
8637a1 |
- ctx, ['sysctl', '-n', 'net.ipv4.ip_nonlocal_bind']
|
|
|
8637a1 |
- )
|
|
|
8637a1 |
- if out.strip() != '1':
|
|
|
8637a1 |
- raise Error('net.ipv4.ip_nonlocal_bind not set to 1')
|
|
|
8637a1 |
|
|
|
8637a1 |
##################################
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -6803,12 +6816,14 @@ class CephadmDaemonHandler(BaseHTTPRequestHandler):
|
|
|
8637a1 |
The token is installed at deployment time and must be provided to
|
|
|
8637a1 |
ensure we only respond to callers who know our token i.e. mgr
|
|
|
8637a1 |
"""
|
|
|
8637a1 |
+
|
|
|
8637a1 |
def wrapper(self, *args, **kwargs):
|
|
|
8637a1 |
auth = self.headers.get('Authorization', None)
|
|
|
8637a1 |
if auth != 'Bearer ' + self.server.token:
|
|
|
8637a1 |
self.send_error(401)
|
|
|
8637a1 |
return
|
|
|
8637a1 |
f(self, *args, **kwargs)
|
|
|
8637a1 |
+
|
|
|
8637a1 |
return wrapper
|
|
|
8637a1 |
|
|
|
8637a1 |
def _help_page(self):
|
|
|
8637a1 |
@@ -7483,6 +7498,10 @@ def _get_parser():
|
|
|
8637a1 |
'--logrotate-dir',
|
|
|
8637a1 |
default=LOGROTATE_DIR,
|
|
|
8637a1 |
help='location of logrotate configuration files')
|
|
|
8637a1 |
+ parser.add_argument(
|
|
|
8637a1 |
+ '--sysctl-dir',
|
|
|
8637a1 |
+ default=SYSCTL_DIR,
|
|
|
8637a1 |
+ help='location of sysctl configuration files')
|
|
|
8637a1 |
parser.add_argument(
|
|
|
8637a1 |
'--unit-dir',
|
|
|
8637a1 |
default=UNIT_DIR,
|
|
|
8637a1 |
@@ -7662,6 +7681,11 @@ def _get_parser():
|
|
|
8637a1 |
action='append',
|
|
|
8637a1 |
default=[],
|
|
|
8637a1 |
help='set environment variable')
|
|
|
8637a1 |
+ parser_shell.add_argument(
|
|
|
8637a1 |
+ '--volume', '-v',
|
|
|
8637a1 |
+ action='append',
|
|
|
8637a1 |
+ default=[],
|
|
|
8637a1 |
+ help='set environment variable')
|
|
|
8637a1 |
parser_shell.add_argument(
|
|
|
8637a1 |
'command', nargs=argparse.REMAINDER,
|
|
|
8637a1 |
help='command (optional)')
|
|
|
8637a1 |
@@ -8083,15 +8107,6 @@ def _get_parser():
|
|
|
8637a1 |
help='Maintenance action - enter maintenance, or exit maintenance')
|
|
|
8637a1 |
parser_maintenance.set_defaults(func=command_maintenance)
|
|
|
8637a1 |
|
|
|
8637a1 |
- parser_verify_prereqs = subparsers.add_parser(
|
|
|
8637a1 |
- 'verify-prereqs',
|
|
|
8637a1 |
- help='verify system prerequisites for a given service are met on this host')
|
|
|
8637a1 |
- parser_verify_prereqs.set_defaults(func=command_verify_prereqs)
|
|
|
8637a1 |
- parser_verify_prereqs.add_argument(
|
|
|
8637a1 |
- '--daemon-type',
|
|
|
8637a1 |
- required=True,
|
|
|
8637a1 |
- help='service type of service to whose prereqs will be checked')
|
|
|
8637a1 |
-
|
|
|
8637a1 |
return parser
|
|
|
8637a1 |
|
|
|
8637a1 |
|
|
|
8637a1 |
@@ -8135,6 +8150,18 @@ def cephadm_init(args: List[str]) -> Optional[CephadmContext]:
|
|
|
8637a1 |
dictConfig(logging_config)
|
|
|
8637a1 |
logger = logging.getLogger()
|
|
|
8637a1 |
|
|
|
8637a1 |
+ if not os.path.exists(ctx.logrotate_dir + '/cephadm'):
|
|
|
8637a1 |
+ with open(ctx.logrotate_dir + '/cephadm', 'w') as f:
|
|
|
8637a1 |
+ f.write("""# created by cephadm
|
|
|
8637a1 |
+/var/log/ceph/cephadm.log {
|
|
|
8637a1 |
+ rotate 7
|
|
|
8637a1 |
+ daily
|
|
|
8637a1 |
+ compress
|
|
|
8637a1 |
+ missingok
|
|
|
8637a1 |
+ notifempty
|
|
|
8637a1 |
+}
|
|
|
8637a1 |
+""")
|
|
|
8637a1 |
+
|
|
|
8637a1 |
if ctx.verbose:
|
|
|
8637a1 |
for handler in logger.handlers:
|
|
|
8637a1 |
if handler.name == 'console':
|