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

[BUG] Creating container (LXC) succeeds but provider reports HTTP error and taints the created resource #40

Open
fabacab opened this issue Sep 9, 2020 · 0 comments

Comments

@fabacab
Copy link

fabacab commented Sep 9, 2020

Briefly, context: I'm just getting familiar with this provider. Apologies in advance if I've made a silly mistake. That said, here's what's happening:

I'd like to create a simple container using an existing template. Creating a proxmox_virtual_environment_vm resource is simple enough, and works without issue so far. But an equally simple container creation attempt fails with the following sample error output:

proxmox_virtual_environment_container.testcontainer: Still creating... [30s elapsed]

Error: Received an HTTP 500 response - Reason: can't lock file '/run/lock/lxc/pve-config-105.lock' - got timeout

  on proxmox.tf line 21, in resource "proxmox_virtual_environment_container" "testcontainer":
  21: resource "proxmox_virtual_environment_container" "testcontainer" {

Details below.

To Reproduce

  1. Set up a single-node Proxmox VE cluster running the current stable Proxmox VE version (6.2-11 at time of this writing), and install the current stable release of this Terraform Provider (0.3.0 at time of this writing), with Terraform 0.13.2, the latest stable version of Terraform at this writing.
  2. Create an example container template in Proxmox either via the command line or the Proxmox VE Web GUI. For example:
    1. Click on the local Proxmox VE storage pool.
    2. Click on the "Templates" button to open the Container Template selection dialogue window.
    3. Search for a template by typing something like wordpress in the filter box. This will result in one container called turnkey-wordpress in the list of available container templates.
    4. Click the "Download" button to download the container template and save it to your local storage pool as an available container template for use in your cluster.
  3. Write a bare-bones Terraform configuration such as the following, changing the appropriate authentication variables (shown as CHANGE_ME in the example below) as needed for your cluster:
    provider "proxmox" {
      virtual_environment {
        endpoint = "https://CHANGE_ME:8006"
        username = "root@pam"
        password = "CHANGE_ME"
        insecure = true
      }
    }
    
    data "proxmox_virtual_environment_nodes" "pve_nodes" {}
    
    resource "proxmox_virtual_environment_container" "testcontainer" {
      description = "Test container"
      node_name   = data.proxmox_virtual_environment_nodes.pve_nodes.names[0]
      operating_system {
        # Use the Proxmox Containter Template downloaded as described earlier:
        template_file_id = "local:vztmpl/debian-10-turnkey-wordpress_16.0-1_amd64.tar.gz"
      }
    }
  4. Apply this configuration with terraform apply and observe the error appear in the terminal output. Sample output is shown here:
    $ terraform apply
    data.proxmox_virtual_environment_nodes.pve_nodes: Refreshing state... [id=nodes]
    
    An execution plan has been generated and is shown below.
    Resource actions are indicated with the following symbols:
      + create
    
    Terraform will perform the following actions:
    
      # proxmox_virtual_environment_container.testcontainer will be created
      + resource "proxmox_virtual_environment_container" "testcontainer" {
          + description = "Test container"
          + id          = (known after apply)
          + node_name   = "proxmox-ve"
          + started     = true
          + template    = false
          + vm_id       = -1
    
          + operating_system {
              + template_file_id = "local:vztmpl/debian-10-turnkey-wordpress_16.0-1_amd64.tar.gz"
              + type             = "unmanaged"
            }
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    
    Do you want to perform these actions?
      Terraform will perform the actions described above.
      Only 'yes' will be accepted to approve.
    
      Enter a value: yes
    
    proxmox_virtual_environment_container.testcontainer: Creating...
    proxmox_virtual_environment_container.testcontainer: Still creating... [10s elapsed]
    proxmox_virtual_environment_container.testcontainer: Still creating... [20s elapsed]
    proxmox_virtual_environment_container.testcontainer: Still creating... [30s elapsed]
    proxmox_virtual_environment_container.testcontainer: Still creating... [40s elapsed]
    
    Error: Received an HTTP 500 response - Reason: can't lock file '/run/lock/lxc/pve-config-105.lock' - got timeout
    
      on proxmox.tf line 3, in resource "proxmox_virtual_environment_container" "testcontainer":
       3: resource "proxmox_virtual_environment_container" "testcontainer" {
    
  5. Visit the Proxmox VE Web GUI and note the container was created successfully and seems to function normally.

Expected behavior

Expected Terraform to report successful creation of the container, not a timeout.

Additional context

I have tried a number of things to ensure I'm not mistakenly reporting a bug, including:

  • Manually deleting the lock file reported in the error (/run/lock/lxc/pve-config-105.lock). Of course, note that 105 is the Proxmox guest ID and might be different on your system.
  • Rebooting the Proxmox VE node.
  • Using a different container template.

Also, as the Terraform plan is being applied, the GUI updates in exactly the way you would expect. This is the order of events I've observed in exact progression when I run terraform apply with the above configuration:

  1. First, Terraform plan is run.
  2. As the Terraform plan is being applied, proxmox_virtual_environment_container.testcontainer: Creating... appears, and within a second the Proxmox VE Web GUI shows a new container guest.
  3. As the container guest appears on the Proxmox VE Web GUI, a lock icon shows up on it. This is to be expected, as the guest is in the creating state; a right-click on the container guest in the Proxmox VE Web GUI shows "(config locked)" in the contextual menu.
  4. Terraform reports waiting on container creation with proxmox_virtual_environment_container.testcontainer: Still creating... [20s elapsed]
  5. Back in the Proxmox VE Web GUI, the lock disappears off the container guest's icon in the Proxmox VE Web GUI Server View sidebar.
  6. Terraform continues to report waiting on container creation with, e.g., proxmox_virtual_environment_container.testcontainer: Still creating... [30s elapsed] and continues until it reports the error, even though it's clear the resource no longer appears locked from the perspective of the Web GUI.

I hope this helps.

I'm a big fan of Proxmox VE and Terraform generally, and yours is the best Terraform Provider for Proxmox that I've seen so far. I wish I was a more skilled Go programmer than I am, but if this is the project that ultimately gets me to take on learning another language, I'd be thrilled. Please let me know how I can be helpful.

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

No branches or pull requests

1 participant