SUSE / BCI-tests

This repository contains the tests for the SUSE Base Container Images
Apache License 2.0
10 stars 22 forks source link

Obtain the process cmdline from /proc/ not via ps #591

Closed dcermak closed 2 months ago

dcermak commented 2 months ago

This works around the container not shipping ps

[CI:TOXENVS] postfix

CC @Priyankasaggu11929

Priyankasaggu11929 commented 2 months ago

LGTM.

(is it related to the SP5 containers (where ps command was dropped some time back?)

dcermak commented 2 months ago

Priyanka Saggu @.***> writes:

LGTM.

(is it related to the SP5 containers (where ps command was dropped some time back?)

Yes, the pipeline started failing tonight as the container image no longer contains procps in 15SP6

Priyankasaggu11929 commented 2 months ago

Priyanka Saggu @.***> writes: LGTM. (is it related to the SP5 containers (where ps command was dropped some time back?) Yes, the pipeline started failing tonight as the container image no longer contains procps in 15SP6

Thanks Dan. One more follow up question – where was it flagged? (openQA pipelines?)

dcermak commented 2 months ago

Dirk Mueller @.***> writes:

@dirkmueller commented on this pull request.

 """check if Postfix service is running inside the container"""
  • verify PID 1 process is ENTRYPOINT - /bin/bash /entrypoint/entrypoint.sh postfix start

  • assert (
  • "/usr/lib/postfix/bin//master -i"
  • in auto_container.connection.check_output(
  • "ps -eo pid,cmd | grep '^ 1 ' | sed 's/^ 1 //'"
  • )
  • )
  • verify PID 1 process is ENTRYPOINT:

  • /bin/bash /entrypoint/entrypoint.sh postfix start

  • we don't have ps in the container, so read /proc/1/cmdline instead, it

  • contains the binary and its arguments split by \x00

  • cmdline: bytes = auto_container.connection.file("/proc/1/cmdline").content
  • proc_1_cmd = cmdline.replace(bytes((0,)), " ".encode()).decode().strip()

this looks brutally complicated... :/

I've simplified the code as much as possible