Add ConditionVirtualization=|microsoft patch

As Fedora will be enabling waagent.service by preset, set a
conditional trigger to start only under Microsoft hypervisors.

Currently, init/redhat/py2/waagent.service is the packaged
systemd service unit, but patch other potentially applicable
ones as well.  This will be cleaned up in the near future
when Fedora support is upstreamed to WALinuxAgent.

Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
This commit is contained in:
Chris Patterson 2022-10-13 10:52:21 -04:00
parent 688db73b5a
commit 4248fde1ff
2 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,69 @@
From dac5101c56b59dbb14d96d4344d6cb2ac047b392 Mon Sep 17 00:00:00 2001
From: Chris Patterson <cpatterson@microsoft.com>
Date: Thu, 1 Sep 2022 10:45:47 -0400
Subject: [PATCH] waagent.service: set ConditionVirtualization=|microsoft
Only start waagent service when running under Microsoft virtualization.
Set it as a triggering condition to make it easier for downstreams or
test setups to add another condition (i.e. run outside of hyperv).
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
---
bin/waagent2.0 | 1 +
init/redhat/py2/waagent.service | 1 +
init/redhat/waagent.service | 1 +
init/waagent.service | 1 +
4 files changed, 4 insertions(+)
diff --git a/bin/waagent2.0 b/bin/waagent2.0
index 34732677..c84c8c40 100644
--- a/bin/waagent2.0
+++ b/bin/waagent2.0
@@ -1569,6 +1569,7 @@ After=network.target
After=sshd.service
ConditionFileIsExecutable=/usr/sbin/waagent
ConditionPathExists=/etc/waagent.conf
+ConditionVirtualization=|microsoft
[Service]
Type=simple
diff --git a/init/redhat/py2/waagent.service b/init/redhat/py2/waagent.service
index c6d15420..132e7027 100644
--- a/init/redhat/py2/waagent.service
+++ b/init/redhat/py2/waagent.service
@@ -5,6 +5,7 @@ After=network-online.target
ConditionFileIsExecutable=/usr/sbin/waagent
ConditionPathExists=/etc/waagent.conf
+ConditionVirtualization=|microsoft
[Service]
Type=simple
diff --git a/init/redhat/waagent.service b/init/redhat/waagent.service
index dc11fbb1..7c93b101 100644
--- a/init/redhat/waagent.service
+++ b/init/redhat/waagent.service
@@ -5,6 +5,7 @@ After=network-online.target
ConditionFileIsExecutable=/usr/sbin/waagent
ConditionPathExists=/etc/waagent.conf
+ConditionVirtualization=|microsoft
[Service]
Type=simple
diff --git a/init/waagent.service b/init/waagent.service
index e91f1433..aa1f3203 100644
--- a/init/waagent.service
+++ b/init/waagent.service
@@ -5,6 +5,7 @@ After=network-online.target
ConditionFileIsExecutable=/usr/sbin/waagent
ConditionPathExists=/etc/waagent.conf
+ConditionVirtualization=|microsoft
[Service]
Type=simple
--
2.37.3

View File

@ -3,7 +3,7 @@
Name: WALinuxAgent Name: WALinuxAgent
Version: 2.7.3.0 Version: 2.7.3.0
Release: 1%{?dist} Release: 2%{?dist}
Summary: The Microsoft Azure Linux Agent Summary: The Microsoft Azure Linux Agent
License: ASL 2.0 License: ASL 2.0
@ -12,6 +12,7 @@ Source0: https://github.com/Azure/%{name}/archive/v%{version}.tar.gz
Source1: module-setup.sh Source1: module-setup.sh
Patch0: 0001-Rudimentary-Fedora-OS-implementation.patch Patch0: 0001-Rudimentary-Fedora-OS-implementation.patch
Patch1: 0001-waagent.service-set-ConditionVirtualization-microsof.patch
BuildArch: noarch BuildArch: noarch
@ -59,6 +60,7 @@ Udev rules specific to Microsoft Azure Virtual Machines.
%prep %prep
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1
%build %build
%py3_build %py3_build
@ -121,6 +123,9 @@ install -m0755 -D -t %{buildroot}%{_prefix}/lib/dracut/modules.d/%{dracut_modnam
%endif %endif
%changelog %changelog
* Tue Oct 18 2022 Chris Patterson <cpatterson@microsoft.com> - 2.7.3.0-2
- Add ConditionVirtualization=|microsoft triggering condition
* Wed Aug 03 2022 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.7.3.0-1 * Wed Aug 03 2022 Vitaly Kuznetsov <vkuznets@redhat.com> - 2.7.3.0-1
- Update to 2.7.3.0 (#2110155) - Update to 2.7.3.0 (#2110155)