saltstack / saltstack/salt

Salt orchestrate fails when no cloud providers are configured

Open
#56,348 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed severity-low
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

What it says on the tin

Setup
docker run --rm -it waynew/salt-sprints:3000
mkdir -p /srv/salt/orch
cat << EOF >/srv/salt/orch/fnord.sls
salt-cloud-create:
  salt.parallel_runners:
  - runners:
      instance-cloud-create-runner-1:
      - name: cloud.create
      - kwarg:
          instances:
          - instance.cloud
          provider: ec2-provider
          availability_zone: us-west-2
          image: ami-04cf43aca3e6f3de3
          size: t3.small
          rename_on_destroy: true
          ssh_username: centos
EOF
Steps to Reproduce Issue
salt-call --local state.orchestrate orch.fnord

This blows up with:

local:
    ----------
    data:
        ----------
        kevin:
            ----------
            salt_|-salt-cloud-create_|-salt-cloud-create_|-parallel_runners:
                ----------
                __id__:
                    salt-cloud-create
                __run_num__:
                    0
                __sls__:
                    orch.fnord
                changes:
                    ----------
                comment:
                    An exception occurred in this state: Traceback (most recent call last):
                      File "/usr/lib/python3.6/site-packages/salt/state.py", line 1981, in call
                        **cdata['kwargs'])
                      File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1977, in wrapper
                        return f(*args, **kwargs)
                      File "/usr/lib/python3.6/site-packages/salt/states/saltmod.py", line 881, in parallel_runners
                        six.itervalues(outputs)]
                      File "/usr/lib/python3.6/site-packages/salt/states/saltmod.py", line 880, in <listcomp>
                        [out.get('outputter', '') == 'highstate' and 'data' in out for out in
                    AttributeError: 'bool' object has no attribute 'get'

That's because https://github.com/saltstack/salt/blob/v3000/salt/cloud/__init__.py#L403 says return False, which is not the kind of output that's expected - that code in saltmod requires out to be a dictionary.

Looking at the way saltmod is structured, probably the correct thing to do is account for False in the listcomp, and then again in https://github.com/saltstack/salt/blob/v3000/salt/states/saltmod.py#L904-L942

Though, it should also probably warn like suggested in this issue

Versions Report
salt-call --versions-report
Salt Version:
           Salt: 3000

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.11.1
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.8 (default, Aug  7 2019, 17:28:10)
   python-gnupg: Not Installed
         PyYAML: 5.3
          PyZMQ: 19.0.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: centos 7.6.1810 Core
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 4.19.76-linuxkit
         system: Linux
        version: CentOS Linux 7.6.1810 Core

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with salt-call --local state.orchestrate orch.fnord, then inspect the False return in salt/cloud/__init__.py and its handling in salt/states/saltmod.py. Trace parallel_runners through the referenced list comprehension and following lines; done means orchestration handles the no-provider result without an AttributeError and preserves the intended warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.