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 doesn't pass the "pool" parameter when cloning a VM #62521

Closed
pjcreath opened this issue Aug 23, 2022 · 2 comments · Fixed by #62559
Closed

[BUG] proxmox salt-cloud driver doesn't pass the "pool" parameter when cloning a VM #62521

pjcreath opened this issue Aug 23, 2022 · 2 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 fails to relay the "pool" parameter specified by the profile.

This causes cloning to fail for any user that does not have a global VM.Allocate permission (i.e. their permissions are restricted to their pool).

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

Steps to Reproduce the behavior
salt-cloud -p -l all ol8 testvm

Excerpt of debug log
...
[DEBUG   ] Sending event: tag = salt/cloud/testvm/requesting; data = {'kwargs': {'cores': 1, 'onboot': 1, 'name': 'testvm', 'pool': 'mypool', 'vmid': 105}, 'event': 'requesting instance', '_stamp': '2022-08-23T15:56:46.656308'}
[DEBUG   ] Closing IPCMessageClient instance
[DEBUG   ] Preparing to generate a node using these parameters: {'vmid': 105, 'onboot': 1, 'cores': 1, 'pool': 'mypool', 'name': 'testvm'} 
[DEBUG   ] post: https://pve:8006/api2/json/nodes/pve/qemu/200/clone ({'newid': 105, '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" 403 13
[ERROR   ] Error creating testvm on PROXMOX

The following exception was thrown when trying to run the initial deployment: 
403 Client Error: Permission check failed for url: https://pve:8006/api2/json/nodes/pve/qemu/200/clone
{"data":null}
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/cloud/clouds/proxmox.py", line 658, in create
    data = create_node(vm_, newid)
  File "/usr/lib/python3.6/site-packages/salt/cloud/clouds/proxmox.py", line 953, in create_node
    postParams,
  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: 403 Client Error: Permission check failed for url: https://pve:8006/api2/json/nodes/pve/qemu/200/clone
Error: There was a profile error: Failed to deploy VM

Expected behavior
Passing the specified pool in order to enable successful creation of the VM, e.g.:

[DEBUG   ] post: https://pve:8006/api2/json/nodes/pve/qemu/200/clone ({'newid': 105, 'pool': 'mypool', 'full': 0})

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 23, 2022
@pjcreath
Copy link
Contributor Author

Should I submit a new PR for this issue separately, or should I update pending PR # 62212 to include the fix and reference this issue?

@pjcreath
Copy link
Contributor Author

After getting past this issue, I ran into yet another bug in the proxmox driver. Is the best approach to do multiple issues/PRs, or multiples issues/single PR, since it's all related to the proxmox driver, or something else?

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