diff options
author | John Mulligan <jmulligan@redhat.com> | 2023-12-05 22:20:57 +0100 |
---|---|---|
committer | John Mulligan <jmulligan@redhat.com> | 2024-01-02 15:30:21 +0100 |
commit | 57540a28c5c83140c2429f1e94fbaeee06d80f64 (patch) | |
tree | 479d07780478d08a70910d3a511fe126db6be8ef /src/cephadm/cephadmlib/runscripts.py | |
parent | cephadm: call functions instead of executing rm in rm_cluster (diff) | |
download | ceph-57540a28c5c83140c2429f1e94fbaeee06d80f64.tar.xz ceph-57540a28c5c83140c2429f1e94fbaeee06d80f64.zip |
cephadm: move init container script generation to a function
Move the generation of the init container run script to a small function
fixing a missing `set -e` along the way. This isolates the logic of
generating this run script.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | src/cephadm/cephadmlib/runscripts.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cephadm/cephadmlib/runscripts.py b/src/cephadm/cephadmlib/runscripts.py index bfa73edbd7d..52694b16b9c 100644 --- a/src/cephadm/cephadmlib/runscripts.py +++ b/src/cephadm/cephadmlib/runscripts.py @@ -91,10 +91,7 @@ def write_service_scripts( # init-container commands if init_containers: initf = estack.enter_context(write_new(initctr_file_path)) - _write_init_container_cmds_clean(ctx, initf, init_containers[0]) - for idx, ic in enumerate(init_containers): - _write_init_container_cmds(ctx, initf, idx, ic) - initf.write('exit 0\n') + _write_init_containers_script(ctx, initf, init_containers) # sidecar container scripts for sidecar in sidecars or []: @@ -220,6 +217,18 @@ def _write_stop_actions( ) +def _write_init_containers_script( + ctx: CephadmContext, + file_obj: IO[str], + init_containers: List[InitContainer], +) -> None: + file_obj.write('set -e\n') + _write_init_container_cmds_clean(ctx, file_obj, init_containers[0]) + for idx, ic in enumerate(init_containers): + _write_init_container_cmds(ctx, file_obj, idx, ic) + file_obj.write('exit 0\n') + + def _write_sidecar_script( ctx: CephadmContext, file_obj: IO[str], |