Skip to content

Commit 41d6e53

Browse files
authored
Node Prep Fix
1 parent 05b8c9a commit 41d6e53

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

internal/nodeprep/instruction/instructions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func init() {
3030
instructionMap[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroAmzn, PkgMgr: nodeinfo.PkgMgrYum}] = newRHELYumISCSI()
3131
instructionMap[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroUbuntu, PkgMgr: nodeinfo.PkgMgrApt}] = newDebianAptISCSI()
3232
instructionMap[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroRhcos, PkgMgr: nodeinfo.PkgMgrNone}] = newRHCOSISCSI()
33+
instructionMap[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroRhel, PkgMgr: nodeinfo.PkgMgrNone}] = newRHCOSISCSI()
3334
instructionMap[Key{Protocol: protocol.ISCSI, Distro: "", PkgMgr: nodeinfo.PkgMgrYum}] = newYumISCSI()
3435
instructionMap[Key{Protocol: protocol.ISCSI, Distro: "", PkgMgr: nodeinfo.PkgMgrApt}] = newAptISCSI()
3536
}

internal/nodeprep/instruction/instructions_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
func TestInstructions(t *testing.T) {
1919
RHELYumISCSI := newRHELYumISCSI()
2020
DebianAptISCSI := newDebianAptISCSI()
21+
RHCOSISCSI := newRHCOSISCSI()
2122
YumISCSI := newYumISCSI()
2223
AptISCSI := newAptISCSI()
2324

@@ -28,6 +29,7 @@ func TestInstructions(t *testing.T) {
2829
scopedInstructions := map[Key]Instructions{}
2930
scopedInstructions[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroAmzn, PkgMgr: nodeinfo.PkgMgrYum}] = RHELYumISCSI
3031
scopedInstructions[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroUbuntu, PkgMgr: nodeinfo.PkgMgrApt}] = DebianAptISCSI
32+
scopedInstructions[Key{Protocol: protocol.ISCSI, Distro: nodeinfo.DistroRhel, PkgMgr: nodeinfo.PkgMgrNone}] = RHCOSISCSI
3133
scopedInstructions[Key{Protocol: protocol.ISCSI, Distro: "", PkgMgr: nodeinfo.PkgMgrYum}] = YumISCSI
3234
scopedInstructions[Key{Protocol: protocol.ISCSI, Distro: "", PkgMgr: nodeinfo.PkgMgrApt}] = AptISCSI
3335
ScopedInstructions(scopedInstructions)
@@ -54,6 +56,12 @@ func TestInstructions(t *testing.T) {
5456
},
5557
}
5658

59+
rhelHostSystemResponse := models.HostSystem{
60+
OS: models.SystemOS{
61+
Distro: nodeinfo.DistroRhel,
62+
},
63+
}
64+
5765
const fooDistro nodeinfo.Distro = "foo"
5866

5967
fooHostSystemResponse := models.HostSystem{
@@ -124,6 +132,27 @@ func TestInstructions(t *testing.T) {
124132
setInstructions: setDefaultInstructions,
125133
assertError: assert.NoError,
126134
},
135+
"node info returns rhel distro without package manager": {
136+
getOSClient: func(controller *gomock.Controller) osutils.Utils {
137+
os := mock_osutils.NewMockUtils(controller)
138+
os.EXPECT().GetHostSystemInfo(gomock.Any()).Return(&rhelHostSystemResponse, nil)
139+
return os
140+
},
141+
getBinaryClient: func(controller *gomock.Controller) nodeinfo.Binary {
142+
binary := mock_nodeinfo.NewMockBinary(controller)
143+
binary.EXPECT().FindPath(nodeinfo.PkgMgrYum).Return("")
144+
binary.EXPECT().FindPath(nodeinfo.PkgMgrApt).Return("")
145+
return binary
146+
},
147+
expectedNodeInfo: &nodeinfo.NodeInfo{
148+
PkgMgr: nodeinfo.PkgMgrNone,
149+
HostSystem: rhelHostSystemResponse,
150+
Distro: nodeinfo.DistroRhel,
151+
},
152+
expectedInstructions: []Instructions{RHCOSISCSI},
153+
setInstructions: setDefaultInstructions,
154+
assertError: assert.NoError,
155+
},
127156
"node info returns unknown linux distro without package manager": {
128157
getOSClient: func(controller *gomock.Controller) osutils.Utils {
129158
os := mock_osutils.NewMockUtils(controller)

internal/nodeprep/nodeinfo/node_info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
DistroUbuntu Distro = osutils.Ubuntu
2929
DistroAmzn Distro = "amzn"
3030
DistroRhcos Distro = "rhcos"
31+
DistroRhel Distro = osutils.RHEL
3132
DistroUnknown = "unknown"
3233

3334
PkgMgrYum PkgMgr = "yum"

0 commit comments

Comments
 (0)