Skip to content

Commit 85a79af

Browse files
authored
cloud-init add patch for PPS support of auzre-proxy-agent (#10455)
Co-authored-by: minghe <rmhsawyer>
1 parent d37a414 commit 85a79af

2 files changed

Lines changed: 99 additions & 1 deletion

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
From 19442eedae2a3f96d424626dad20e037f10f147b Mon Sep 17 00:00:00 2001
2+
From: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
3+
Date: Tue, 13 Aug 2024 09:44:25 -0700
4+
Subject: [PATCH] add PPS support for azure-proxy-agent
5+
6+
---
7+
cloudinit/sources/DataSourceAzure.py | 23 +++++++++++++++++++++--
8+
cloudinit/sources/azure/errors.py | 5 +----
9+
tests/unittests/sources/test_azure.py | 5 ++++-
10+
3 files changed, 26 insertions(+), 7 deletions(-)
11+
12+
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
13+
index c2f74e173..aed740b89 100644
14+
--- a/cloudinit/sources/DataSourceAzure.py
15+
+++ b/cloudinit/sources/DataSourceAzure.py
16+
@@ -504,15 +504,31 @@ class DataSourceAzure(sources.DataSource):
17+
]
18+
out, err = subp.subp(cmd)
19+
report_diagnostic_event(
20+
- "Running azure-proxy-agent %s resulted"
21+
- "in stderr output: %s with stdout: %s" % (cmd, err, out),
22+
+ "Executing %s resulted "
23+
+ "in stderr=%r with stdout=%r" % (cmd, err, out),
24+
logger_func=LOG.debug,
25+
)
26+
except subp.ProcessExecutionError as error:
27+
if isinstance(error.reason, FileNotFoundError):
28+
+ LOG.error(
29+
+ "Failed to activate Azure Guest Proxy Agent: "
30+
+ "azure-proxy-agent not found"
31+
+ )
32+
report_error = errors.ReportableErrorProxyAgentNotFound()
33+
self._report_failure(report_error)
34+
else:
35+
+ report_diagnostic_event(
36+
+ "Failed to activate Azure Guest Proxy Agent: "
37+
+ "status check failed "
38+
+ "cmd=%r stderr=%r stdout=%r exit_code=%s"
39+
+ % (
40+
+ error.cmd,
41+
+ error.stderr,
42+
+ error.stdout,
43+
+ error.exit_code,
44+
+ ),
45+
+ logger_func=LOG.error,
46+
+ )
47+
reportable_error = (
48+
errors.ReportableErrorProxyAgentStatusFailure(error)
49+
)
50+
@@ -637,6 +653,9 @@ class DataSourceAzure(sources.DataSource):
51+
self._wait_for_pps_unknown_reuse()
52+
53+
md, userdata_raw, cfg, files = self._reprovision()
54+
+ if cfg.get("ProvisionGuestProxyAgent"):
55+
+ self._check_azure_proxy_agent_status()
56+
+
57+
# fetch metadata again as it has changed after reprovisioning
58+
imds_md = self.get_metadata_from_imds(report_failure=True)
59+
60+
diff --git a/cloudinit/sources/azure/errors.py b/cloudinit/sources/azure/errors.py
61+
index b331cd686..6595ceda9 100644
62+
--- a/cloudinit/sources/azure/errors.py
63+
+++ b/cloudinit/sources/azure/errors.py
64+
@@ -155,10 +155,7 @@ class ReportableErrorUnhandledException(ReportableError):
65+
66+
class ReportableErrorProxyAgentNotFound(ReportableError):
67+
def __init__(self) -> None:
68+
- super().__init__(
69+
- "Unable to activate Azure Guest Proxy Agent."
70+
- "azure-proxy-agent not found"
71+
- )
72+
+ super().__init__("azure-proxy-agent not found")
73+
74+
75+
class ReportableErrorProxyAgentStatusFailure(ReportableError):
76+
diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py
77+
index 9b6672e1e..446d5bf31 100644
78+
--- a/tests/unittests/sources/test_azure.py
79+
+++ b/tests/unittests/sources/test_azure.py
80+
@@ -4532,7 +4532,10 @@ class TestCheckAzureProxyAgent:
81+
subp.SubpResult("Guest Proxy Agent running", ""),
82+
]
83+
self.azure_ds._check_azure_proxy_agent_status()
84+
- assert "Running azure-proxy-agent" in self.caplog.text
85+
+ assert (
86+
+ "Executing ['azure-proxy-agent', '--status', '--wait', '120']"
87+
+ in self.caplog.text
88+
+ )
89+
assert self.mock_wrapping_report_failure.mock_calls == []
90+
91+
def test_check_azure_proxy_agent_status_notfound(self):
92+
--
93+
2.34.1
94+

SPECS/cloud-init/cloud-init.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Summary: Cloud instance init scripts
55
Name: cloud-init
66
Epoch: 1
77
Version: %{package_version}
8-
Release: 4%{?dist}
8+
Release: 5%{?dist}
99
License: GPLv3
1010
Vendor: Microsoft Corporation
1111
Distribution: Mariner
@@ -19,6 +19,7 @@ Patch2: Add-Network-Interface-Renaming-Support-for-CAPM3-Met.patch
1919
Patch3: 0001-feat-azure-Add-ProvisionGuestProxyAgent-OVF-setting.patch
2020
Patch4: 0002-feat-azure-parse-ProvisionGuestProxyAgent-as-bool-51.patch
2121
Patch5: 0003-feat-azure-add-support-for-azure-proxy-agent.patch
22+
Patch6: 0001-add-PPS-support-for-azure-proxy-agent.patch
2223
%define cl_services cloud-config.service cloud-config.target cloud-final.service cloud-init.service cloud-init.target cloud-init-local.service
2324
BuildRequires: automake
2425
BuildRequires: dbus
@@ -154,6 +155,9 @@ make check %{?_smp_mflags}
154155
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/10-azure-kvp.cfg
155156

156157
%changelog
158+
* Fri Sep 13 2024 Minghe Ren <mingheren@microsoft.com> - 1:23.3-5
159+
- Add patche to have PPS support for azure-proxy-agent.
160+
157161
* Wed Sep 04 2024 Minghe Ren <mingheren@microsoft.com> - 1:23.3-4
158162
- Add patches to support azure-proxy-agent.
159163

0 commit comments

Comments
 (0)