LOG_DIR_MODE,
SYSCTL_DIR,
UNIT_DIR,
+ DAEMON_FAILED_ERROR,
)
from cephadmlib.context import CephadmContext
from cephadmlib.context_getters import (
ClusterAlreadyExists,
Error,
UnauthorizedRegistryError,
+ DaemonStartException,
)
from cephadmlib.exe_utils import find_executable, find_program
from cephadmlib.call_wrappers import (
call_throws(ctx, ['systemctl', 'enable', unit_name])
if start:
clean_cgroup(ctx, ident.fsid, unit_name)
- call_throws(ctx, ['systemctl', 'start', unit_name])
+ try:
+ call_throws(ctx, ['systemctl', 'start', unit_name])
+ except Exception as e:
+ logger.error(f'systemctl start failed for {unit_name}: {str(e)}')
+ raise DaemonStartException()
def _osd_unit_run_commands(
@deprecated_command
def command_deploy(ctx):
# type: (CephadmContext) -> None
- _common_deploy(ctx)
+ try:
+ _common_deploy(ctx)
+ except DaemonStartException:
+ sys.exit(DAEMON_FAILED_ERROR)
def apply_deploy_config_to_ctx(
config_data = read_configuration_source(ctx)
logger.debug('Loaded deploy configuration: %r', config_data)
apply_deploy_config_to_ctx(config_data, ctx)
- _common_deploy(ctx)
+ try:
+ _common_deploy(ctx)
+ except DaemonStartException:
+ sys.exit(DAEMON_FAILED_ERROR)
def _common_deploy(ctx: CephadmContext) -> None:
NO_DEPRECATED = False
UID_NOBODY = 65534
GID_NOGROUP = 65534
+DAEMON_FAILED_ERROR = 17
class PortOccupiedError(Error):
pass
+
+
+class DaemonStartException(Exception):
+ """
+ Special exception type we raise when the
+ systemctl start command fails during daemon
+ deployment. Necessary because the cephadm mgr module
+ needs to handle this case differently than a failure
+ earlier in the deploy process where no attempt was made
+ to actually start the daemon
+ """
+
+ pass
config_blobs=daemon_spec.final_config,
).dump_json_str(),
use_current_daemon_image=reconfig,
+ error_ok=True
)
+ # return number corresponding to DAEMON_FAILED_ERROR
+ # in src/cephadm/cephadmlib/constants.
+ # TODO: link these together so one cannot be changed without the other
+ if code == 17:
+ # daemon failed on systemctl start command, meaning while
+ # deployment failed the daemon is present and we should handle
+ # this as if the deploy command "succeeded" and mark the daemon
+ # as failed later when we fetch its status
+ self.mgr.log.error(f'Deployment of {daemon_spec.name()} failed during "systemctl start" command')
+ elif code:
+ # some other failure earlier in the deploy process. Just raise an exception
+ # the same as we would in _run_cephadm on a nonzero rc
+ raise OrchestratorError(
+ f'cephadm exited with an error code: {code}, stderr: {err}')
+
if daemon_spec.daemon_type == 'agent':
self.mgr.agent_cache.agent_timestamp[daemon_spec.host] = datetime_now()
self.mgr.agent_cache.agent_counter[daemon_spec.host] = 1
mock.call(host, 'osd', 'ceph-volume',
['--', 'lvm', 'list', '--format', 'json'],
no_fsid=False, error_ok=False, image='', log_output=True, use_current_daemon_image=False),
- mock.call(host, f'osd.{osd_id}', ['_orch', 'deploy'], [], stdin=mock.ANY, use_current_daemon_image=False),
+ mock.call(host, f'osd.{osd_id}', ['_orch', 'deploy'], [], stdin=mock.ANY, error_ok=True, use_current_daemon_image=False),
mock.call(host, 'osd', 'ceph-volume',
['--', 'raw', 'list', '--format', 'json'],
no_fsid=False, error_ok=False, image='', log_output=True, use_current_daemon_image=False),
},
},
}),
+ error_ok=True,
use_current_daemon_image=True,
)
"crush_location": "datacenter=a",
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"keyring": "[client.crash.test]\nkey = None\n",
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": {},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": {},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": {},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
}
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"use_url_prefix": False,
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"use_url_prefix": True,
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"use_url_prefix": False,
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"files": {
"ceph-exporter.crt": "mycert",
"ceph-exporter.key": "mykey"}}}),
+ error_ok=True,
use_current_daemon_image=False)
@patch("cephadm.serve.CephadmServe._run_cephadm")
},
"config_blobs": {}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
'web_config': '/etc/node-exporter/web.yml',
}
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"use_url_prefix": False
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"use_url_prefix": False
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"files": files,
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"files": files,
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
"files": files,
},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": {},
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": es_config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
with with_service(cephadm_module, collector_spec):
},
"config_blobs": collector_config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
"config_blobs": collector_config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
with with_service(cephadm_module, agent_spec):
},
"config_blobs": agent_config,
}),
+ error_ok=True,
use_current_daemon_image=False,
)
},
}
),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)
['_orch', 'deploy'],
[],
stdin=json.dumps(expected),
+ error_ok=True,
use_current_daemon_image=False,
)