salt/state.py: set chunk['order'] = 0' with order: first'; fixes #24744

Currently the `order: first' keyword executes later states without order
options. Consider a test case such as:

```SaltStack
sleep 1:
  cmd.run:
    - order: first
sleep 2:
  cmd.run
sleep 3:
  cmd.run
sleep 4:
  cmd.run:
    - order: last
```

The contents of each chunk dictionary at runtime show that the 'first' state
is not evaluated to 'first'.

{'name': 'sleep 4', 'state': 'cmd', '__id__': 'sleep 4', 'fun': 'run', '__env__': 'base', '__sls__': u'test', 'order': 1010100}
{'name': 'sleep 2', 'state': 'cmd', '__id__': 'sleep 2', 'fun': 'run', '__env__': 'base', '__sls__': u'test', 'order': 10000}
{'name': 'sleep 3', 'state': 'cmd', '__id__': 'sleep 3', 'fun': 'run', '__env__': 'base', '__sls__': u'test', 'order': 10001}
{'name': 'sleep 1', 'state': 'cmd', '__id__': 'sleep 1', 'fun': 'run', '__env__': 'base', '__sls__': u'test', 'order': 10100}
This commit is contained in:
Jason Unovitch 2016-07-18 20:00:49 -04:00
parent 58021035a9
commit 64c850410f

View File

@ -512,6 +512,8 @@ class Compiler(object):
if not isinstance(chunk['order'], (int, float)):
if chunk['order'] == 'last':
chunk['order'] = cap + 1000000
elif chunk['order'] == 'first':
chunk['order'] = 0
else:
chunk['order'] = cap
if 'name_order' in chunk:
@ -1140,6 +1142,8 @@ class State(object):
if not isinstance(chunk['order'], (int, float)):
if chunk['order'] == 'last':
chunk['order'] = cap + 1000000
elif chunk['order'] == 'first':
chunk['order'] = 0
else:
chunk['order'] = cap
if 'name_order' in chunk: