Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/registration_engine/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ def update_registration_data(
create_resp.raise_for_status()

elif read_resp.status_code in (409, 429, 500, 502, 503, 504):
last_err = RuntimeError(
f"Transient read error {read_resp.status_code}"
)
last_err = RuntimeError(f"Transient read error {read_resp.status_code}")
else:
read_resp.raise_for_status()

Expand All @@ -212,6 +210,4 @@ def update_registration_data(
time.sleep(delay)
delay *= K8S_RETRY_BACKOFF

raise RuntimeError(
f"Kubernetes secret update exhausted retries: {last_err}"
)
raise RuntimeError(f"Kubernetes secret update exhausted retries: {last_err}")
8 changes: 2 additions & 6 deletions src/registration_engine/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ def from_env(cls) -> "Plan":
)


def fetch_extension_plan(
token: str, extension_resource_id: str
) -> Plan:
def fetch_extension_plan(token: str, extension_resource_id: str) -> Plan:
"""Fetch extension plan block using ARM Identity.

Retries with exponential backoff on transient (5xx, 429, network) errors.
Expand Down Expand Up @@ -271,9 +269,7 @@ def get_attested_data(nonce: str, api_version: str) -> Dict[str, Any]:
Dictionary containing pkcs7 signature, subscription ID and
plain text nonce
"""
url = (
f"{IMDS_BASE_URL}/attested/document?api-version={api_version}&nonce={nonce}"
)
url = f"{IMDS_BASE_URL}/attested/document?api-version={api_version}&nonce={nonce}"
try:
response_body = _make_imds_request(url)
attested_data = json.loads(response_body)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_config_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ def test_config_loading_invalid_integration():
# in compliance with SMT parsing guardrails
if not (cfg.has_section("server") and cfg.has_section("instance")):
with pytest.raises(ValueError, match="Missing required sections"):
raise ValueError(
"Missing required sections: [server] and [instance]"
)
raise ValueError("Missing required sections: [server] and [instance]")
1 change: 1 addition & 0 deletions tests/test_microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def test_get_workload_identity_token_request_error(mock_open, mock_post):
mock_open.return_value.__enter__.return_value = mock_file

import requests

mock_post.side_effect = requests.RequestException("Network error")

with patch.dict(os.environ, env_vars):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_smt.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def test_get_target_update_server_return_type_and_outage_chaos(
)
mock_fetch_smt_data.return_value = [node]

with patch.object(SMT, "is_responsive", return_value=True), \
patch.object(SMT, "get_cert", return_value="pem-data"):

with (
patch.object(SMT, "is_responsive", return_value=True),
patch.object(SMT, "get_cert", return_value="pem-data"),
):
res = get_target_update_server(cfg)
assert isinstance(res, dict)
assert res["ipv4"] == "192.168.1.100"
Expand Down
Loading