Skip to content

Commit ddf7c20

Browse files
committed
use only major version for rhel-specific driver images
Signed-off-by: Rahul Sharma <rahulsharm@nvidia.com>
1 parent 5441f4d commit ddf7c20

5 files changed

Lines changed: 27 additions & 78 deletions

File tree

controllers/state_manager.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"fmt"
2222
"path/filepath"
23-
"strconv"
2423
"strings"
2524

2625
"github.com/go-logr/logr"
@@ -662,42 +661,16 @@ func (n *ClusterPolicyController) getGPUNodeOSInfo() (string, string, error) {
662661
if !ok {
663662
return "", "", fmt.Errorf("unable to retrieve OS version from label %s", nfdOSVersionIDLabelKey)
664663
}
665-
osMajorVersion := strings.Split(osVersion, ".")[0]
666-
667-
// If the OS is RockyLinux or RHEL 10 & above, we will omit the minor version when constructing the os image tag
664+
// If the OS is RockyLinux or RHEL, we will omit the minor version when constructing the os image tag
668665
switch osName {
669-
case "rocky":
670-
osVersion = osMajorVersion
671-
case "rhel":
672-
osMajorNumber, err := parseOSMajorVersion(osVersion)
673-
if err != nil {
674-
return "", "", err
675-
}
676-
if osMajorNumber >= 10 {
677-
osVersion = osMajorVersion
678-
}
666+
case "rocky", "rhel":
667+
osVersion = strings.Split(osVersion, ".")[0]
679668
}
680669
osTag := fmt.Sprintf("%s%s", osName, osVersion)
681670

682671
return osName, osTag, nil
683672
}
684673

685-
func parseOSMajorVersion(osVersion string) (int, error) {
686-
osMajorVersion := strings.Split(osVersion, ".")[0]
687-
osMajorVersion = strings.TrimSpace(osMajorVersion)
688-
osMajorVersion = strings.TrimPrefix(strings.TrimPrefix(osMajorVersion, "v"), "V")
689-
if osMajorVersion == "" {
690-
return 0, fmt.Errorf("empty OS major version")
691-
}
692-
693-
osMajorNumber, err := strconv.Atoi(osMajorVersion)
694-
if err != nil {
695-
return 0, fmt.Errorf("error processing OS major version %s: %w", osMajorVersion, err)
696-
}
697-
698-
return osMajorNumber, nil
699-
}
700-
701674
func (n *ClusterPolicyController) setPodSecurityLabelsForNamespace() error {
702675
ctx := n.ctx
703676
namespaceName := clusterPolicyCtrl.operatorNamespace

controllers/state_manager_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ func TestGetGPUNodeOSInfo(t *testing.T) {
4646
osVersion: "v1.12.6",
4747
expected: "talosv1.12.6",
4848
},
49+
{
50+
name: "rhel 9 omits minor version",
51+
osName: "rhel",
52+
osVersion: "9.4",
53+
expected: "rhel9",
54+
},
55+
{
56+
name: "rhel 8 omits minor version",
57+
osName: "rhel",
58+
osVersion: "8.10",
59+
expected: "rhel8",
60+
},
4961
{
5062
name: "rhel 10 omits minor version",
5163
osName: "rhel",
@@ -88,13 +100,6 @@ func TestGetGPUNodeOSInfo(t *testing.T) {
88100
osVersion: "rolling",
89101
expected: "archlinuxrolling",
90102
},
91-
{
92-
name: "rhel invalid major version errors",
93-
osName: "rhel",
94-
osVersion: "A.10",
95-
expectError: true,
96-
errorContainsText: "error processing OS major version",
97-
},
98103
}
99104

100105
for _, tc := range testCases {

deployments/gpu-operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ driver:
148148
usePrecompiled: false
149149
repository: nvcr.io/nvidia
150150
image: driver
151-
version: "595.58.03"
151+
version: "595.71.05"
152152
imagePullPolicy: IfNotPresent
153153
imagePullSecrets: []
154154
startupProbe:

internal/state/nodepool.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"fmt"
2222
"maps"
23-
"strconv"
2423
"strings"
2524

2625
corev1 "k8s.io/api/core/v1"
@@ -141,41 +140,13 @@ func getNodePools(ctx context.Context, k8sClient client.Client, selector map[str
141140
}
142141

143142
func getOSTag(osRelease, osVersion string) (string, error) {
144-
osMajorVersion := strings.Split(osVersion, ".")[0]
145-
146143
var osTagSuffix string
147-
// If the OS is RockyLinux or RHEL 10 & above, we will omit the minor version when constructing the os image tag
144+
// If the OS is RockyLinux or RHEL, we will omit the minor version when constructing the os image tag
148145
switch osRelease {
149-
case "rocky":
150-
osTagSuffix = osMajorVersion
151-
case "rhel":
152-
osMajorNumber, err := parseOSMajorVersion(osVersion)
153-
if err != nil {
154-
return "", fmt.Errorf("failed to parse os version: %w", err)
155-
}
156-
if osMajorNumber >= 10 {
157-
osTagSuffix = osMajorVersion
158-
} else {
159-
osTagSuffix = osVersion
160-
}
146+
case "rocky", "rhel":
147+
osTagSuffix = strings.Split(osVersion, ".")[0]
161148
default:
162149
osTagSuffix = osVersion
163150
}
164151
return fmt.Sprintf("%s%s", osRelease, osTagSuffix), nil
165152
}
166-
167-
func parseOSMajorVersion(osVersion string) (int, error) {
168-
osMajorVersion := strings.Split(osVersion, ".")[0]
169-
osMajorVersion = strings.TrimSpace(osMajorVersion)
170-
osMajorVersion = strings.TrimPrefix(strings.TrimPrefix(osMajorVersion, "v"), "V")
171-
if osMajorVersion == "" {
172-
return 0, fmt.Errorf("empty OS major version")
173-
}
174-
175-
osMajorNumber, err := strconv.Atoi(osMajorVersion)
176-
if err != nil {
177-
return 0, err
178-
}
179-
180-
return osMajorNumber, nil
181-
}

internal/state/nodepool_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ func TestGetOSTag(t *testing.T) {
3535
description: "valid os release & version",
3636
osRelease: "rhel",
3737
osVersion: "9.4",
38-
expected: "rhel9.4",
38+
expected: "rhel9",
39+
expectError: false,
40+
},
41+
{
42+
description: "valid os release & version - rhel8",
43+
osRelease: "rhel",
44+
osVersion: "8.10",
45+
expected: "rhel8",
3946
expectError: false,
4047
},
4148
{
@@ -73,13 +80,6 @@ func TestGetOSTag(t *testing.T) {
7380
expected: "archlinuxrolling",
7481
expectError: false,
7582
},
76-
{
77-
description: "invalid os version",
78-
osRelease: "rhel",
79-
osVersion: "A.10",
80-
expectError: true,
81-
errorMessage: "failed to parse os version: strconv.Atoi: parsing \"A\": invalid syntax",
82-
},
8383
}
8484

8585
for _, test := range tests {

0 commit comments

Comments
 (0)