Skip to content

Commit b39ff84

Browse files
fix(systemd): consider the unit to be active
in order to not mislead the end user once the main process is gone. Signed-off-by: Joel Capitao <jcapitao@redhat.com> Co-authored-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
1 parent dda4b93 commit b39ff84

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

deployments/systemd/nvidia-cdi-refresh.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ EnvironmentFile=-/etc/nvidia-container-toolkit/nvidia-cdi-refresh.env
2626
ExecCondition=/usr/bin/grep -qE '/nvidia.ko' /lib/modules/%v/modules.dep
2727
ExecStart=/usr/bin/nvidia-ctk cdi generate
2828
CapabilityBoundingSet=CAP_SYS_MODULE CAP_SYS_ADMIN CAP_MKNOD
29+
RemainAfterExit=yes
2930

3031
[Install]
3132
WantedBy=multi-user.target

tests/e2e/nvidia-cdi-refresh_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,23 @@ EOF
9797
# remove the generated files
9898
rm /var/run/cdi/nvidia.yaml /tmp/nvidia.yaml
9999
100-
# Touch the nvidia-ctk binary to change the mtime
101-
# This will trigger the nvidia-cdi-refresh.path unit to call the
102-
# nvidia-cdi-refresh.service unit, simulating a change(update/downgrade) in the nvidia-ctk binary.
103-
touch $(which nvidia-ctk)
104-
105-
# wait for 3 seconds
100+
# Simulate a binary upgrade by removing and recreating the file
101+
# This mimics package manager behavior during upgrades
102+
NVIDIA_CTK_PATH=$(which nvidia-ctk)
103+
# Create a backup
104+
cp "${NVIDIA_CTK_PATH}" "${NVIDIA_CTK_PATH}.backup"
105+
# Remove the original (simulating uninstall/upgrade phase)
106+
rm -f "${NVIDIA_CTK_PATH}"
107+
# Small delay to ensure systemd detects the removal
108+
sleep 0.1
109+
# Restore from backup (simulating install phase)
110+
cp "${NVIDIA_CTK_PATH}.backup" "${NVIDIA_CTK_PATH}"
111+
# Ensure executable permissions
112+
chmod +x "${NVIDIA_CTK_PATH}"
113+
# Clean up backup
114+
rm -f "${NVIDIA_CTK_PATH}.backup"
115+
116+
# wait for systemd path unit to detect the change and trigger the service
106117
sleep 3
107118
108119
# Check if the file /var/run/cdi/nvidia.yaml is created

0 commit comments

Comments
 (0)