Skip to content

MINOR: ensure ps output is unlimited width - #22990

Open
gaurav-narula wants to merge 1 commit into
apache:trunkfrom
gaurav-narula:ps-output-wide
Open

MINOR: ensure ps output is unlimited width#22990
gaurav-narula wants to merge 1 commit into
apache:trunkfrom
gaurav-narula:ps-output-wide

Conversation

@gaurav-narula

@gaurav-narula gaurav-narula commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

kafka-server-stop.sh uses ps to figure out Kafka's pid. This fails when the command is long which may happen due to classpath being passed as the args to the java command.

This change adds the ww flag which ensures no limits are put on ps' output. It also changes jvm/Dockerfile to use ps from procps-ng package as the ps implementation that ships in busybox limits the output to a max of 2048 characters 0.

Reviewers: Chia-Ping Tsai chia7712@gmail.com

`kafka-server-stop.sh` uses `ps` to figure out Kafka's pid. This fails
when the command is long which may happen due to classpath being passed
as the args to the java command.

This change adds the `ww` flag which ensures no limits are put on `ps`'
output. It also changes `jvm/Dockerfile` to use `ps` from `procps-ng`
package as the `ps` implementation that ships in busybox limits the
output to a max of `2048` characters [0].

[0]: https://github.com/mirror/busybox/blob/371fe9f71d445d18be28c82a2a6d82115c8af19d/procps/ps.c#L679
@github-actions github-actions Bot added docker Official Docker image small Small PRs triage PRs from the community labels Jul 29, 2026
Comment thread bin/kafka-server-stop.sh
PIDS=$(ps -Af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
else
PIDS=$(ps ax | grep ' kafka\.Kafka ' | grep java | grep -v grep | awk '{print $1}'| xargs)
PIDS=$(ps axww | grep ' kafka\.Kafka ' | grep java | grep -v grep | awk '{print $1}'| xargs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, w flag has been accepted as a part of POSIX: https://austingroupbugs.net/view.php?id=905

@github-actions github-actions Bot removed the triage PRs from the community label Jul 30, 2026
Comment thread docker/jvm/Dockerfile
apk update ; \
apk upgrade ; \
apk add --no-cache bash; \
apk add --no-cache bash procps-ng; \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why modify build-jsa? Since it's a temporary layer, I believe you meant to apply this fix at line 75

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because build-jsa layer runs jsa_launch which in turn runs kafka-server-stop.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved docker Official Docker image small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants