Skip to content

Commit ccd3f10

Browse files
authored
Merge pull request #2781 from rackerlabs/panos-commit-timeout
fix(ironic): wait longer for PAN-OS commits
2 parents b88eab3 + 19a8cdd commit ccd3f10

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎python/ironic-understack/ironic_understack/tests/test_panos_api.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ def test_system_info(conf):
141141
assert session.post.call_args.kwargs["headers"] == {"X-PAN-KEY": "KEY"}
142142

143143

144+
def test_a_slow_commit_is_waited_for(conf, mocker):
145+
mocker.patch("time.sleep")
146+
client = panos_api.PanosClient("192.0.2.10", session=Mock())
147+
running, done = {"status": "ACT"}, {"status": "FIN", "result": "OK"}
148+
mocker.patch.object(client, "check_job", side_effect=[running] * 39 + [done])
149+
150+
assert client.wait_for_commit("12") is True
151+
152+
144153
def test_op_requires_login(conf):
145154
client = panos_api.PanosClient("192.0.2.10", session=Mock())
146155
with pytest.raises(panos_api.PanosApiError, match="not logged in"):

‎python/ironic-understack/ironic_understack/utils/panos_api.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
LOG = log.getLogger(__name__)
1818

1919
TIMEOUT = 30
20+
COMMIT_TIMEOUT = 240
2021

2122
# Passwords are tried in this order. An appliance that has been through initial
2223
# setup takes the standard password, one part way through takes preconfig, and
@@ -238,7 +239,7 @@ def check_job(self, job_id: str) -> dict[str, str]:
238239
"details": job.findtext("details") or "",
239240
}
240241

241-
def wait_for_commit(self, job_id: str, timeout: int = 60) -> bool:
242+
def wait_for_commit(self, job_id: str, timeout: int = COMMIT_TIMEOUT) -> bool:
242243
"""Wait for a commit job to complete.
243244
244245
:param job_id: Job ID from commit()
@@ -263,7 +264,12 @@ def wait_for_commit(self, job_id: str, timeout: int = 60) -> bool:
263264
)
264265
return False
265266

266-
LOG.error("PAN-OS %s commit timed out", self.address)
267+
LOG.error(
268+
"PAN-OS %s commit job %s still running after %ss",
269+
self.address,
270+
job_id,
271+
timeout,
272+
)
267273
return False
268274

269275
def get_interface_macs(self) -> dict[str, str]:
@@ -603,7 +609,7 @@ def configure_ha(
603609
role,
604610
)
605611
job_id = self.commit(f"HA Configuration - {role}")
606-
if job_id and not self.wait_for_commit(job_id, timeout=120):
612+
if job_id and not self.wait_for_commit(job_id):
607613
LOG.error("PAN-OS %s: Failed to commit HA configuration", self.address)
608614
return False
609615

0 commit comments

Comments
 (0)