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

Schedule advanced success check #40

Merged
merged 3 commits into from
Jul 8, 2023
Merged

Conversation

kpetremann
Copy link
Owner

Due to a Salt inconsistency, a failing scheduled job can report to be successful.

For a Scheduled Job, sometimes a failing jobs can have either:

  • retcode=0
  • success=True
  • no retcode defined in each function of the state

The most precise way to know the real status is to parse the "result" field in Event.Return, meaning get the "result" boolean provided in each function of the state.

For example, if we have the given state:

  dummy test:
    test.nop:
      - name: "nop"

  success:
    test.succeed_with_changes:
      - name: "success"

  failed:
    test.fail_with_changes:
      - name: "failed"

We get the "result", which is a boolean, for the dummy test, success and failed. If one of them returns "false", we consider the state failed.

This will mainly be useful for state triggered by a scheduler.

Salt behavior for a state executed by a scheduler:
- success=true as Salt considers it successfully got the state result
- inconsitency: sometimes the global retcode is equal to 0 even if one
  function of the state failed

So, to better know the success of a state executed by a scheduler, we
will look for "result" in the "return" field, and use them to generate
the global success of the state.

This is only applied on the scheduler, as this issue does not seem to be
present when states are executed directly.
This is due to a Salt inconsistency.

For a Scheduled Job, sometimes a failing jobs can have either:
- retcode=0
- success=True
- no retcode defined in each function of the state

The most precise way to know the real status is to parse the "result"
field in Event.Return, meaning get the "result" boolean provided in each
function of the state.

For example, if we have the given state:
  dummy test:
    test.nop:
      - name: "nop"

  success:
    test.succeed_with_changes:
      - name: "success"

  failed:
    test.fail_with_changes:
      - name: "failed"

We get the "result", which is a boolean, for the dummy test, success and
failed. If one of them is returns "false", we consider the state failed.
@kpetremann kpetremann merged commit 91474a2 into main Jul 8, 2023
2 checks passed
@kpetremann kpetremann deleted the schedule_advanced_success_check branch July 8, 2023 14:55
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

1 participant