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

added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED #6534

Merged
merged 5 commits into from
May 22, 2023

Conversation

tover99
Copy link
Contributor

@tover99 tover99 commented May 19, 2023

added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

SUMMARY

This code was not treated at all by the module and therefore considered a faillure and the changed status was never set.

After my fix the exitcode 102 will be treated exactly like 0 by the module internally, and the changed status will be reported correctly.

However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "register" and a "failed_when" property to pass as OK in this event.

Example:

  tasks:
    - name: Apply patches on OpenSUSE/SUSE Linux
      zypper:
        name: '*'
        state: latest
        type: patch
        extra_args_precommand: '--non-interactive-include-reboot-patches'
      register: zypper_cmd
      failed_when: zypper_cmd.rc not in [0, 102]

    - name: Reboot the SUSE/OpenSUSE box if kernel updated
      reboot:
        msg: "Reboot initiated by Ansible for kernel updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 10
        post_reboot_delay: 30
        test_command: uptime
      when: zypper_cmd.rc == 102

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

zypper

ADDITIONAL INFORMATION

When used to do updates of the type "patch" the zypper module failed in case the updates were successfull, but resulted in the system needing a reboot. In that case the changed status was not correctly set. After my fix the task will still be treated a faillure by ansible unless you treat the rc 102 in a failed_when statement as shown above, but the changed state will be correctly set.

…- Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels May 19, 2023
@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label May 19, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 labels May 19, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Could you please add a changelog fragment? Thanks.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label May 20, 2023
@commel
Copy link

commel commented May 20, 2023

Looks great to me! Thank you for your contribution. Could you please add some static variable names for the return value codes? At this stage it still seems manageable.

Co-authored-by: Alex <[email protected]>
@felixfontein
Copy link
Collaborator

I'll merge this by tomorrow morning if nobody objects (so it can make it into tomorrow's releases). Moving the literals to constants can be done in a follow-up PR.

@commel
Copy link

commel commented May 21, 2023

I'll merge this by tomorrow morning if nobody objects (so it can make it into tomorrow's releases). Moving the literals to constants can be done in a follow-up PR.

I'm good with that!

@felixfontein felixfontein merged commit a9fd9f8 into ansible-collections:main May 22, 2023
@patchback
Copy link

patchback bot commented May 22, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/a9fd9f8982a1f2ff7de3939bb885c9a7d8174439/pr-6534

Backported as #6559

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request May 22, 2023
…6534)

* added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.

* removed trailing whitespaces

* added changelogs fragment

* Fix typo.

Co-authored-by: Alex <[email protected]>

* Add URL.

---------

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Alex <[email protected]>
(cherry picked from commit a9fd9f8)
@patchback
Copy link

patchback bot commented May 22, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/a9fd9f8982a1f2ff7de3939bb885c9a7d8174439/pr-6534

Backported as #6560

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request May 22, 2023
…6534)

* added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.

* removed trailing whitespaces

* added changelogs fragment

* Fix typo.

Co-authored-by: Alex <[email protected]>

* Add URL.

---------

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Alex <[email protected]>
(cherry picked from commit a9fd9f8)
@felixfontein
Copy link
Collaborator

@tover99 thanks for fixing this!
@commel @alxgu thanks for reviewing!

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label May 22, 2023
felixfontein pushed a commit that referenced this pull request May 22, 2023
…ode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6559)

added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6534)

* added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.

* removed trailing whitespaces

* added changelogs fragment

* Fix typo.

Co-authored-by: Alex <[email protected]>

* Add URL.

---------

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Alex <[email protected]>
(cherry picked from commit a9fd9f8)

Co-authored-by: tover99 <[email protected]>
felixfontein pushed a commit that referenced this pull request May 22, 2023
…ode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6560)

added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED (#6534)

* added handling of zypper exitcode 102: ZYPPER_EXIT_INF_REBOOT_NEEDED - Returned after a successful installation of a patch which requires reboot of computer.

The exitcode 102 will be treated exactly like 0 by the module internally now, and the changed status will be reported correctly. However, since I preserve the rc 102 in the retvals to allow the playbook to react to the requested reboot, the task must still include a "failed_when: zypper_cmd.rc not in [0, 102]" to not fail in this case.

* removed trailing whitespaces

* added changelogs fragment

* Fix typo.

Co-authored-by: Alex <[email protected]>

* Add URL.

---------

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Alex <[email protected]>
(cherry picked from commit a9fd9f8)

Co-authored-by: tover99 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants