saltstack / saltstack/salt

Running salt-cloud within orchestration always reports success

Open
#50,939 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description of Issue/Question

When running cloud functions within orchestrate, orchestrate can't catch failures correctly.

The issue is that these lines in salt/states/saltmod.py work most of the time:
if isinstance(runner_return, dict) and 'Error' in runner_return:
out['success'] = False

These stop working when the return dict element is itself a dictionary, like this line in my example:

[INFO ] {u'return': {u'servername': {u'Error': u'servername already exists under mh-vmware:vmware'}}}

Setup

#Spins up a new host taking the last octet of the IP as an argument
'provision_single_host':
salt.runner:
- name: cloud.profile
- prof: single_server
- instances:
- servername{{pillar.ip}}
- vm_overrides:
devices:
network:
Network adapter 1:
name: VL1011_TestNet1
switch_type: standard
adapter_type: vmxnet3
ip: ip{{pillar.ip}}
gateway: [gateway]
subnet_mask: 255.255.255.0

Steps to Reproduce Issue

The easiest way to reproduce this is to have an orchestration that creates a new server when that server already exists

sudo salt-run state.orchestrate orchestrate.test_single_server pillar='{"ip": "200"}' saltenv=*testenv* -l info
[INFO    ] Loading fresh modules for state activity
[INFO    ] Fetching file from saltenv '*testenv*', ** done ** 'orchestrate/test_single_server.sls'
[INFO    ] Running state [cloud.profile] at time 11:43:51.146055
[INFO    ] Executing state salt.runner for [cloud.profile]
[ERROR   ] *servername* already exists under mh-vmware:vmware
[INFO    ] Runner completed: 20181220114351486434
[INFO    ] {u'return': {u'*servername*': {u'Error': u'*servername* already exists under mh-vmware:vmware'}}}
[INFO    ] Completed state [cloud.profile] at time 11:43:52.064214 (duration_in_ms=918.16)
*saltmaster*:
----------
          ID: provision_single_host
    Function: salt.runner
        Name: cloud.profile
      Result: True
     Comment: Runner function 'cloud.profile' executed.
     Started: 11:43:51.146054
    Duration: 918.16 ms
     Changes:
              ----------
              return:
                  ----------
                  *servername*:
                      ----------
                      Error:
                          *servername* already exists under mh-vmware:vmware

Summary for *saltmaster*
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 918.160 ms
[INFO    ] Runner completed: 20181220114347984639
Versions Report

salt --versions-report
Salt Version:
Salt: 2018.3.0

Dependency Versions:
cffi: 1.11.2
cherrypy: unknown
dateutil: Not Installed
docker-py: Not Installed
gitdb: 0.6.4
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: 0.26.3
libnacl: Not Installed
M2Crypto: 0.28.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.1
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.26.4
Python: 2.7.5 (default, Apr 11 2018, 07:36:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4

System Versions:
dist: centos 7.5.1804 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-862.3.2.el7.x86_64
system: Linux
version: CentOS Linux 7.5.1804 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

Start in salt/states/saltmod.py, focusing on how the salt.runner state evaluates the runner return, then run the provided salt-run state.orchestrate reproduction. Done means an Error nested inside the cloud.profile return is recognized as a failure instead of reporting Result: True.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.