Skip to content

Commit aeca231

Browse files
Refactor: move service stop orchestration to hook configuration level
Replace stop-services-for-mode and stop-services-for-config with a single stop-services function. Build the complete stop sequence in hooks-default.yaml by invoking stop-services and stop_driver_services separately. This removes Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent e877022 commit aeca231

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

deployments/systemd/hooks-default.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ hooks:
77
pre-apply-mode:
88
- workdir: "/etc/nvidia-mig-manager"
99
command: "/bin/bash"
10-
args: ["-x", "-c", "source hooks.sh; stop-services-for-mode"]
10+
args: ["-x", "-c", "source hooks.sh; stop-services"]
11+
- workdir: "/etc/nvidia-mig-manager"
12+
command: "/bin/bash"
13+
args: ["-x", "-c", "source hooks.sh; stop_driver_services"]
1114
pre-apply-config:
1215
- workdir: "/etc/nvidia-mig-manager"
1316
command: "/bin/bash"
14-
args: ["-x", "-c", "source hooks.sh; stop-services-for-config"]
17+
args: ["-x", "-c", "source hooks.sh; stop-services"]
1518
apply-exit:
1619
- workdir: "/etc/nvidia-mig-manager"
1720
command: "/bin/bash"

deployments/systemd/hooks.sh

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,9 @@ function persist-config() {
4646
return 0
4747
}
4848

49-
# stop-services-for-mode stops all GPU-dependent services (K8s workloads
50-
# and driver services) before applying MIG mode changes that require a
51-
# GPU reset.
52-
function stop-services-for-mode() {
53-
stop_k8s_services
54-
if [ "${?}" != "0" ]; then
55-
return 1
56-
fi
57-
stop_k8s_pods
58-
if [ "${?}" != "0" ]; then
59-
return 1
60-
fi
61-
stop_driver_services
62-
if [ "${?}" != "0" ]; then
63-
return 1
64-
fi
65-
return 0
66-
}
67-
68-
# stop-services-for-config stops Kubernetes services and pods before
69-
# applying MIG device configuration changes (no GPU reset required).
70-
function stop-services-for-config() {
49+
# stop-services stops Kubernetes services and pods before applying
50+
# MIG configuration changes.
51+
function stop-services() {
7152
stop_k8s_services
7253
if [ "${?}" != "0" ]; then
7354
return 1

0 commit comments

Comments
 (0)