vdombrovski opened a new issue, #7907:
URL: https://github.com/apache/cloudstack/issues/7907

   <!--
   Verify first that your issue/request is not already reported on GitHub.
   Also test if the latest release and main branch are affected too.
   Always add information AFTER of these HTML comments, but no need to delete 
the comments.
   -->
   
   ##### ISSUE TYPE
   <!-- Pick one below and delete the rest -->
    * Bug Report
   
   ##### COMPONENT NAME
   <!--
   Categorize the issue, e.g. API, VR, VPN, UI, etc.
   -->
   ~~~
   Core/Network
   ~~~
   
   ##### CLOUDSTACK VERSION
   <!--
   New line separated list of affected versions, commit ID for issues on main 
branch.
   -->
   
   ~~~
   4.17.2
   ~~~
   
   ##### CONFIGURATION
   <!--
   Information about the configuration if relevant, e.g. basic network, 
advanced networking, etc.  N/A otherwise
   -->
   N/A
   
   ##### OS / ENVIRONMENT
   <!--
   Information about the environment if relevant, N/A otherwise
   -->
   N/A
   
   ##### SUMMARY
   <!-- Explain the problem/feature briefly -->
   
   When creating 2 virtual machines in the same guest network at the exact same 
second (in our case 23 Aug 2023 13:34:11) with automatic IP assignment, both 
VMs can reserve a single IP address by race condition.
   
   ##### STEPS TO REPRODUCE
   <!--
   For bugs, show exactly how to reproduce the problem, using a minimal 
test-case. Use Screenshots if accurate.
   
   For new features, show how the feature would be used.
   -->
   
   With Terraform, create 2 VMs in the same Guest network
   
   ```
   resource "cloudstack_instance" "terraform_vm" {
     name =  "vm-created-using-terraform"
     service_offering = "Dynamic"
     template = "Debian 11"
     network_id = resource.cloudstack_network.testnet.id
     keypair = "[name_of_ssh_keypair]"
     details = {"cpuNumber" = 4,"memory" = 2048}
     expunge = "true"
     zone = "PA4"
   }
   
   resource "cloudstack_instance" "terraform_vm_2" {
     name =  "vm-created-using-terraform-2"
     service_offering = "Dynamic"
     template = "Debian 11"
     network_id = resource.cloudstack_network.testnet.id
     keypair = "[name_of_ssh_keypair]"
     details = {"cpuNumber" = 4,"memory" = 2048}
     expunge = "true"
     zone = "PA4"
   }
   ```
   
   Then apply the manifest several times (until the race condition triggers), 
and check their IPs
   
   <!-- You can also paste gist.github.com links for larger files -->
   
   ##### EXPECTED RESULTS
   <!-- What did you expect to happen when running the steps above? -->
   
   The IPs are always different
   
   ##### ACTUAL RESULTS
   <!-- What actually happened? -->
   
   In some iterations, here is what we saw (sensitive information redacted):
   
   
![acs_issue_race_condition](https://github.com/apache/cloudstack/assets/19999157/42647257-4946-4c17-9b4c-9827c8f02897)
   
   Both VMs have reserved the exact same IP, the same Zone and guest network
   
   Here is the relevant entries from the cloud database:
   
   ```
   > select * from nics where ip4_address='10.4.1.144' and state='Allocated' \G;
   *************************** 1. row ***************************
               id: 7225
             uuid: eab5163e-b88b-43a0-b6a3-ac02fd5a6037
      instance_id: 5471
      mac_address: 02:00:7c:99:00:19
      ip4_address: 10.4.1.144
          netmask: 255.255.255.0
          gateway: 10.4.1.1
          ip_type: Ip4
    broadcast_uri: NULL
       network_id: 627
             mode: Dhcp
            state: Allocated
         strategy: Start
    reserver_name: VxlanGuestNetworkGuru
   reservation_id: a3a9b296-e962-49f4-8c8f-3a3eef9128da
        device_id: 0
      update_time: 2023-08-23 15:34:11
    isolation_uri: NULL
      ip6_address: NULL
      default_nic: 1
          vm_type: User
          created: 2023-08-23 13:34:11
          removed: NULL
      ip6_gateway: NULL
         ip6_cidr: NULL
     secondary_ip: 0
      display_nic: 1
   *************************** 2. row ***************************
               id: 7227
             uuid: 49af630f-9075-40f3-ae95-3d5a28c19ec2
      instance_id: 5475
      mac_address: 02:00:6e:f1:00:1d
      ip4_address: 10.4.1.144
          netmask: 255.255.255.0
          gateway: 10.4.1.1
          ip_type: Ip4
    broadcast_uri: NULL
       network_id: 627
             mode: Dhcp
            state: Allocated
         strategy: Start
    reserver_name: VxlanGuestNetworkGuru
   reservation_id: 5dc0a9e8-b4c5-4f8e-a883-00178984c09a
        device_id: 0
      update_time: 2023-08-23 15:34:11
    isolation_uri: NULL
      ip6_address: NULL
      default_nic: 1
          vm_type: User
          created: 2023-08-23 13:34:11
          removed: NULL
      ip6_gateway: NULL
         ip6_cidr: NULL
     secondary_ip: 0
      display_nic: 1
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to