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] proxmox salt-cloud driver fails to provision a cloned VM with a specified id #62558

Closed
pjcreath opened this issue Aug 29, 2022 · 0 comments · Fixed by #62559
Closed

[BUG] proxmox salt-cloud driver fails to provision a cloned VM with a specified id #62558

pjcreath opened this issue Aug 29, 2022 · 0 comments · Fixed by #62559
Labels
Bug broken, incorrect, or confusing behavior needs-triage Salt-Cloud

Comments

@pjcreath
Copy link
Contributor

Description
When attempting to clone a qemu VM on a Proxmox VE host, the salt-cloud proxmox driver uses the specified ID to clone the new VM, but uses the "next available" ID to bootstrap.

Since the next-available VM doesn't exist, bootstrapping fails.

Pull request with fix and tests to follow.

Setup

  • salt master (hostname "salt") is running in a container on the Proxmox host.
  • Proxmox (hostname "pve") is running on bare metal, on-premises.
/etc/salt/cloud.providers.d/proxmox.conf
proxmox:
  minion:
    master: salt
  user: mysaltuser@pve
  password: notreallythepassword
  url: pve
  driver: proxmox
/etc/salt/cloud.profiles.d/proxmox.conf
ol8:
  provider: proxmox
  pool: mypool
  technology: qemu
  image: ''  # work around bug in salt
  clone: True
  clone_full: 0
  clone_from: 200
  host: pve
  onboot: 1
  pubkey: mypubkey
  cores: 1
cloud.map
ol8:
  - testvm:
      vmid: 300

Steps to Reproduce the behavior
salt-cloud -l all -m cloud.map testvm

Excerpt of debug log
...
[DEBUG   ] post: https://pve:8006/api2/json/nodes/pve/qemu/200/clone ({'newid': 300, 'pool': 'mypool', 'full': 0})
[DEBUG   ] Starting new HTTPS connection (1): pve:8006
[DEBUG   ] https://pve:8006 "POST /api2/json/nodes/pve/qemu/200/clone HTTP/1.1" 200 75
[DEBUG   ] Using IP address 10.10.10.10
[DEBUG   ] Getting creation status for upid: UPID:pve:00112233:44556677:8899AABB:qmclone:200:mysaltuser@pve:
[DEBUG   ] get: https://pve:8006/api2/json/cluster/tasks (None)
[DEBUG   ] Starting new HTTPS connection (1): pve:8006
[DEBUG   ] https://pve:8006 "GET /api2/json/cluster/tasks HTTP/1.1" 200 426
[DEBUG   ] Found upid task: {'id': '200', 'type': 'qmclone', 'user': 'mysaltuser@pve', 'node': 'pve', 'pid': 701325, 'upid': 'UPID:pve:00112233:44556677:8899AABB:qmclone:200:mysaltuser@pve:', 'starttime': 1661797302}
[DEBUG   ] Getting creation status for upid: UPID:pve:00112233:44556677:8899AABB:qmclone:200:mysaltuser@pve:
[DEBUG   ] get: https://pve:8006/api2/json/cluster/tasks (None)
[DEBUG   ] Starting new HTTPS connection (1): pve:8006
[DEBUG   ] https://pve:8006 "GET /api2/json/cluster/tasks HTTP/1.1" 200 432
[DEBUG   ] Found upid task: {'node': 'pve', 'starttime': 1661797302, 'status': 'OK', 'saved': 1, 'type': 'qmclone', 'user': 'mysaltuser@pve', 'endtime': 1661797303, 'upid': 'UPID:pve:00112233:44556677:8899AABB:qmclone:200:mysaltuser@pve:', 'id': '200'}
[DEBUG   ] Host has been created!
[INFO    ] Configuring cloned VM
[DEBUG   ] get: https://pve:8006/api2/json/nodes/pve/qemu/110/config (None)
[DEBUG   ] Starting new HTTPS connection (1): pve:8006
[DEBUG   ] https://pve:8006 "GET /api2/json/nodes/pve/qemu/110/config HTTP/1.1" 500 13
[ERROR   ] There was a query error: 500 Server Error: Configuration file 'nodes/pve/qemu-server/110.conf' does not exist for url: https://pve:8006/api2/json/nodes/pve/qemu/110/config
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/cloud/cli.py", line 319, in run
    ret = mapper.run_map(dmap)
  File "/usr/lib/python3.6/site-packages/salt/cloud/__init__.py", line 2196, in run_map
    output[name] = self.create(profile, local_master=local_master)
  File "/usr/lib/python3.6/site-packages/salt/cloud/__init__.py", line 1226, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/cloud/clouds/proxmox.py", line 703, in create
    _reconfigure_clone(vm_, vmid)
  File "/usr/lib/python3.6/site-packages/salt/cloud/clouds/proxmox.py", line 583, in _reconfigure_clone
    data = query("get", "nodes/{}/qemu/{}/config".format(vm_["host"], vmid))
  File "/usr/lib/python3.6/site-packages/salt/cloud/clouds/proxmox.py", line 195, in query
    response.raise_for_status()
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Configuration file 'nodes/pve/qemu-server/110.conf' does not exist for url: https://pve:8006/api2/json/nodes/pve/qemu/110/config

Expected behavior
Configuring the proper VM ID in order to enable successful creation of the VM, e.g.:

[DEBUG   ] get: https://pve:8006/api2/json/nodes/pve/qemu/300/config (None)

Versions Report

salt --versions-report
Salt Version:
          Salt: 3004.1
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Apr 11 2022, 08:25:52)
  python-gnupg: 0.4.6
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: oracle 8.6 
        locale: UTF-8
       machine: x86_64
       release: 5.15.35-3-pve
        system: Linux
       version: Oracle Linux Server 8.6  
@pjcreath pjcreath added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 29, 2022
pjcreath added a commit to pjcreath/salt that referenced this issue Aug 30, 2022
Ch3LL pushed a commit that referenced this issue Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage Salt-Cloud
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants