Commit 5960904
committed
nocloud: handle dict-of-strings public-keys format
The third branch of NoCloudConfigDriveService.get_public_keys() assumed
public-keys was a dict of {<name>: {'openssh-key': <key>}} (OpenStack
config drive shape) and called .get('openssh-key') on each value.
KubeVirt's accessCredentials sshPublicKey noCloud propagation method
serialises the keys as map[string]string, producing
{'key0': '<ssh-rsa ...>', 'key1': '<ssh-rsa ...>'} - dict whose values
are plain strings. With that input the plugin crashed with:
ERROR cloudbaseinit.init [-] plugin 'SetUserSSHPublicKeysPlugin'
failed with error "'str' object has no attribute 'get'"
File "...nocloudservice.py", line 698, in get_public_keys
public_keys = service.get_public_keys()
Accept both shapes: if the dict value is a string treat it as the SSH
key directly, otherwise keep the previous OpenStack-style extraction.
Reproduced on Windows Server 2022/2025 deployed on KubeVirt 1.8.x +
cloudbase-init 1.1.8 with the Cozystack vm-instance chart that wires
.Values.sshKeys into accessCredentials sshPublicKey + noCloud
propagation. KubeVirt source for the format: pkg/cloud-init/cloud-init.go,
type NoCloudMetadata PublicSSHKeys map[string]string.
Adds a regression unit test test_get_public_keys_dict_of_strings
mirroring the existing test_get_public_keys / test_get_public_keys_alt_fmt
pattern.
Signed-off-by: mattia-eleuteri <mattia@hidora.io>1 parent c48d759 commit 5960904
2 files changed
Lines changed: 25 additions & 1 deletion
File tree
- cloudbaseinit
- metadata/services
- tests/metadata/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
699 | 706 | | |
700 | 707 | | |
701 | 708 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
519 | 536 | | |
520 | 537 | | |
521 | 538 | | |
| |||
0 commit comments