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

replace - always return rc #71963

Merged
merged 3 commits into from
Feb 9, 2022
Merged

replace - always return rc #71963

merged 3 commits into from
Feb 9, 2022

Conversation

jscheible
Copy link
Contributor

@jscheible jscheible commented Sep 26, 2020

Error handling in playbooks generally expects rc to be set to 0 when a module has not failed. Playbook authors should not have to check for the existence of rc first.

SUMMARY

Added two lines to set res_args['rc'] = 0 before normal module.exit() calls.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

replace

ADDITIONAL INFORMATION

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. files Files category module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 26, 2020
@jborean93
Copy link
Contributor

I don't see the point in returning rc as this isn't calling any command to produce a reliable rc from. Ansible already has tests to check if a module failed or succeeded with these test plugins.

@jscheible
Copy link
Contributor Author

jscheible commented Sep 26, 2020 via email

@jscheible
Copy link
Contributor Author

jscheible commented Sep 26, 2020 via email

@jborean93
Copy link
Contributor

My point is that rc codes are not consistent in Ansible and not every module has them. Typically the ones that do are the ones that call a new process as it is reporting the rc that it reports. In this case this PR simply returns 0 but Ansible’s way of notifying a success is using the tests I mentioned.

1 similar comment
@jborean93
Copy link
Contributor

My point is that rc codes are not consistent in Ansible and not every module has them. Typically the ones that do are the ones that call a new process as it is reporting the rc that it reports. In this case this PR simply returns 0 but Ansible’s way of notifying a success is using the tests I mentioned.

@jscheible
Copy link
Contributor Author

jscheible commented Sep 26, 2020 via email

@jborean93
Copy link
Contributor

Ah I see now, I thought this PR added the rc value but it was already there. A better way would be to have rc=0 when the return dict is defined rather than setting to 0 in 2 places. That way the default is 0 and only changes when explicitly done so.

@jscheible
Copy link
Contributor Author

jscheible commented Sep 27, 2020 via email

@samdoran
Copy link
Contributor

👍 To adding rc: 0 to the res_args when it is defined. Please add a changelog and tests as well.

@samdoran samdoran changed the title Return rc=0 on success. replace - always return rc Sep 29, 2020
@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Sep 29, 2020
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 7, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pre_azp This PR was last tested before migration to Azure Pipelines. and removed core_review In order to be merged, this PR must follow the core review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Dec 10, 2020
jscheible and others added 2 commits February 10, 2022 05:57
Error handling in playbooks generally expects `rc` to be set to 0 when a module has not failed.  Playbook authors should not have to check for the existence of `rc` first.
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. pre_azp This PR was last tested before migration to Azure Pipelines. small_patch labels Feb 9, 2022
@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Feb 9, 2022
@jborean93 jborean93 merged commit d35bef6 into ansible:devel Feb 9, 2022
@ansible ansible locked and limited conversation to collaborators Feb 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. files Files category module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants