Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/asset/agent/joiner/clusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ func (ci *ClusterInfo) retrieveSSHKey() error {
ci.SSHKey = installConfig.SSHKey
return nil
}

if errors.IsNotFound(err) {
return nil
}
return err
}
var ign igntypes.Config
Expand Down
55 changes: 36 additions & 19 deletions pkg/asset/agent/joiner/clusterinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,41 @@ storage:
name: "99-worker-ssh",
err: errors.NewForbidden(schema.GroupResource{}, "", nil),
},
overrideExpectedClusterInfo: func(clusterInfo ClusterInfo) ClusterInfo {
t.Helper()
clusterInfo.SSHKey = "my-ssh-key-from-installconfig"
return clusterInfo
},
},
{
name: "ssh-key from 99-worker-ssh configmap",
workflow: workflow.AgentWorkflowTypeAddNodes,
objs: func(t *testing.T) ([]runtime.Object, []runtime.Object, []runtime.Object) {
t.Helper()
objs, ocObjs, ocMachineConfigObjs := defaultObjects()(t)
ocMachineConfigObjs = append(ocMachineConfigObjs, &machineconfigv1.MachineConfig{
ObjectMeta: v1.ObjectMeta{
Name: "99-worker-ssh",
},
Spec: machineconfigv1.MachineConfigSpec{
Config: runtime.RawExtension{
Raw: []byte(`
ignition:
version: 3.2.0
passwd:
users:
- name: core
sshAuthorizedKeys:
- my-ssh-key-from-cm`),
}}})

return objs, ocObjs, ocMachineConfigObjs
},
overrideExpectedClusterInfo: func(clusterInfo ClusterInfo) ClusterInfo {
t.Helper()
clusterInfo.SSHKey = "my-ssh-key-from-cm"
return clusterInfo
},
},
}
for _, tc := range cases {
Expand Down Expand Up @@ -343,7 +378,7 @@ func makeInstallConfig(t *testing.T) string {
},
},
},
SSHKey: "my-ssh-key",
SSHKey: "my-ssh-key-from-installconfig",
FIPS: true,
}
data, err := yaml.Marshal(ic)
Expand Down Expand Up @@ -478,23 +513,6 @@ func defaultObjects() func(t *testing.T) ([]runtime.Object, []runtime.Object, []
}

openshiftMachineConfigObjects := []runtime.Object{
&machineconfigv1.MachineConfig{
ObjectMeta: v1.ObjectMeta{
Name: "99-worker-ssh",
},
Spec: machineconfigv1.MachineConfigSpec{
Config: runtime.RawExtension{
Raw: []byte(`
ignition:
version: 3.2.0
passwd:
users:
- name: core
sshAuthorizedKeys:
- my-ssh-key`),
},
},
},
&machineconfigv1.MachineConfig{
ObjectMeta: v1.ObjectMeta{
Name: "99-worker-fips",
Expand Down Expand Up @@ -534,7 +552,6 @@ func defaultExpectedClusterInfo() ClusterInfo {
},
},
PlatformType: v1beta1.BareMetalPlatformType,
SSHKey: "my-ssh-key",
OSImage: buildStreamData(),
OSImageLocation: "http://my-coreosimage-url/416.94.202402130130-0",
IgnitionEndpointWorker: &models.IgnitionEndpoint{
Expand Down