kcl-lang / kcl-lang.io

KCL Website and Documentation Repo: https://kcl-lang.io
https://kcl-lang.github.io
Apache License 2.0
12 stars 33 forks source link

[BUG] Zombie (<defunct>) processes within the kcl argocd pod plugin #350

Closed metacoma closed 3 months ago

metacoma commented 3 months ago

Bug Report

1. Minimal reproduce step (Required)

2. What did you expect to see? (Required)

No <defunct> processes

3. What did you see instead (Required)

999           62 21.6  0.0      0     0 ?        Z    18:44   0:30 [kclvm_cli] <defunct>
999           63  0.0  0.0      0     0 ?        Z    18:44   0:00 [kclvm_cli] <defunct>
999          160  0.5  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>
999          161  0.0  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>
999          205  0.6  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>
999          206  0.0  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>
999          250  0.6  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>
999          251  0.0  0.0      0     0 ?        Z    18:45   0:00 [kclvm_cli] <defunct>

4. What is your KCL components version? (Required)

0.8.7-linux-amd64

metacoma commented 3 months ago

The root cause of this bug is described here: https://github.com/argoproj/argo-cd/issues/13026#issuecomment-1489800913

Here is a steps to eliminate defunct processes in kcl-cmp argo plugin:

  1. Add tiny binary to kcl-cmp image https://github.com/kcl-lang/kcl/pull/1264
  2. Build and publish kcllang/kcllang-cmp-plugin (for example) image after each KCL release
  3. Change entrypoint and arguments in kcl-cmp manifest https://github.com/kcl-lang/kcl-lang.io/pull/351

As a result, there are no defunct processes after several argocd app sync calls.

$ kubectl -n argocd exec -it `kubectl -n argocd get pod -l app.kubernetes.io/component=repo-server -o name` -c my-plugin -- ps auxw
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
999            1  0.0  0.0   2780  1152 ?        Ss   00:30   0:00 /tini /var/run/argocd/argocd-cmp-server -- --loglevel=debug
999            6  0.0  0.5 5540792 83536 ?       Sl   00:30   0:01 /var/run/argocd/argocd-cmp-server --loglevel=debug
999           76  0.0  0.0   4628  3584 pts/0    Ss+  00:33   0:00 /bin/bash
999          360  0.0  0.0   7064  2944 pts/1    Rs+  01:17   0:00 ps auxw