Skip to content

Commit

Permalink
azure/imds: increase read-timeout to 30s (#4372)
Browse files Browse the repository at this point in the history
When fetching metadata or reprovisiondata, allow up to 30 seconds
for a read timeout.  For cases where a read request is delayed,
this would eliminate extra follow-up request(s).

Signed-off-by: Chris Patterson <[email protected]>
  • Loading branch information
cjp256 authored Aug 21, 2023
1 parent 9436569 commit b669f31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cloudinit/sources/azure/imds.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _fetch_url(
*,
retry_deadline: float,
log_response: bool = True,
timeout: int = 2,
timeout: int = 30,
) -> bytes:
"""Fetch URL from IMDS.
Expand Down Expand Up @@ -194,7 +194,7 @@ def fetch_reprovision_data() -> bytes:
headers={"Metadata": "true"},
infinite=True,
log_req_resp=False,
timeout=2,
timeout=30,
)

report_diagnostic_event(
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/sources/azure/test_imds.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TestFetchMetadataWithApiFallback:
"http://169.254.169.254/metadata/instance?api-version=2019-06-01"
)
headers = {"Metadata": "true"}
timeout = 2
timeout = 30

@pytest.mark.parametrize("retry_deadline", [0.0, 1.0, 60.0])
def test_basic(
Expand Down Expand Up @@ -488,7 +488,7 @@ class TestFetchReprovisionData:
"reprovisiondata?api-version=2019-06-01"
)
headers = {"Metadata": "true"}
timeout = 2
timeout = 30

def test_basic(
self,
Expand Down
32 changes: 16 additions & 16 deletions tests/unittests/sources/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3660,7 +3660,7 @@ def test_no_pps(self):
mock.call(
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
timeout=2,
timeout=30,
headers={"Metadata": "true"},
exception_cb=mock.ANY,
infinite=True,
Expand Down Expand Up @@ -3737,7 +3737,7 @@ def test_running_pps(self):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/reprovisiondata?"
Expand All @@ -3746,7 +3746,7 @@ def test_running_pps(self):
headers={"Metadata": "true"},
log_req_resp=False,
infinite=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -3755,7 +3755,7 @@ def test_running_pps(self):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
]

Expand Down Expand Up @@ -3850,7 +3850,7 @@ def test_savable_pps(self):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -3859,7 +3859,7 @@ def test_savable_pps(self):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/reprovisiondata?"
Expand All @@ -3868,7 +3868,7 @@ def test_savable_pps(self):
headers={"Metadata": "true"},
log_req_resp=False,
infinite=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -3877,7 +3877,7 @@ def test_savable_pps(self):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
]

Expand Down Expand Up @@ -4010,7 +4010,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -4019,7 +4019,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/reprovisiondata?"
Expand All @@ -4028,7 +4028,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=False,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -4037,7 +4037,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
]

Expand Down Expand Up @@ -4124,7 +4124,7 @@ def test_recovery_pps(self, pps_type):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/reprovisiondata?"
Expand All @@ -4133,7 +4133,7 @@ def test_recovery_pps(self, pps_type):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=False,
timeout=2,
timeout=30,
),
mock.call(
"http://169.254.169.254/metadata/instance?"
Expand All @@ -4142,7 +4142,7 @@ def test_recovery_pps(self, pps_type):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
]

Expand Down Expand Up @@ -4249,7 +4249,7 @@ def test_os_disk_pps(self, mock_sleep, subp_side_effect):
headers={"Metadata": "true"},
infinite=True,
log_req_resp=True,
timeout=2,
timeout=30,
),
]

Expand Down

0 comments on commit b669f31

Please sign in to comment.