Skip to content

Commit

Permalink
Revert "Merge PR ceph#39482 into master"
Browse files Browse the repository at this point in the history
This reverts commit 9200b1e, reversing
changes made to e42bbba.

For running tests to narrow down the root cause of:
https://tracker.ceph.com/issues/49237

Signed-off-by: Michael Fritch <mfritch@suse.com>
  • Loading branch information
liewegas committed Mar 1, 2021
1 parent 34dee80 commit a16e46e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
11 changes: 5 additions & 6 deletions doc/man/8/cephadm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Synopsis
| **cephadm**** [-h] [--image IMAGE] [--docker] [--data-dir DATA_DIR]
| [--log-dir LOG_DIR] [--logrotate-dir LOGROTATE_DIR]
| [--unit-dir UNIT_DIR] [--verbose] [--timeout TIMEOUT]
| [--retry RETRY]
| [--retry RETRY] [--no-container-init]
| {version,pull,inspect-image,ls,list-networks,adopt,rm-daemon,rm-cluster,run,shell,enter,ceph-volume,unit,logs,bootstrap,deploy,check-host,prepare-host,add-repo,rm-repo,install}
| ...
Expand All @@ -28,7 +28,6 @@ Synopsis
| **cephadm** **adopt** [-h] --name NAME --style STYLE [--cluster CLUSTER]
| [--legacy-dir LEGACY_DIR] [--config-json CONFIG_JSON]
| [--skip-firewalld] [--skip-pull]
| [--container-init]
| **cephadm** **rm-daemon** [-h] --name NAME --fsid FSID [--force]
| [--force-delete-data]
Expand Down Expand Up @@ -78,15 +77,13 @@ Synopsis
| [--registry-username REGISTRY_USERNAME]
| [--registry-password REGISTRY_PASSWORD]
| [--registry-json REGISTRY_JSON]
| [--container-init]


| **cephadm** **deploy** [-h] --name NAME --fsid FSID [--config CONFIG]
| [--config-json CONFIG_JSON] [--keyring KEYRING]
| [--key KEY] [--osd-fsid OSD_FSID] [--skip-firewalld]
| [--tcp-ports TCP_PORTS] [--reconfig] [--allow-ptrace]
| [--container-init]
| **cephadm** **check-host** [-h] [--expect-hostname EXPECT_HOSTNAME]
Expand Down Expand Up @@ -157,6 +154,10 @@ Options

max number of retries (default: 10)

.. option:: --no-container-init

do not run podman/docker with `--init` (default: False)


Commands
========
Expand Down Expand Up @@ -238,7 +239,6 @@ Arguments:
* [--registry-username REGISTRY_USERNAME] username of account to login to on custom registry
* [--registry-password REGISTRY_PASSWORD] password of account to login to on custom registry
* [--registry-json REGISTRY_JSON] JSON file containing registry login info (see registry-login command documentation)
* [--container-init] Run podman/docker with `--init`


ceph-volume
Expand Down Expand Up @@ -289,7 +289,6 @@ Arguments:
* [--tcp-ports List of tcp ports to open in the host firewall
* [--reconfig] Reconfigure a previously deployed daemon
* [--allow-ptrace] Allow SYS_PTRACE on daemon container
* [--container-init] Run podman/docker with `--init`


enter
Expand Down
40 changes: 31 additions & 9 deletions src/cephadm/cephadm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LOGROTATE_DIR = '/etc/logrotate.d'
UNIT_DIR = '/etc/systemd/system'
LOG_DIR_MODE = 0o770
DATA_DIR_MODE = 0o700
CONTAINER_INIT=True
CONTAINER_PREFERENCE = ['podman', 'docker'] # prefer podman to docker
MIN_PODMAN_VERSION = (2, 0, 2)
CUSTOM_PS1 = r'[ceph: \u@\h \W]\$ '
Expand Down Expand Up @@ -116,6 +117,7 @@ class BaseConfig:
self.memory_request: Optional[int] = None
self.memory_limit: Optional[int] = None

self.container_init: bool = CONTAINER_INIT
self.container_path: str = ""

def set_from_args(self, args: argparse.Namespace):
Expand Down Expand Up @@ -2419,7 +2421,6 @@ def get_container(ctx: CephadmContext,
envs=envs,
privileged=privileged,
ptrace=ptrace,
init=ctx.container_init,
host_network=host_network,
)

Expand Down Expand Up @@ -2967,7 +2968,7 @@ class CephContainer:
privileged: bool = False,
ptrace: bool = False,
bind_mounts: Optional[List[List[str]]] = None,
init: bool = False,
init: Optional[bool] = None,
host_network: bool = True,
memory_request: Optional[str] = None,
memory_limit: Optional[str] = None,
Expand All @@ -2983,7 +2984,7 @@ class CephContainer:
self.privileged = privileged
self.ptrace = ptrace
self.bind_mounts = bind_mounts if bind_mounts else []
self.init = init
self.init = init if init else ctx.container_init
self.host_network = host_network
self.memory_request = memory_request
self.memory_limit = memory_limit
Expand Down Expand Up @@ -3067,6 +3068,8 @@ class CephContainer:
# let OSD etc read block devs that haven't been chowned
'--group-add=disk',
])
if self.init:
cmd_args.append('--init')
if self.envs:
for env in self.envs:
envs.extend(['-e', env])
Expand Down Expand Up @@ -3909,8 +3912,7 @@ def command_bootstrap(ctx):
cli(['config', 'set', 'mgr', 'mgr/cephadm/registry_username', ctx.registry_username, '--force'])
cli(['config', 'set', 'mgr', 'mgr/cephadm/registry_password', ctx.registry_password, '--force'])

if ctx.container_init:
cli(['config', 'set', 'mgr', 'mgr/cephadm/container_init', str(ctx.container_init), '--force'])
cli(['config', 'set', 'mgr', 'mgr/cephadm/container_init', str(ctx.container_init), '--force'])

if ctx.with_exporter:
cli(['config-key', 'set', 'mgr/cephadm/exporter_enabled', 'true'])
Expand All @@ -3933,7 +3935,6 @@ def command_bootstrap(ctx):
logger.info('Deploying cephadm exporter service with default placement...')
cli(['orch', 'apply', 'cephadm-exporter'])


if not ctx.skip_dashboard:
prepare_dashboard(ctx, uid, gid, cli, wait_for_mgr_restart)

Expand Down Expand Up @@ -7183,6 +7184,11 @@ def _get_parser():
action='append',
default=[],
help='set environment variable')
parser.add_argument(
'--no-container-init',
action='store_true',
default=not CONTAINER_INIT,
help='Do not run podman/docker with `--init`')

subparsers = parser.add_subparsers(help='sub-command')

Expand Down Expand Up @@ -7251,7 +7257,8 @@ def _get_parser():
parser_adopt.add_argument(
'--container-init',
action='store_true',
help='Run podman/docker with `--init`')
default=CONTAINER_INIT,
help=argparse.SUPPRESS)

parser_rm_daemon = subparsers.add_parser(
'rm-daemon', help='remove daemon instance')
Expand Down Expand Up @@ -7545,7 +7552,8 @@ def _get_parser():
parser_bootstrap.add_argument(
'--container-init',
action='store_true',
help='Run podman/docker with `--init`')
default=CONTAINER_INIT,
help=argparse.SUPPRESS)
parser_bootstrap.add_argument(
'--with-exporter',
action='store_true',
Expand Down Expand Up @@ -7603,7 +7611,8 @@ def _get_parser():
parser_deploy.add_argument(
'--container-init',
action='store_true',
help='Run podman/docker with `--init`')
default=CONTAINER_INIT,
help=argparse.SUPPRESS)
parser_deploy.add_argument(
'--memory-request',
help='Container memory request/target'
Expand Down Expand Up @@ -7735,9 +7744,22 @@ def _get_parser():

def _parse_args(av):
parser = _get_parser()

args = parser.parse_args(av)
if 'command' in args and args.command and args.command[0] == "--":
args.command.pop(0)

# workaround argparse to deprecate the subparser `--container-init` flag
# container_init and no_container_init must always be mutually exclusive
container_init_args = ('--container-init', '--no-container-init')
if set(container_init_args).issubset(av):
parser.error('argument %s: not allowed with argument %s' % (container_init_args))
elif '--container-init' in av:
args.no_container_init = not args.container_init
else:
args.container_init = not args.no_container_init
assert args.container_init is not args.no_container_init

return args


Expand Down
4 changes: 2 additions & 2 deletions src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
Option(
'container_init',
type='bool',
default=False,
default=True,
desc='Run podman/docker with `--init`'
),
Option(
Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__(self, *args: Any, **kwargs: Any):
self.warn_on_stray_daemons = True
self.warn_on_failed_host_check = True
self.allow_ptrace = False
self.container_init = False
self.container_init = True
self.prometheus_alerts_path = ''
self.migration_current: Optional[int] = None
self.config_dashboard = True
Expand Down
11 changes: 8 additions & 3 deletions src/pybind/mgr/cephadm/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,22 +961,27 @@ def _run_cephadm(self,

final_args = []

# global args
if env_vars:
for env_var_pair in env_vars:
final_args.extend(['--env', env_var_pair])

if image:
final_args.extend(['--image', image])

if not self.mgr.container_init:
final_args += ['--no-container-init']

# subcommand
final_args.append(command)

# subcommand args
if not no_fsid:
final_args += ['--fsid', self.mgr._cluster_fsid]

if self.mgr.container_init:
final_args += ['--container-init']

final_args += args

# exec
self.log.debug('args: %s' % (' '.join(final_args)))
if self.mgr.mode == 'root':
if stdin:
Expand Down

0 comments on commit a16e46e

Please sign in to comment.