Bug 2170104

Summary: [Azure][WALA][RHEL-8] systemd service should not use python3
Product: Red Hat Enterprise Linux 8 Reporter: Klaas Demter <klaas>
Component: WALinuxAgentAssignee: Vitaly Kuznetsov <vkuznets>
Status: CLOSED ERRATA QA Contact: Yuxin Sun <yuxisun>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.7CC: eterrell, jmaloy, mrezanin, pvlasin, rmcswain, vkuznets, xuli, yacao, ymankad, yuxisun
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: WALinuxAgent-2.7.0.6-8.el8_8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2174895 2175255 (view as bug list) Environment:
Last Closed: 2023-05-16 08:44:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2174895, 2175255    

Description Klaas Demter 2023-02-15 16:31:17 UTC
Description of problem:
This is a cross post from
https://github.com/Azure/WALinuxAgent/issues/2728
the Microsoft people do not seem to see that they are the ones supplying the service file that is doing the wrong thing here, so maybe this needs to be patched downstream.

it seems on systems where python3 is not pointing to the same python version as platform-python waagent fails to start. This happens because it tries to directly use python3 in the systemd service file.

Easiest fix I could come up with is: https://github.com/Azure/WALinuxAgent/pull/2729 -- do not use python3 at all in the service file but use waagent directly. It's executeable and contains the right shebang.


Version-Release number of selected component (if applicable):


How reproducible:
Have python3 point to an appstream python that is not 3.6


Actual results:
WALinuxAgent no longer starts


Expected results:
WALinux starts and does not use python3 to execute

Comment 1 Yuxin Sun 2023-02-16 10:17:44 UTC
Hi Klaas,

Thank you for reporting this issue! We also have a BZ#2170211 to track this issue. Would you mind me to duplicate this issue to BZ#2170211 and track in that one? Thanks!

Comment 2 Klaas Demter 2023-02-16 10:44:32 UTC
@yuxisun 
can you make that other report public - in that case I don't care if this bug lives on or the other one? But judging from the number 2170211 should be a duplicate of 2170104 :)

Greetings
Klaas

Comment 3 Yuxin Sun 2023-02-20 10:16:12 UTC
(In reply to Klaas Demter from comment #2)
> @yuxisun 
> can you make that other report public - in that case I don't care if this
> bug lives on or the other one? But judging from the number 2170211 should be
> a duplicate of 2170104 :)
> 
> Greetings
> Klaas

Hi Klaas,

I double checked these 2 issues and they are actually not exactly the same issues. So I'd like to still track them separately. Thanks!


Hi Vitaly,

I can reproduce this issue. Could you please help to check which one we should use in both waagent.service and /usr/sbin/waagent? /usr/bin/python3 or /usr/libexec/platform-python? Thanks! (In the spec file the RHEL-8 WALA package requires python36)

Comment 4 Klaas Demter 2023-02-21 08:49:36 UTC
(In reply to Yuxin Sun from comment #3)
> 
> Hi Vitaly,
> 
> I can reproduce this issue. Could you please help to check which one we
> should use in both waagent.service and /usr/sbin/waagent? /usr/bin/python3
> or /usr/libexec/platform-python? Thanks! (In the spec file the RHEL-8 WALA
> package requires python36)

My idea was to remove python from the service file and just let /usr/sbin/waagent handle the interpreter choice. Is there any advantage of using python directly inside the service file?

Comment 5 Vitaly Kuznetsov 2023-02-21 09:11:19 UTC
(In reply to Yuxin Sun from comment #3)

> I can reproduce this issue. Could you please help to check which one we
> should use in both waagent.service and /usr/sbin/waagent? /usr/bin/python3
> or /usr/libexec/platform-python? Thanks! (In the spec file the RHEL-8 WALA
> package requires python36)

I also think that relying on the shabang in /usr/sbin/waagent is the right fix here.

Comment 10 Kyle Walker 2023-02-21 16:45:31 UTC
*** Bug 2170211 has been marked as a duplicate of this bug. ***

Comment 15 Robert McSwain 2023-02-24 20:13:45 UTC
Yuxin, This does help one of my customers. One more question from case 03440559


I understand the LinuxDiagnostic extension install will fail on RHEL8. I am trying to use the images published by RedHat on the Azure MarketPlace. This one too fails as Python2. Do you have any plans to change this behavior in the images published by RedHat to make it work. 

"imageReference": {
                        "publisher": "RedHat",
                        "offer": "RHEL",
                        "sku": "8-LVM",
                        "version": "8.7.2022112213"
                    },

Comment 19 Klaas Demter 2023-03-03 07:32:26 UTC
(In reply to Robert McSwain from comment #15)
> Yuxin, This does help one of my customers. One more question from case
> 03440559
> 
> 
> I understand the LinuxDiagnostic extension install will fail on RHEL8. I am
> trying to use the images published by RedHat on the Azure MarketPlace. This
> one too fails as Python2. Do you have any plans to change this behavior in
> the images published by RedHat to make it work. 
> 
> "imageReference": {
>                         "publisher": "RedHat",
>                         "offer": "RHEL",
>                         "sku": "8-LVM",
>                         "version": "8.7.2022112213"
>                     },

I think you're wrong here about this, the extension is not made by Red Hat (neither is the image btw), you have to complain to the Microsoft Team in charge of the Linux Diagnostic Extension, but I'd say for now it's on purpose: https://github.com/MicrosoftDocs/azure-docs/issues/91647

Greetings
Klaas

Comment 20 Klaas Demter 2023-03-03 08:24:35 UTC
@mrezanin will there be a zstream backport of this to 8.7 ?

Comment 21 Yuxin Sun 2023-03-03 11:34:24 UTC
(In reply to Klaas Demter from comment #19)
> (In reply to Robert McSwain from comment #15)
> > Yuxin, This does help one of my customers. One more question from case
> > 03440559
> > 
> > 
> > I understand the LinuxDiagnostic extension install will fail on RHEL8. I am
> > trying to use the images published by RedHat on the Azure MarketPlace. This
> > one too fails as Python2. Do you have any plans to change this behavior in
> > the images published by RedHat to make it work. 
> > 
> > "imageReference": {
> >                         "publisher": "RedHat",
> >                         "offer": "RHEL",
> >                         "sku": "8-LVM",
> >                         "version": "8.7.2022112213"
> >                     },
> 
> I think you're wrong here about this, the extension is not made by Red Hat
> (neither is the image btw), you have to complain to the Microsoft Team in
> charge of the Linux Diagnostic Extension, but I'd say for now it's on
> purpose: https://github.com/MicrosoftDocs/azure-docs/issues/91647
> 
> Greetings
> Klaas

Thanks Klass! I also opened an issue in LAD upstream: https://github.com/Azure/azure-linux-extensions/issues/1681

> @mrezanin will there be a zstream backport of this to 8.7 ?

Yes. We've already requested for 8.7.z and is waiting for approval now. Thanks!

Comment 22 Yash Mankad 2023-03-03 16:19:32 UTC
(In reply to Klaas Demter from comment #20)
> @mrezanin will there be a zstream backport of this to 8.7 ?

Approving zstream for 8.7.
The 8.7 clone will be created shortly.

Comment 34 Klaas Demter 2023-03-17 06:54:37 UTC
@mrezanin I can't see the PR, does this also change the dependencies from python3.6 to platform python? I noticed walinuxagent gets removed when a user removes python3.6

Comment 35 Klaas Demter 2023-03-22 15:30:49 UTC
Patch https://gitlab.com/redhat/centos-stream/rpms/WALinuxAgent/-/blob/c8s/wla-Use-platform-python-in-waagent.service.patch
I am guessing this also needs to go into rhel9/c9s

Greetings
Klaas

Comment 36 Vitaly Kuznetsov 2023-03-22 16:04:16 UTC
(In reply to Klaas Demter from comment #35)
> Patch
> https://gitlab.com/redhat/centos-stream/rpms/WALinuxAgent/-/blob/c8s/wla-Use-platform-python-in-waagent.service.patch
> I am guessing this also needs to go into rhel9/c9s

WALinuxAgent in RHEL9/C9S does not override shebang in /usr/sbin/waagent, it is 

#!/usr/bin/python3

and waagent.service calling it with

ExecStart=/usr/bin/python3 -u /usr/sbin/waagent -daemon

doesn't really change anything. Also, using /usr/bin/python3 is recommended in RHEL9:
(https://access.redhat.com/solutions/6736391):

"""
The /usr/libexec/platform-python is implemented as a symbolic link to /usr/bin/python3 . Although this platform-python
symlink is deprecated in RHEL 9 and is added for backwards compatibility with RHEL 8.

The /usr/bin/python3 is used by Red Hat shipped applications and is recommended to be used for third party applications,
User scripts and custom use of python library instead of /usr/libexec/platform-python
"""

Comment 37 Klaas Demter 2023-03-22 16:10:46 UTC
hehe okay, I actually did not know that, not using rhel9 that much yet, I still think it would be cleaner to let waagent decide the python version, but well - if it works and doesn't break then I don't care :)

Comment 38 Vitaly Kuznetsov 2023-03-22 16:16:18 UTC
(In reply to Klaas Demter from comment #37)
> hehe okay, I actually did not know that, not using rhel9 that much yet, I
> still think it would be cleaner to let waagent decide the python version,
> but well - if it works and doesn't break then I don't care :)

Generally, I agree that overriding /usr/sbin/waagent's shebang in waagent.service is not
a good idea, hope https://github.com/Azure/WALinuxAgent/pull/2729 will get accepted.

Comment 39 Klaas Demter 2023-03-22 16:20:46 UTC
So Microsoft considers that file to be Red Hats problem, https://github.com/Azure/WALinuxAgent/issues/2728#issuecomment-1479788371 , maybe give them a kick in the PR, maybe we can finally close this for good :)

Comment 42 errata-xmlrpc 2023-05-16 08:44:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (WALinuxAgent bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2944