Skip to content

Commit d2a2700

Browse files
Merge pull request #1178 from jcpunk/systemd-envfile
[no-relnote] Setup envfile for systemd services
2 parents c8e3c3a + c4a9bbe commit d2a2700

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file can be used to override the configuration of the
2+
# nvidia-ctk cdi generate
3+
# command invoked by the nvidia-cdi-refresh.service.
4+
#
5+
# This is done by specifying the name and value of the environment variables in
6+
# this file as follows:
7+
#
8+
# ENVVAR=value
9+
#
10+
# For a list of envvars that can be set set the output of:
11+
#
12+
# nvidia-ctk --help
13+
#
14+
# and
15+
#
16+
# nvidia-ctk cdi generate --help
17+
#
18+
# For example, to change the for the generated CDI specification update and
19+
# uncomment the following line:
20+
# NVIDIA_CTK_CDI_OUTPUT_FILE_PATH=/var/run/cdi/nvidia.yaml

deployments/systemd/nvidia-cdi-refresh.service

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ ConditionPathExists=/usr/bin/nvidia-ctk
2020

2121
[Service]
2222
Type=oneshot
23-
EnvironmentFile=-/etc/nvidia-container-toolkit/cdi-refresh.env
23+
# Values from Environment will be replaced if defined in EnvironmentFile
24+
Environment=NVIDIA_CTK_CDI_OUTPUT_FILE_PATH=/var/run/cdi/nvidia.yaml
25+
EnvironmentFile=-/etc/nvidia-container-toolkit/nvidia-cdi-refresh.env
2426
ExecCondition=/usr/bin/grep -qE '/nvidia.ko' /lib/modules/%v/modules.dep
25-
ExecStart=/usr/bin/nvidia-ctk cdi generate --output=/var/run/cdi/nvidia.yaml
27+
ExecStart=/usr/bin/nvidia-ctk cdi generate
2628
CapabilityBoundingSet=CAP_SYS_MODULE CAP_SYS_ADMIN CAP_MKNOD
2729

2830
[Install]

packaging/debian/nvidia-container-toolkit-base.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ nvidia-ctk /usr/bin
33
nvidia-cdi-hook /usr/bin
44
nvidia-cdi-refresh.service /etc/systemd/system/
55
nvidia-cdi-refresh.path /etc/systemd/system/
6+
nvidia-cdi-refresh.env /etc/nvidia-container-toolkit/

packaging/rpm/SPECS/nvidia-container-toolkit.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Source5: nvidia-container-runtime.legacy
1919
Source6: nvidia-cdi-hook
2020
Source7: nvidia-cdi-refresh.service
2121
Source8: nvidia-cdi-refresh.path
22+
Source9: nvidia-cdi-refresh.env
2223

2324
Obsoletes: nvidia-container-runtime <= 3.5.0-1, nvidia-container-runtime-hook <= 1.4.0-2
2425
Provides: nvidia-container-runtime
@@ -35,6 +36,7 @@ cp %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6}
3536
%install
3637
mkdir -p %{buildroot}%{_bindir}
3738
mkdir -p %{buildroot}%{_sysconfdir}/systemd/system/
39+
mkdir -p %{buildroot}%{_sysconfdir}/nvidia-container-toolkit
3840

3941
install -m 755 -t %{buildroot}%{_bindir} nvidia-container-runtime-hook
4042
install -m 755 -t %{buildroot}%{_bindir} nvidia-container-runtime
@@ -44,6 +46,7 @@ install -m 755 -t %{buildroot}%{_bindir} nvidia-ctk
4446
install -m 755 -t %{buildroot}%{_bindir} nvidia-cdi-hook
4547
install -m 644 -t %{buildroot}%{_sysconfdir}/systemd/system nvidia-cdi-refresh.service
4648
install -m 644 -t %{buildroot}%{_sysconfdir}/systemd/system nvidia-cdi-refresh.path
49+
install -m 644 -t %{buildroot}%{_sysconfdir}/nvidia-container-toolkit nvidia-cdi-refresh.env
4750

4851
%post
4952
if [ $1 -gt 1 ]; then # only on package upgrade
@@ -105,6 +108,7 @@ Provides tools such as the NVIDIA Container Runtime and NVIDIA Container Toolkit
105108
%{_bindir}/nvidia-cdi-hook
106109
%{_sysconfdir}/systemd/system/nvidia-cdi-refresh.service
107110
%{_sysconfdir}/systemd/system/nvidia-cdi-refresh.path
111+
%config(noreplace) %{_sysconfdir}/nvidia-container-toolkit/nvidia-cdi-refresh.env
108112

109113
# The OPERATOR EXTENSIONS package consists of components that are required to enable GPU support in Kubernetes.
110114
# This package is not distributed as part of the NVIDIA Container Toolkit RPMs.

0 commit comments

Comments
 (0)