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

Solaris: Correct version check in svcadm_supports_sync API #73860

Merged
merged 1 commit into from
Apr 10, 2021

Conversation

guillermomolina
Copy link
Contributor

SUMMARY

This is a bug and a fix, the service module fails in Solaris, the way the comparison of the version is implemented in lib/ansible/modules/service.py:

def svcadm_supports_sync(self): # Support for synchronous restart/refresh is only supported on # Oracle Solaris >= 11.2 for line in open('/etc/release', 'r').readlines(): m = re.match(r'\s+Oracle Solaris (\d+\.\d+).*', line.rstrip()) if m and m.groups()[0] >= 11.2: return True

It compares the string "11.X" with the float 11.2 raising an exception.
I propose to convert it to a float and guard it for exception with:

def svcadm_supports_sync(self): # Support for synchronous restart/refresh is only supported on # Oracle Solaris >= 11.2 for line in open('/etc/release', 'r').readlines(): m = re.match(r'\s+Oracle Solaris (\d+\.\d+).*', line.rstrip()) try: if m and float(m.groups()[0]) >= 11.2: return True except: pass

This new code is tested ok in Solaris 11.4

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

service

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. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Mar 11, 2021
@ansibot
Copy link
Contributor

ansibot commented Mar 11, 2021

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/service.py:1362:12: bare-except: No exception type(s) specified

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/service.py:1362:13: E722: do not use bare 'except'

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed core_review In order to be merged, this PR must follow the core review workflow. ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 11, 2021
Copy link
Member

@mattclay mattclay left a comment

Choose a reason for hiding this comment

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

Several changes are needed here:

  1. Use LooseVersion to compare versions.
  2. Add tests.
  3. Add a changelog.

@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Mar 11, 2021
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Mar 11, 2021
@Akasurde Akasurde changed the title Fix expected float and got str Solaris: Correct version check in svcadm_supports_sync API Mar 15, 2021
Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

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

still needs changelog and tests

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. labels Mar 16, 2021
@guillermomolina
Copy link
Contributor Author

still needs changelog and tests

What do you mean by changelog? do you want me to add a file at ansible/changelogs/fragments ?

Could you point me where this the service module is tested to insert a test there

Thanks

@Akasurde
Copy link
Member

@guillermomolina Every PR requires a changelog. You can create it here. Take a look at the existing changelog entry to get an idea.

You can write tests here

@samdoran samdoran added the ci_verified Changes made in this PR are causing tests to fail. label Mar 19, 2021
@guillermomolina
Copy link
Contributor Author

Please give me hints on how to create the module test, everything I tried didn't work.

@Akasurde
Copy link
Member

Please give me hints on how to create the module test, everything I tried didn't work.

Give me some time I will try something and let you know. Thanks.

* Use correct version comparison in SunOS version check
* Added test
* Added changelog

Signed-off-by: Guillermo Adrian Molina <guillermoadrianmolina@hotmail.com>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. labels Mar 25, 2021
@Akasurde
Copy link
Member

@guillermomolina Could you please take a look at the test and let me know? Thanks.

@guillermomolina
Copy link
Contributor Author

@guillermomolina Could you please take a look at the test and let me know? Thanks.

@Akasurde Perfect, very well done, thanks.

@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Apr 6, 2021
@Akasurde
Copy link
Member

Akasurde commented Apr 9, 2021

@bcoca @mattclay Can you please review this? Thanks in advance.

@Akasurde

This comment has been minimized.

@Akasurde
Copy link
Member

Akasurde commented Apr 9, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Akasurde Akasurde merged commit 9c50603 into ansible:devel Apr 10, 2021
@Akasurde
Copy link
Member

@guillermomolina Thanks for the contribution.

@guillermomolina
Copy link
Contributor Author

@Akasurde you are welcome

@guillermomolina guillermomolina deleted the fix-solaris-service branch April 12, 2021 04:08
@froebela
Copy link

Hello,

we've just installed the new quarterly Solaris 11.4 SRU patchset 32. As part of that, Solaris has changed the standard Python interpreter /usr/bin/python from Python 2 to Python 3. As a result we now also face this issue with our Ansible version 2.9 running on Debian 10 and we assume many more Solaris customers will follow. Therefore we'd kindly request a backport for this fix to Ansible 2.9 and 2.10 as soon as possible.

Thanks and kind regards,

Andre Fröbel!

@Akasurde
Copy link
Member

@froebela Can you confirm if this fix works with 2.10?

FYI, Ansible 2.9 is only accepting security fixes.

@froebela
Copy link

@Akasurde We're a little bit afraid of getting newer Ansible major versions in an uncontrolled way, therefore we pin it. I'm in discussion with my colleagues in order to roll out version 2.10. After that we could test the fix.

@ansible ansible locked and limited conversation to collaborators May 8, 2021
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. has_issue module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. 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

7 participants