Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opennebula_virtual_machine_group fails to store state after creation #497

Open
sorinpad opened this issue Oct 19, 2023 · 2 comments · May be fixed by #559
Open

opennebula_virtual_machine_group fails to store state after creation #497

sorinpad opened this issue Oct 19, 2023 · 2 comments · May be fixed by #559

Comments

@sorinpad
Copy link

sorinpad commented Oct 19, 2023

Description

Creation of a VM group is successful, subsequent runs do not try to modify the resource.

In practice, Terraform tries to update VM group with all but the first host in the host_anti_affined attribute.

Terraform and Provider version

Terraform: 1.3.9, 1.4.6, 1.5.7
Provider: 1.2.2, 1.3.1

Affected resources and data sources

opennebula_virtual_machine_group

Terraform configuration

resource "opennebula_virtual_machine_group" "random" {
  name        = "team-random-group"
  group       = "oneadmin"
  permissions = "642"

  role {
    name = "random"
    host_anti_affined = [
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-40"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-44"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-47"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-02"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-33"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-21"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-22"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-58"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-59"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-60"].id,
      module.hypervisor_prod.opennebula_cluster_hosts["random-host-61"].id,
    ]
  }
}

Expected behavior

The VM group gets created with a role called random which lists the 11 hosts in the anti_affined list.

Actual behavior

The VM Group gets created with a role called random which lists the 11 hosts in the anti_affined list, however, on subsequent runs, Terraform tries to add all but the last host to the anti_affined list.

Steps to Reproduce

Create a VM group:

  # opennebula_virtual_machine_group.random will be created
+ resource "opennebula_virtual_machine_group" "random" {
+       default_tags = (known after apply)
+       gid          = (known after apply)
+       gname        = (known after apply)
+       group        = "oneadmin"
+       id           = (known after apply)
+       name         = "team-random-group"
+       permissions  = "642"
+       tags_all     = (known after apply)
+       uid          = (known after apply)
+       uname        = (known after apply)

+       role {
+           host_affined      = (known after apply)
+           host_anti_affined = [
              + 22,
              + 21,
              + 20,
              + 32,
              + 28,
              + 30,
              + 31,
              + 23,
              + 2,
              + 3,
              + 16,
            ]
+           id                = (known after apply)
+           name              = "random"
+           policy            = (known after apply)
        }
    }
...
opennebula_virtual_machine_group.random: Creating...
opennebula_virtual_machine_group.random: Creation complete after 0s [id=18]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Run the plan again; Terraform wants to add all but the first host in the list:

  # opennebula_virtual_machine_group.random will be updated in-place
! resource "opennebula_virtual_machine_group" "random" {
        id           = "18"
        name         = "team-random-group"
        # (8 unchanged attributes hidden)

!       role {
!           host_anti_affined = [
              + 22,
              + 21,
              + 20,
              + 32,
              + 28,
              + 30,
              + 31,
              + 23,
              + 2,
              + 3,
                16,
            ]
            id                = 0
            name              = "random"
            # (1 unchanged attribute hidden)
        }
    }

Trying to apply the change fails (but that's on Nebula's API side), stating the group has some VMs attached:

╷
│ Error: Failed to update content
│ 
│   with opennebula_virtual_machine_group.random,
│   on vm_groups_team.tf line 100, in resource "opennebula_virtual_machine_group" "random":
│  100: resource "opennebula_virtual_machine_group" "random" {
│ 
│ VM group (ID: 11): OpenNebula error [INTERNAL]: [one.vmgroup.update] Cannot
│ update template. VM Group has 2 VMs
╵

We can see Nebula itself already has the hosts in the VM group:

$ onevmgroup show 18
VM GROUP 18 INFORMATION
ID             : 18
NAME           : team-random-group
USER           : oneadmin
GROUP          : oneadmin
LOCK           : None
PERMISSIONS

OWNER          : um-
GROUP          : u--
OTHER          : -m-

ROLES
ID   NAME     POLICY       AFFINED_HOSTS      ANTI_AFFINED_HOST  VIRTUAL_MACHINES
0    random                                   22,21,20,32,28,30,

TEMPLATE CONTENTS

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

Copy link

This issue is stale because it has been open for 30 days with no activity and it has not the 'status: confirmed' label or it is not in a milestone. Remove the 'status: stale' label or comment, or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2023
@frousselet frousselet reopened this Dec 20, 2023
@frousselet frousselet added this to the 1.4.1 milestone Jan 11, 2024
@treywelsh treywelsh self-assigned this Apr 18, 2024
@frousselet frousselet modified the milestones: 1.4.1, 1.4.2 May 30, 2024
@treywelsh treywelsh linked a pull request Jul 1, 2024 that will close this issue
7 tasks
@treywelsh
Copy link
Collaborator

Sorry for the late reply, it seems it was a small error in the code, feel free to test the fix in the PR I just created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants