-
Notifications
You must be signed in to change notification settings - Fork 521
Restart driver pods in place when driver config is unchanged #2527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rajathagasthya
merged 1 commit into
NVIDIA:main
from
rajathagasthya:worktree-minor-version-driver-no-upgrade
Jun 30, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| # Copyright (c) NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| **/ | ||
|
|
||
| // Package predicates holds predicates the upgrade controller registers on the | ||
| // k8s-operator-libs upgrade state manager. | ||
| package predicates | ||
|
|
||
| import ( | ||
| "github.com/go-logr/logr" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
||
| "github.com/NVIDIA/k8s-operator-libs/pkg/consts" | ||
| "github.com/NVIDIA/k8s-operator-libs/pkg/upgrade" | ||
|
|
||
| driverconfig "github.com/NVIDIA/gpu-operator/internal/config" | ||
| ) | ||
|
|
||
| // DriverPodRestartOnly returns the upgrade controller's RestartOnlyPredicate: it allows an | ||
| // out-of-sync driver pod to be restarted in place when the running pod spec and the desired | ||
| // DaemonSet template spec have the same DRIVER_CONFIG_DIGEST, i.e. the install-relevant | ||
| // config is unchanged (e.g. only a helm.sh/chart label changed). If either digest is missing, | ||
| // it returns false and the node takes the full upgrade flow. | ||
| func DriverPodRestartOnly(log logr.Logger) upgrade.RestartOnlyPredicate { | ||
| return func(running, desired *corev1.PodSpec) (bool, error) { | ||
| desiredDigest := driverconfig.DriverConfigDigestFromPodSpec(desired) | ||
| runningDigest := driverconfig.DriverConfigDigestFromPodSpec(running) | ||
| if desiredDigest == "" || runningDigest == "" { | ||
| log.V(consts.LogLevelDebug).Info("driver config digest missing; taking full upgrade flow", | ||
| "desiredDigest", desiredDigest, "runningDigest", runningDigest) | ||
| return false, nil | ||
| } | ||
| restartOnly := desiredDigest == runningDigest | ||
| log.V(consts.LogLevelDebug).Info("evaluated driver config digest for restart-only routing", | ||
| "desiredDigest", desiredDigest, "runningDigest", runningDigest, "restartOnly", restartOnly) | ||
| return restartOnly, nil | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| # Copyright (c) NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| **/ | ||
|
|
||
| package predicates | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/go-logr/logr" | ||
| "github.com/stretchr/testify/assert" | ||
| corev1 "k8s.io/api/core/v1" | ||
|
|
||
| driverconfig "github.com/NVIDIA/gpu-operator/internal/config" | ||
| ) | ||
|
|
||
| func TestDriverPodRestartOnly(t *testing.T) { | ||
| podSpec := func(digest string) *corev1.PodSpec { | ||
| return &corev1.PodSpec{Containers: []corev1.Container{{ | ||
| Name: "nvidia-driver-ctr", | ||
| Env: []corev1.EnvVar{{Name: driverconfig.DriverConfigDigestEnvName, Value: digest}}, | ||
| }}} | ||
| } | ||
|
|
||
| predicate := DriverPodRestartOnly(logr.Discard()) | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| running *corev1.PodSpec | ||
| desired *corev1.PodSpec | ||
| wantRestart bool | ||
| }{ | ||
| {name: "equal digests -> restart-only", running: podSpec("same"), desired: podSpec("same"), wantRestart: true}, | ||
| {name: "differing digests -> full upgrade", running: podSpec("old"), desired: podSpec("new"), wantRestart: false}, | ||
| {name: "missing digest on running pod -> full upgrade", running: podSpec(""), desired: podSpec("new"), wantRestart: false}, | ||
| {name: "missing digest on desired template -> full upgrade", running: podSpec("old"), desired: podSpec(""), wantRestart: false}, | ||
| {name: "nil running spec -> full upgrade", running: nil, desired: podSpec("x"), wantRestart: false}, | ||
| {name: "nil desired spec -> full upgrade", running: podSpec("x"), desired: nil, wantRestart: false}, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got, err := predicate(tt.running, tt.desired) | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, tt.wantRestart, got) | ||
| }) | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
vendor/github.com/NVIDIA/k8s-operator-libs/pkg/upgrade/common_manager.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.