Lspci: only refresh the pciids database once per node - #4656
Lspci: only refresh the pciids database once per node#4656mcgov (mcgov) wants to merge 3 commits into
Conversation
56fbd8f to
80769c7
Compare
80769c7 to
e139016
Compare
e139016 to
659b949
Compare
There was a problem hiding this comment.
Pull request overview
This PR optimizes Lspci.get_devices() by avoiding repeated update-pciids network downloads during forced PCI refreshes, which is especially beneficial for hot-plug test loops that rescan PCI state frequently.
Changes:
- Add a per-tool-instance
_pciids_initializedflag to ensureupdate-pciidsruns at most once. - Move the
update-pciidscall behind the initialization guard while keeping device list refresh behavior unchanged.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lisa/tools/lspci.py:303
_pciids_initializedis only set to True whenupdate-pciidsreturns 0. Ifupdate-pciidsis slow and fails (e.g., transient network/DNS issues), then each subsequentforce_runwill re-runupdate-pciids, reintroducing the repeated delay this PR is trying to remove. Consider marking the refresh as "attempted" regardless of exit code (best-effort update) and log stderr for troubleshooting.
if not self._pciids_initialized:
# Ensure pci device ids and name mappings are updated.
exit_code = self.node.execute("update-pciids", sudo=True, shell=True).exit_code
if exit_code == 0:
self._pciids_initialized = True
else:
self.node.log.debug(f"update-pciids failed, returned code {exit_code}")
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
lisa/tools/lspci.py:307
_pciids_initializedis only set toTruewhenupdate-pciidssucceeds. Ifupdate-pciidsis slow and fails (e.g., transient network issues), everyforce_run=Truerefresh will re-run it, reintroducing the repeated download/delay this PR is trying to remove. Consider marking it initialized after the first attempt (success or failure) and just logging failures.
if not self._pciids_initialized:
# Ensure pci device ids and name mappings are updated.
exit_code = self.node.execute(
"update-pciids", sudo=True, shell=True
).exit_code
if exit_code == 0:
self._pciids_initialized = True
else:
self.node.log.debug(
f"update-pciids failed, returned code {exit_code}"
)
lisa/tools/lspci.py:296
- The PR description lists
verify_dpdk_sriov_rescind_failover_send_onlyandverify_device_reports_correct_pci_slotas executed test cases, but those method names don’t exist in this branch (no matches inlisa/microsoft/testsuites/). Please update the PR description to reference the actual test methods that were run so reviewers can reproduce validation.
if (not self._pci_devices) or force_run:
get_devices ran update-pciids on every forced refresh, which adds a network download and a noticeable delay to hot plug tests that rescan the pci bus repeatedly. Track whether the database was already updated for this tool instance and skip the refresh afterwards. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5d5f58ad-b9df-4420-ad37-22caee78e925
ad62757 to
ed17764
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lisa/tools/lspci.py:307
_pciids_initializedis only set toTruewhenupdate-pciidssucceeds. If the command fails once (e.g., no outbound network access), every subsequentforce_runwill retryupdate-pciids, reintroducing the repeated download/delay this PR is trying to eliminate. Consider marking the pciids refresh as "attempted" after the first run regardless of exit code, while still logging failures.
if exit_code == 0:
self._pciids_initialized = True
else:
self.node.log.debug(
f"update-pciids failed, returned code {exit_code}"
Part 3 of 9 of a stacked series that reworks the DPDK SRIOV hot plug tests. Stacked on #4655, review only the last commit.
get_devicesranupdate-pciidson every forced refresh, which adds a network download and a noticeable delay to hot plug tests that rescan the pci bus repeatedly. The database is now refreshed once per tool instance.Key Test Cases:
verify_dpdk_sriov_rescind_failover_send_only|verify_device_reports_correct_pci_slot
Impacted LISA Features:
Sriov, NetworkInterface, Nvme, Gpu
Tested Azure Marketplace Images:
canonical 0001-com-ubuntu-server-jammy 22_04-lts latestmicrosoftcblmariner azure-linux-3 azure-linux-3 latest