Skip to content

Commit

Permalink
Launch testpmd and trex with an infinite loop entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ramperher committed Nov 27, 2024
1 parent 1519170 commit 5515318
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 58 deletions.
5 changes: 4 additions & 1 deletion testpmd-container-app/cnfapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,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/run/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/run/infinite.sh"]
3 changes: 3 additions & 0 deletions testpmd-container-app/cnfapp/scripts/infinite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sleep 999999999999 &
20 changes: 15 additions & 5 deletions testpmd-container-app/cnfapp/scripts/testpmd-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -97,8 +106,9 @@ function sig_term() {
}
trap sig_term SIGTERM

if [[ $RUN_APP == "1" ]]; then
sudo /usr/local/bin/example-cnf/run/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/run/testpmd-run
#else
# sleep infinity
#fi
26 changes: 1 addition & 25 deletions testpmd-operator/roles/testpmd/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
containerPort: 8095
image: "{{ image_testpmd }}"
imagePullPolicy: "{{ image_pull_policy }}"
command: ['tail', '-f', '/dev/null']
securityContext:
runAsNonRoot: true
runAsUser: 56560
Expand Down Expand Up @@ -130,31 +131,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
Expand Down
5 changes: 5 additions & 0 deletions trex-container-app/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,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"]
3 changes: 3 additions & 0 deletions trex-container-app/server/scripts/infinite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sleep 999999999999 &
1 change: 0 additions & 1 deletion trex-operator/roles/server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 1 addition & 26 deletions trex-operator/roles/server/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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:
Expand Down Expand Up @@ -130,31 +130,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 %}
Expand Down

0 comments on commit 5515318

Please sign in to comment.