59 lines
2.0 KiB
Diff
59 lines
2.0 KiB
Diff
From d78e7000d0c91ba0b6b7a56fc931bce3094d0bc9 Mon Sep 17 00:00:00 2001
|
|
From: Frank Liang <xiliang@redhat.com>
|
|
Date: Wed, 3 Dec 2025 00:21:06 +0800
|
|
Subject: [PATCH] [plugin_aws]fix unable to get metadata in aws.py
|
|
|
|
- exec_cmd() cmd type is a str, cannot execute when
|
|
it is a list
|
|
- removed spaces after X-aws-ec2-metadata-token and
|
|
X-aws-ec2-metadata-token-ttl-seconds
|
|
|
|
Signed-off-by: Frank Liang <xiliang@redhat.com>
|
|
---
|
|
sos/report/plugins/aws.py | 14 ++++++--------
|
|
1 file changed, 6 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/sos/report/plugins/aws.py b/sos/report/plugins/aws.py
|
|
index 602e88e4..ba819bed 100644
|
|
--- a/sos/report/plugins/aws.py
|
|
+++ b/sos/report/plugins/aws.py
|
|
@@ -41,21 +41,19 @@ class Aws(Plugin, IndependentPlugin):
|
|
|
|
# Try to get an IMDSv2 token
|
|
token_url = 'http://169.254.169.254/latest/api/token'
|
|
- token_cmd = [
|
|
- 'curl', '-sS', '-X', 'PUT', '-H',
|
|
- 'X-aws-ec2-metadata-token-ttl-seconds: 21600',
|
|
- token_url]
|
|
+ token_cmd = f'curl -sS -X PUT -H \
|
|
+ X-aws-ec2-metadata-token-ttl-seconds:21600 {token_url}'
|
|
|
|
try:
|
|
- token = self.exec_cmd(token_cmd, timeout=1)
|
|
+ token = self.exec_cmd(token_cmd, timeout=1)['output']
|
|
except Exception:
|
|
token = ''
|
|
|
|
# Add header only if token retrieval succeeded
|
|
- token_header = []
|
|
+ token_header = ''
|
|
|
|
if token:
|
|
- token_header = ['-H', f'X-aws-ec2-metadata-token: {token}']
|
|
+ token_header = f'-H X-aws-ec2-metadata-token:{token}'
|
|
|
|
# List of metadata paths we want to get
|
|
metadata_paths = [
|
|
@@ -73,7 +71,7 @@ class Aws(Plugin, IndependentPlugin):
|
|
meta_url = base_url + path
|
|
safe_name = path.replace('/', '_')
|
|
self.add_cmd_output(
|
|
- ['curl', '-sS'] + token_header + [meta_url],
|
|
+ f'curl -sS {token_header} {meta_url}',
|
|
suggest_filename=f'aws_metadata_{safe_name}.txt'
|
|
)
|
|
|
|
--
|
|
2.51.1
|
|
|