-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Conversation
The test
The test
|
There was a problem hiding this 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:
- Use LooseVersion to compare versions.
- Add tests.
- Add a changelog.
There was a problem hiding this 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
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 |
@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 |
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>
183e7dd
to
051e74d
Compare
@guillermomolina Could you please take a look at the test and let me know? Thanks. |
@Akasurde Perfect, very well done, thanks. |
This comment has been minimized.
This comment has been minimized.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@guillermomolina Thanks for the contribution. |
@Akasurde you are welcome |
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! |
@froebela Can you confirm if this fix works with 2.10? FYI, Ansible 2.9 is only accepting security fixes. |
@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. |
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
COMPONENT NAME
service
ADDITIONAL INFORMATION