-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed KeyError in logs when running a state that fails. (#615)
Co-authored-by: Megan Wilhite <[email protected]>
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed KeyError in logs when running a state that fails. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
def test_failing_sls(salt_master, salt_minion, salt_cli, caplog): | ||
""" | ||
Test when running state.sls and the state fails. | ||
When the master stores the job and attempts to send | ||
an event a KeyError was previously being logged. | ||
This test ensures we do not log an error when | ||
attempting to send an event about a failing state. | ||
""" | ||
statesls = """ | ||
test_state: | ||
test.fail_without_changes: | ||
- name: "bla" | ||
""" | ||
with salt_master.state_tree.base.temp_file("test_failure.sls", statesls): | ||
ret = salt_cli.run("state.sls", "test_failure", minion_tgt=salt_minion.id) | ||
for message in caplog.messages: | ||
assert "Event iteration failed with" not in message | ||
|
||
|
||
def test_failing_sls_compound(salt_master, salt_minion, salt_cli, caplog): | ||
""" | ||
Test when running state.sls in a compound command and the state fails. | ||
When the master stores the job and attempts to send | ||
an event a KeyError was previously being logged. | ||
This test ensures we do not log an error when | ||
attempting to send an event about a failing state. | ||
""" | ||
statesls = """ | ||
test_state: | ||
test.fail_without_changes: | ||
- name: "bla" | ||
""" | ||
with salt_master.state_tree.base.temp_file("test_failure.sls", statesls): | ||
ret = salt_cli.run( | ||
"state.sls,cmd.run", "test_failure,ls", minion_tgt=salt_minion.id | ||
) | ||
for message in caplog.messages: | ||
assert "Event iteration failed with" not in message |