saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.11k stars 5.47k forks source link

[BUG] OpenNebula VM Create Fails #64577

Open KarlAustin opened 1 year ago

KarlAustin commented 1 year ago

Description Creating an OpenNebula VM fails with an error:

[ERROR   ] Failed to create VM hostname.example.org. Configuration value '__utils__' needs to be set
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/salt/cloud/__init__.py", line 1226, in create
    output = self.clouds[func](vm_)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/cloud/clouds/opennebula.py", line 1080, in create
    data = __utils__["cloud.wait_for_ip"](
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/utils/cloud.py", line 2616, in wait_for_ip
    data = update_callback(*update_args, **update_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/salt/cloud/clouds/opennebula.py", line 1070, in __query_node_data
    node_data = show_instance(vm_name, call="action")
  File "/usr/local/lib/python3.10/dist-packages/salt/cloud/clouds/opennebula.py", line 1898, in show_instance
    __utils__["cloud.cache_node"](node, _get_active_provider_name(), __opts__)
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/context.py", line 78, in __getitem__
    return self.value()[item]
  File "/usr/local/lib/python3.10/dist-packages/salt/loader/context.py", line 72, in value
    return loader.pack[self.name]
KeyError: '__utils__'

Setup (Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

Steps to Reproduce the behavior /usr/local/bin/salt-run' 'cloud.map_run' 'map_data={"one-ubuntu-profile":[{"hostname.example.org":{"cpu":1,"vcpu":1,"memory":512}}]}'

Expected behavior The VM is created.

Versions Report

salt --versions-report ```yaml Salt Version: Salt: 3005.1 Dependency Versions: cffi: 1.15.1 cherrypy: Not Installed dateutil: 2.8.2 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.2 libgit2: Not Installed M2Crypto: Not Installed Mako: 1.2.4 msgpack: 1.0.5 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.17 pygit2: Not Installed Python: 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] python-gnupg: Not Installed PyYAML: 6.0 PyZMQ: 20.0.0 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.3 System Versions: dist: ubuntu 22.04 Jammy Jellyfish locale: utf-8 machine: x86_64 release: 5.15.0-75-generic system: Linux version: Ubuntu 22.04 Jammy Jellyfish ```

Additional context Referenced a couple of years ago here: https://github.com/saltstack/salt/issues/60239#issuecomment-957801409

Fix The fix is to change: https://github.com/saltstack/salt/blob/2d02017d6c8e2b950eec959ba25ffe62f72214e3/salt/cloud/clouds/opennebula.py#L1080 From: data = __utils__["cloud.wait_for_ip"]( to data = salt.utils.cloud.wait_for_ip(

I've tested this out dozens of times whilst adding the vm_disk_resize feature.

s0undt3ch commented 1 year ago

Is this still an issue just for 3005.1 or is it also present in 3006.1?

KarlAustin commented 1 year ago

Yes it was still present in 3006.1 as well as I had to update for something else yesterday evening:

Salt Version:
          Salt: 3006.1

Python Version:
        Python: 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]

Dependency Versions:
          cffi: 1.15.1
      cherrypy: Not Installed
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: Not Installed
  looseversion: 1.2.0
      M2Crypto: Not Installed
          Mako: 1.2.4
       msgpack: 1.0.5
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.18.0
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 6.0
         PyZMQ: 25.0.2
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: ubuntu 22.04.2 jammy
        locale: utf-8
       machine: x86_64
       release: 5.15.0-75-generic
        system: Linux
       version: Ubuntu 22.04.2 jammy

PR is in and accepted for it though.