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

[BUG][RHEL8] systemd service should not use python3 #2728

Closed
Klaas- opened this issue Jan 17, 2023 · 13 comments
Closed

[BUG][RHEL8] systemd service should not use python3 #2728

Klaas- opened this issue Jan 17, 2023 · 13 comments

Comments

@Klaas-
Copy link

Klaas- commented Jan 17, 2023

Describe the bug: A clear and concise description of what the bug is.
Hi,
it seems on systems where python3 is not pointing to the same python version as platform-python waagent fails to start. This happens because you try to directly use python3 in the systemd service file.

  1. Section of the log where the error occurs.
Traceback (most recent call last):
  File "/usr/sbin/waagent", line 35, in <module>
    import azurelinuxagent.agent as agent
ModuleNotFoundError: No module named 'azurelinuxagent'
  1. Steps to reproduce the behavior.
    I'd guess this happens on any rhel8 system where /usr/bin/python3 is not pointing to python 3.6 (platform-python)

Distro and WALinuxAgent details (please complete the following information):

  • Distro and Version: Red Hat Enterprise Linux release 8.7 (Ootpa)
  • WALinuxAgent version
WALinuxAgent-2.7.0.6 running on redhat 8.7
Python: 3.6.8
Goal state agent: 2.8.0.11
$ python3 --version
Python 3.9.13

Additional context
Workaround: Create an override for the waagent.service file, something like this:

# /etc/systemd/system/waagent.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/libexec/platform-python -u /usr/sbin/waagent -daemon

This happens because WALinuxAgent uses platform-python (3.6 on RHEL8).

head -n1 /usr/sbin/waagent
#!/usr/libexec/platform-python

I am guessing you could also change it to start /usr/sbin/waagent directly, without python, then it will work as well because /usr/sbin/waagent has the correct shebang and is executable

Klaas- added a commit to Klaas-/WALinuxAgent that referenced this issue Jan 17, 2023
@narrieta
Copy link
Member

@Klaas- Installation of Python and the setup in the service file are done by the publisher of the image. If this is the standard image coming published by Red Hat, could you report the issue on their site? At some point they were using the platform Python, but there were some issues and they changed that after 1 release (AFAIK).

@Klaas-
Copy link
Author

Klaas- commented Jan 19, 2023

@narrieta yeah, but it's your file that is creating the issues and easily fixed by my PR #2729 - then it'll trickle down into RHEL, I'll create a backport request once it's merged here. About which python version rhel uses, the beauty is I don't care :D Look at the PR, there is no need to specify which python in the service file, as long as the shebang is correct that service file will work.

@Klaas-
Copy link
Author

Klaas- commented Feb 15, 2023

@narrieta any progress here? :)

@narrieta
Copy link
Member

@Klaas- As previously mentioned, the Python setup is done by the image publisher. I left your PR open in case in the future we find time to test it and see if we should merge it.

@Klaas-
Copy link
Author

Klaas- commented Feb 15, 2023

but that is the whole point, you supply a systemd service that specifies which python is used, red hat uses that file as is, but you could be leaving the python selection up to the image publisher, which is what the PR introduces

@narrieta
Copy link
Member

@Klaas- yes, thank you for your contribution. we'll consider it at a later time

@Klaas-
Copy link
Author

Klaas- commented Mar 3, 2023

@narrieta
Copy link
Member

Closing this issue. Image publishers adapt the service files as best suited to their image.

@Klaas-
Copy link
Author

Klaas- commented Mar 22, 2023

@narrieta I still think you should give a good example upstream :)

@narrieta
Copy link
Member

@Klaas- thanks for pointing this out. I took a look at the service files of the distros we tests and there are several differences between them. There is really not a "good example", it's up to the distro owner to set this up. Ideally we would like the different customizations of the agent to be submitted upstream, but that does not always happen.

@Klaas-
Copy link
Author

Klaas- commented Mar 22, 2023

@narrieta rhel 8.8 will use the suggestion from my PR, so I am guessing you can consider that PR rhel upstreaming their changes :)

@narrieta
Copy link
Member

@Klaas- Thanks for letting me know. We'll consider that when we do some work on this area. RHEL 8.8 is only 1 of 100+ distros/versions where the agent is used, but it is a good start.

@Klaas-
Copy link
Author

Klaas- commented Mar 22, 2023

the file is just for redhat based distros "init/redhat/waagent.service" :) But with rhel9 it seems to be a little different: https://bugzilla.redhat.com/show_bug.cgi?id=2170104#c36 I still think it makes sense not to set the python version in the service file, but then I do no longer care if python3 is static :)

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

No branches or pull requests

2 participants