Skip to content

Commit 66d1f16

Browse files
Merge pull request #9908 from andfasano/node-joiner-fix-missing-sshkey
OCPBUGS-60600: node-joner ignore error if SSH key was not found
2 parents f55a83a + d1e9b81 commit 66d1f16

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

pkg/asset/agent/joiner/clusterinfo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ func (ci *ClusterInfo) retrieveSSHKey() error {
320320
ci.SSHKey = installConfig.SSHKey
321321
return nil
322322
}
323+
324+
if errors.IsNotFound(err) {
325+
return nil
326+
}
323327
return err
324328
}
325329
var ign igntypes.Config

pkg/asset/agent/joiner/clusterinfo_test.go

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,41 @@ storage:
215215
name: "99-worker-ssh",
216216
err: errors.NewForbidden(schema.GroupResource{}, "", nil),
217217
},
218+
overrideExpectedClusterInfo: func(clusterInfo ClusterInfo) ClusterInfo {
219+
t.Helper()
220+
clusterInfo.SSHKey = "my-ssh-key-from-installconfig"
221+
return clusterInfo
222+
},
223+
},
224+
{
225+
name: "ssh-key from 99-worker-ssh configmap",
226+
workflow: workflow.AgentWorkflowTypeAddNodes,
227+
objs: func(t *testing.T) ([]runtime.Object, []runtime.Object, []runtime.Object) {
228+
t.Helper()
229+
objs, ocObjs, ocMachineConfigObjs := defaultObjects()(t)
230+
ocMachineConfigObjs = append(ocMachineConfigObjs, &machineconfigv1.MachineConfig{
231+
ObjectMeta: v1.ObjectMeta{
232+
Name: "99-worker-ssh",
233+
},
234+
Spec: machineconfigv1.MachineConfigSpec{
235+
Config: runtime.RawExtension{
236+
Raw: []byte(`
237+
ignition:
238+
version: 3.2.0
239+
passwd:
240+
users:
241+
- name: core
242+
sshAuthorizedKeys:
243+
- my-ssh-key-from-cm`),
244+
}}})
245+
246+
return objs, ocObjs, ocMachineConfigObjs
247+
},
248+
overrideExpectedClusterInfo: func(clusterInfo ClusterInfo) ClusterInfo {
249+
t.Helper()
250+
clusterInfo.SSHKey = "my-ssh-key-from-cm"
251+
return clusterInfo
252+
},
218253
},
219254
}
220255
for _, tc := range cases {
@@ -343,7 +378,7 @@ func makeInstallConfig(t *testing.T) string {
343378
},
344379
},
345380
},
346-
SSHKey: "my-ssh-key",
381+
SSHKey: "my-ssh-key-from-installconfig",
347382
FIPS: true,
348383
}
349384
data, err := yaml.Marshal(ic)
@@ -478,23 +513,6 @@ func defaultObjects() func(t *testing.T) ([]runtime.Object, []runtime.Object, []
478513
}
479514

480515
openshiftMachineConfigObjects := []runtime.Object{
481-
&machineconfigv1.MachineConfig{
482-
ObjectMeta: v1.ObjectMeta{
483-
Name: "99-worker-ssh",
484-
},
485-
Spec: machineconfigv1.MachineConfigSpec{
486-
Config: runtime.RawExtension{
487-
Raw: []byte(`
488-
ignition:
489-
version: 3.2.0
490-
passwd:
491-
users:
492-
- name: core
493-
sshAuthorizedKeys:
494-
- my-ssh-key`),
495-
},
496-
},
497-
},
498516
&machineconfigv1.MachineConfig{
499517
ObjectMeta: v1.ObjectMeta{
500518
Name: "99-worker-fips",
@@ -534,7 +552,6 @@ func defaultExpectedClusterInfo() ClusterInfo {
534552
},
535553
},
536554
PlatformType: v1beta1.BareMetalPlatformType,
537-
SSHKey: "my-ssh-key",
538555
OSImage: buildStreamData(),
539556
OSImageLocation: "http://my-coreosimage-url/416.94.202402130130-0",
540557
IgnitionEndpointWorker: &models.IgnitionEndpoint{

0 commit comments

Comments
 (0)