stx control stop: faster shutdown
Make sure aptly & builder containers catch and handle SIGTERM. Otherwise "stx stop" sends the signal, 2 out of 6 containers ignore it, then docker waits for ~15 seconds and SIGKILL's them. * stx-builder.Dockerfile: change default image command from plain "bash" to "tini" that starts "sleep infinity". Tini catches and broadcasts signals to its own children (sleep), enabling graceful shutdown to work * aptly: replace call to "supervisord" to "exec supervisord", to make sure it runs as PID 1 and actually receives signals from docker. * stx_control.py: slightly reduce loop sleep time in "stx control stop" TESTS ================== * Retest "stx control start --wait" * Make sure builder's entry point executes "finisSetup.sh" script, as before this change * Make sure "stx control stop --wait" exits quickly (~4 seconds on my machine, down from ~15 seconds) Story: 2011038 Task: 49577 Signed-off-by: Davlet Panech <davlet.panech@windriver.com> Change-Id: I984846fc45349be045c069b84186f12179fe36ad
This commit is contained in:
parent
4df5160bbd
commit
86d219ada7
|
@ -51,6 +51,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
rpm2cpio \
|
rpm2cpio \
|
||||||
ssh \
|
ssh \
|
||||||
sudo \
|
sudo \
|
||||||
|
tini \
|
||||||
unzip \
|
unzip \
|
||||||
vim \
|
vim \
|
||||||
wget \
|
wget \
|
||||||
|
@ -97,3 +98,6 @@ RUN apt-key add /root/pubkey.rsa && rm -f /root/pubkey.rsa
|
||||||
RUN mkdir -p /etc/vim
|
RUN mkdir -p /etc/vim
|
||||||
COPY stx/toCOPY/common/vimrc.local /etc/vim/vimrc.local
|
COPY stx/toCOPY/common/vimrc.local /etc/vim/vimrc.local
|
||||||
RUN chmod 0644 /etc/vim/vimrc.local
|
RUN chmod 0644 /etc/vim/vimrc.local
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/tini", "-g", "--"]
|
||||||
|
CMD ["/bin/bash", "-i", "-c", "exec /bin/sleep infinity" ]
|
||||||
|
|
|
@ -80,7 +80,7 @@ class KubeHelper:
|
||||||
suffix='.stderr') as stderr_file:
|
suffix='.stderr') as stderr_file:
|
||||||
cmd = f'{self.config.kubectl()} get pods --no-headers'
|
cmd = f'{self.config.kubectl()} get pods --no-headers'
|
||||||
cmd += f' --selector=app.kubernetes.io/instance={project_name} 2>{stderr_file.name}'
|
cmd += f' --selector=app.kubernetes.io/instance={project_name} 2>{stderr_file.name}'
|
||||||
process_result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
|
process_result = subprocess.run(cmd, encoding='utf-8', shell=True, stdout=subprocess.PIPE)
|
||||||
if process_result.returncode != 0:
|
if process_result.returncode != 0:
|
||||||
logger.error('Command failed: %s\n%s', cmd, stderr_file.fread())
|
logger.error('Command failed: %s\n%s', cmd, stderr_file.fread())
|
||||||
raise RuntimeError("Failed to list pods")
|
raise RuntimeError("Failed to list pods")
|
||||||
|
|
|
@ -306,7 +306,7 @@ stx-pkgbuilder/configmap/')
|
||||||
self.logger.warning("gave up while pods are still running")
|
self.logger.warning("gave up while pods are still running")
|
||||||
break
|
break
|
||||||
self.logger.info("waiting for %d pod(s) to exit", pod_count)
|
self.logger.info("waiting for %d pod(s) to exit", pod_count)
|
||||||
time.sleep(3)
|
time.sleep(2)
|
||||||
|
|
||||||
def handleIsStartedTask(self, projectname):
|
def handleIsStartedTask(self, projectname):
|
||||||
if self.k8s.helm_release_exists(projectname):
|
if self.k8s.helm_release_exists(projectname):
|
||||||
|
|
|
@ -39,4 +39,4 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start Supervisor
|
# Start Supervisor
|
||||||
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
||||||
|
|
Loading…
Reference in New Issue