From cb0807d6736362b401ccd0ff504f8bee9f09900b Mon Sep 17 00:00:00 2001 From: Ramon Perez Date: Thu, 12 Sep 2024 12:49:15 +0200 Subject: [PATCH] Launch testpmd and trex with an infinite loop entrypoint --- testpmd-container-app/cnfapp/Dockerfile | 5 +++- .../cnfapp/scripts/infinite.sh | 3 +++ .../cnfapp/scripts/testpmd-wrapper | 20 ++++++++++---- .../roles/testpmd/templates/deployment.yml | 26 +----------------- trex-container-app/server/Dockerfile | 5 ++++ trex-container-app/server/scripts/infinite.sh | 3 +++ trex-operator/roles/server/defaults/main.yml | 1 - .../roles/server/templates/deployment.yml | 27 +------------------ 8 files changed, 32 insertions(+), 58 deletions(-) create mode 100755 testpmd-container-app/cnfapp/scripts/infinite.sh create mode 100755 trex-container-app/server/scripts/infinite.sh diff --git a/testpmd-container-app/cnfapp/Dockerfile b/testpmd-container-app/cnfapp/Dockerfile index b3fc4a1a..ffecb02f 100644 --- a/testpmd-container-app/cnfapp/Dockerfile +++ b/testpmd-container-app/cnfapp/Dockerfile @@ -45,9 +45,12 @@ RUN chown example-cnf /var/log/testpmd COPY --chmod=550 --from=build2 /utils/webserver /usr/local/bin/webserver COPY --chmod=550 --from=build /usr/local/bin/dpdk-testpmd /usr/local/bin/example-cnf/testpmd COPY --chmod=550 scripts/testpmd-wrapper /usr/local/bin/example-cnf/testpmd-wrapper +COPY --chmod=550 scripts/infinite.sh /usr/local/bin/example-cnf/infinite.sh # Move to the custom user USER example-cnf # Prepare entrypoint -ENTRYPOINT ["/usr/local/bin/example-cnf/testpmd-wrapper"] +#ENTRYPOINT ["/usr/local/bin/example-cnf/testpmd-wrapper"] +## Make the container to live forever without executing testpmd-wrapper, we'll run it manually +ENTRYPOINT ["/usr/local/bin/example-cnf/infinite.sh"] diff --git a/testpmd-container-app/cnfapp/scripts/infinite.sh b/testpmd-container-app/cnfapp/scripts/infinite.sh new file mode 100755 index 00000000..bf1fede7 --- /dev/null +++ b/testpmd-container-app/cnfapp/scripts/infinite.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sleep 999999999999 & diff --git a/testpmd-container-app/cnfapp/scripts/testpmd-wrapper b/testpmd-container-app/cnfapp/scripts/testpmd-wrapper index 8b48a651..4516806f 100644 --- a/testpmd-container-app/cnfapp/scripts/testpmd-wrapper +++ b/testpmd-container-app/cnfapp/scripts/testpmd-wrapper @@ -89,6 +89,15 @@ CMD="${CMD} 2>&1 | tee /var/log/testpmd/app.log" echo "${CMD}" > $RUN chmod +x $RUN +RUN_INT="/usr/local/bin/example-cnf/testpmd-interactive" +CMD_INT="/usr/local/bin/example-cnf/testpmd" +CMD_INT="${CMD_INT} -l $LCORES --in-memory $PCI --socket-mem ${SOCKET_MEM} -n ${MEMORY_CHANNELS} --proc-type auto --file-prefix pg" +CMD_INT="${CMD_INT} --" +CMD_INT="${CMD_INT} --disable-rss --nb-cores=${FORWARDING_CORES} --rxq=${RXQ} --txq=${TXQ} --rxd=${RXD} --txd=${TXD}" +CMD_INT="${CMD_INT} --i ${ETH_PEER} --forward-mode=mac --stats-period ${STATS_PERIOD}" +echo "${CMD_INT}" > $RUN_INT +chmod +x $RUN_INT + function sig_term() { echo $(date +"%F %T,%3N") > /var/log/testpmd/sigterm-received.log # kill testpmd application @@ -97,8 +106,9 @@ function sig_term() { } trap sig_term SIGTERM -if [[ $RUN_APP == "1" ]]; then - sudo /usr/local/bin/example-cnf/testpmd-run -else - sleep infinity -fi +# do not launch testpmd-run script, we just need its content to launch the same but in interactive mode +#if [[ $RUN_APP == "1" ]]; then +# sudo /usr/local/bin/example-cnf/testpmd-run +#else +# sleep infinity +#fi diff --git a/testpmd-operator/roles/testpmd/templates/deployment.yml b/testpmd-operator/roles/testpmd/templates/deployment.yml index 89c6dc7f..1456a07f 100644 --- a/testpmd-operator/roles/testpmd/templates/deployment.yml +++ b/testpmd-operator/roles/testpmd/templates/deployment.yml @@ -60,6 +60,7 @@ spec: containerPort: 8095 image: "{{ image_testpmd }}" imagePullPolicy: "{{ image_pull_policy }}" + command: ['tail', '-f', '/dev/null'] securityContext: {% if privileged %} privileged: true @@ -118,31 +119,6 @@ spec: - name: {{ key }} value: "{{ value }}" {% endfor %} - lifecycle: - postStart: - exec: - command: ["/bin/sh", "-c", "echo Hello from the postStart handler"] - preStop: - exec: - command: ["/bin/sh", "-c", "echo Hello from the preStop handler"] - livenessProbe: - httpGet: - path: /healthz - port: 8095 - initialDelaySeconds: 15 - periodSeconds: 10 - readinessProbe: - httpGet: - path: /readyz - port: 8095 - initialDelaySeconds: 5 - periodSeconds: 10 - startupProbe: - httpGet: - path: /startz - port: 8095 - initialDelaySeconds: 30 - periodSeconds: 10 terminationMessagePolicy: FallbackToLogsOnError volumes: - name: hugepage diff --git a/trex-container-app/server/Dockerfile b/trex-container-app/server/Dockerfile index 32094f59..c035e22e 100644 --- a/trex-container-app/server/Dockerfile +++ b/trex-container-app/server/Dockerfile @@ -79,3 +79,8 @@ COPY --chmod=550 --from=build /utils/webserver /usr/local/bin/webserver # Move to the custom user USER example-cnf + +# Prepare entrypoint +#ENTRYPOINT ["trex-wrapper"] +## Make the container to live forever without executing testpmd-wrapper, we'll run it manually +ENTRYPOINT ["infinite.sh"] diff --git a/trex-container-app/server/scripts/infinite.sh b/trex-container-app/server/scripts/infinite.sh new file mode 100755 index 00000000..bf1fede7 --- /dev/null +++ b/trex-container-app/server/scripts/infinite.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sleep 999999999999 & diff --git a/trex-operator/roles/server/defaults/main.yml b/trex-operator/roles/server/defaults/main.yml index 0423e0a7..c95d8523 100644 --- a/trex-operator/roles/server/defaults/main.yml +++ b/trex-operator/roles/server/defaults/main.yml @@ -6,7 +6,6 @@ image_server: "quay.io/rh-nfv-int/trex-container-server@sha256:190d69aef293d1719 image_app: "quay.io/rh-nfv-int/trex-container-app@sha256:da8c5aae7f2f7459d9d7b842880040cfde0ce301a9edc83e88ae9f27dc448829" # v0.2.6 image_pull_policy: IfNotPresent privileged: false -command: ["trex-wrapper"] environments: {} network_resources: {} enable_lb: true diff --git a/trex-operator/roles/server/templates/deployment.yml b/trex-operator/roles/server/templates/deployment.yml index c3c226dc..c08c5841 100644 --- a/trex-operator/roles/server/templates/deployment.yml +++ b/trex-operator/roles/server/templates/deployment.yml @@ -68,7 +68,7 @@ spec: containers: {% if trex_server|bool %} - name: trex-server - command: {{ command }} + command: ['tail', '-f', '/dev/null'] image: "{{ image_server }}" imagePullPolicy: "{{ image_pull_policy }}" ports: @@ -120,31 +120,6 @@ spec: - name: {{ key }} value: "{{ value }}" {% endfor %} - lifecycle: - postStart: - exec: - command: ["/bin/sh", "-c", "echo Hello from the postStart handler"] - preStop: - exec: - command: ["/bin/sh", "-c", "echo Hello from the preStop handler"] - livenessProbe: - httpGet: - path: /healthz - port: 8096 - initialDelaySeconds: 15 - periodSeconds: 10 - readinessProbe: - httpGet: - path: /readyz - port: 8096 - initialDelaySeconds: 5 - periodSeconds: 10 - startupProbe: - httpGet: - path: /startz - port: 8096 - initialDelaySeconds: 30 - periodSeconds: 10 terminationMessagePolicy: FallbackToLogsOnError {% endif %} {% if trex_app|bool %}