Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: ekarlso <endre.karlson@gmail.com>
  • Loading branch information
ekarlso committed Oct 10, 2024
1 parent bee82b0 commit 31cf332
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/service/vmservice/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func checkCloudInitStatus(ctx context.Context, machineScope *scope.MachineScope)
}
}

if !machineScope.SkipQemuGuestCheck() && !machineScope.SkipCloudInitCheck() {
if !machineScope.SkipCloudInitCheck() {
if running, err := machineScope.InfraCluster.ProxmoxClient.CloudInitStatus(ctx, machineScope.VirtualMachine); err != nil || running {
if running {
return true, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/proxmox/goproxmox/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (c *APIClient) UnmountCloudInitISO(ctx context.Context, vm *proxmox.Virtual

// CloudInitStatus returns the cloud-init status of the VM.
func (c *APIClient) CloudInitStatus(ctx context.Context, vm *proxmox.VirtualMachine) (running bool, err error) {
if err := vm.WaitForAgent(ctx, 5); err != nil {
if err := c.QemuAgentStatus(ctx, vm); err != nil {
return false, errors.Wrap(err, "error waiting for agent")
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ func (m *MachineScope) SkipQemuGuestCheck() bool {

// SkipCloudInitCheck check whether cloud-init status check is enabled.
func (m *MachineScope) SkipCloudInitCheck() bool {
if m.SkipQemuGuestCheck() {
return true
}

if m.ProxmoxMachine.Spec.Checks != nil {
return ptr.Deref(m.ProxmoxMachine.Spec.Checks.SkipCloudInitStatus, false)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ func TestMachineScope_SkipCloudInit(t *testing.T) {
require.False(t, scope.SkipQemuGuestCheck())
}

func TestMachineScope_SkipQemuDisablesCloudInitCheck(t *testing.T) {
p := infrav1alpha1.ProxmoxMachine{
Spec: infrav1alpha1.ProxmoxMachineSpec{
Checks: &infrav1alpha1.ProxmoxMachineChecks{
SkipQemuGuestAgent: ptr.To(true),
},
},
}
scope := MachineScope{
ProxmoxMachine: &p,
}

require.False(t, scope.SkipCloudInitCheck())
}

func TestMachineScope_GetBootstrapSecret(t *testing.T) {
client := fake.NewClientBuilder().Build()
p := infrav1alpha1.ProxmoxMachine{
Expand Down

0 comments on commit 31cf332

Please sign in to comment.