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] libcloud_storage file_present state returns HTTP 400, module works fine #62074

Closed
1 task done
OliElli opened this issue May 17, 2022 · 2 comments · Fixed by #62075
Closed
1 task done

[BUG] libcloud_storage file_present state returns HTTP 400, module works fine #62074

OliElli opened this issue May 17, 2022 · 2 comments · Fixed by #62075
Labels
Bug broken, incorrect, or confusing behavior needs-triage Salt-Cloud

Comments

@OliElli
Copy link

OliElli commented May 17, 2022

Description
The libcloud_storage state uses the args in the wrong order, leading to a HTTP 400 from the provider. The module works fine.

Setup

Local minion config:

libcloud_storage:
  profile_azure:
    driver: azure_blobs
    key: mykey
    secret: supersecretfromAzure

State:

Download latest backup from Azure Blob Storage:
  libcloud_storage.file_present:
    - container: mycontainer
    - name: myexamplefile.tar
    - path: /tmp/myexamplefile.tar
    - profile: profile_azure
  • on-prem machine

Steps to Reproduce the behavior
state.apply with an appropriate Azure blob sotrage setup with test container and file created.

Expected behavior
The file is downloaded to the local machine per the state configuration

Actual behaviour

[olielli@test-salt-master ~]$ sudo salt my-test-host state.apply -l quiet --state-verbose=false
my-test-host:
----------
          ID: Download latest backup from Azure Blob Storage
    Function: libcloud_storage.file_present
        Name: myexamplefile.tar
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.6/site-packages/salt/state.py", line 2180, in call
                  *cdata["args"], **cdata["kwargs"]
                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/loader/lazy.py", line 1249, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/states/libcloud_storage.py", line 191, in file_present
                  path, container, name, profile, overwrite_existing
                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/modules/libcloud_storage.py", line 282, in download_object
                  obj = conn.get_object(container_name, object_name)
                File "/usr/local/lib/python3.6/site-packages/libcloud/storage/drivers/azure_blobs.py", line 531, in get_object
                  container = self.get_container(container_name=container_name)
                File "/usr/local/lib/python3.6/site-packages/libcloud/storage/drivers/azure_blobs.py", line 521, in get_container
                  "Unexpected status code: %s" % (response.status), driver=self
              libcloud.common.types.LibcloudError: <LibcloudError in <libcloud.storage.drivers.azure_blobs.AzureBlobsStorageDriver object at 0x7efed6eee710> 'Unexpected status code: 400'>
     Started: 12:47:04.235824
    Duration: 271.885 ms
     Changes:

Summary for my-test-host
-------------
Succeeded: 10
Failed:     1
-------------
Total states run:     11
Total run time:    6.812 s
ERROR: Minions returned with non-zero exit code

I will create a PR with the fix (re-ordering the arguments in the state code)

Versions Report

Salt Version:
          Salt: 3004.1

Dependency Versions:
          cffi: 1.11.5
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: 4.0.1
     gitpython: 3.0.9
        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: 2.14
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov  9 2021, 14:44:26)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: 3.0.1
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: rocky 8.5 Green Obsidian
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-348.12.2.el8_5.x86_64
        system: Linux
       version: Rocky Linux 8.5 Green Obsidian
@OliElli OliElli added Bug broken, incorrect, or confusing behavior needs-triage labels May 17, 2022
@welcome
Copy link

welcome bot commented May 17, 2022

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@OliElli OliElli changed the title [BUG] [BUG] libcloud_storage file_present state returns HTTP 400, module works fine May 17, 2022
@OliElli
Copy link
Author

OliElli commented May 19, 2022

Useful workaround to force the state to work is to intentionally configure the state with the wrong key/value pairs as follows:

    - path: {{ container }}
    - container: {{ name }}
    - name: {{ path }}

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