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

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

Merged
merged 1 commit into from
Jul 20, 2016

Conversation

junovitch
Copy link
Contributor

@junovitch junovitch commented Jul 20, 2016

What does this PR do?

Fixes behavior of 'order: first' (explain in further detail in the commit message and below)

What issues does this PR fix or reference?

#24744 and the later (closed) #26278

Previous Behavior

Explained in commit message.

New Behavior

First goes first :)

Tests written?

No. Tested manually before removing the debug logging and committing.

Commit Message

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

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

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}

…ltstack#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}
@junovitch
Copy link
Contributor Author

Open against 2015.8 per @cachedout in #34769. Should be a clean merge forward to 2016.3 and develop.

@cachedout
Copy link
Contributor

Thanks very much, @junovitch

@anlutro
Copy link
Contributor

anlutro commented Jul 22, 2016

If I already have states with order: 0, will those be ran before or after order: first?

What if I have states with a negative integer as the order?

@junovitch
Copy link
Contributor Author

junovitch commented Jul 28, 2016

If I already have states with order: 0, will those be ran before or after order: first?

See https://docs.saltstack.com/en/2015.8/ref/states/compiler_ordering.html#lexicographical-fall-back

What if I have states with a negative integer as the order?

Based off https://docs.saltstack.com/en/2015.8/ref/states/compiler_ordering.html#the-order-flag that suggest that 'order: last' and 'order: -1' are synonymous with each other. I haven't verified the code actually does what the documentation says so I don't know the impact of other negative numbers and if they are just treated as 'last'.

@junovitch junovitch deleted the issue_24744 branch August 28, 2016 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants