-
Notifications
You must be signed in to change notification settings - Fork 25
ipfixprobed: fix config2args #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||
| import json | ||||||||||||
| import re | ||||||||||||
| from pathlib import Path | ||||||||||||
| from typing import List | ||||||||||||
|
|
||||||||||||
| def load_config(file_path): | ||||||||||||
| try: | ||||||||||||
|
|
@@ -54,7 +55,7 @@ def process_input_plugin(config): | |||||||||||
|
|
||||||||||||
| return " ".join(params) | ||||||||||||
|
|
||||||||||||
| def get_cpus_for_pci_device(pci_address: str) -> list[int]: | ||||||||||||
| def get_cpus_for_pci_device(pci_address: str) -> List[int]: | ||||||||||||
| """ | ||||||||||||
| Gets the list of CPU IDs associated with the NUMA node corresponding to the given PCI address. | ||||||||||||
|
|
||||||||||||
|
|
@@ -63,15 +64,14 @@ def get_cpus_for_pci_device(pci_address: str) -> list[int]: | |||||||||||
| """ | ||||||||||||
| # Get the NUMA node | ||||||||||||
| numa_path = Path(f"/sys/bus/pci/devices/{pci_address}/numa_node") | ||||||||||||
| if not numa_path.exists(): | ||||||||||||
| raise FileNotFoundError(f"NUMA node info for PCI address {pci_address} does not exist.") | ||||||||||||
|
|
||||||||||||
| numa_node = numa_path.read_text().strip() | ||||||||||||
| if numa_node == "-1": | ||||||||||||
| raise ValueError(f"Device {pci_address} is not assigned to any NUMA node.") | ||||||||||||
| numa_node = 0 | ||||||||||||
| if numa_path.exists(): | ||||||||||||
| numa_node = numa_path.read_text().strip() | ||||||||||||
| if numa_node == "-1": | ||||||||||||
| numa_node = 0 | ||||||||||||
|
|
||||||||||||
| # Run lscpu to get CPU information | ||||||||||||
| result = subprocess.run(["lscpu"], capture_output=True, text=True, check=True) | ||||||||||||
| result = subprocess.run(["lscpu"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True) | ||||||||||||
| lines = result.stdout.splitlines() | ||||||||||||
|
|
||||||||||||
| # Find the line corresponding to the NUMA node | ||||||||||||
|
|
@@ -84,7 +84,7 @@ def get_cpus_for_pci_device(pci_address: str) -> list[int]: | |||||||||||
|
|
||||||||||||
| raise RuntimeError(f"Could not find CPU list for NUMA node {numa_node}.") | ||||||||||||
|
|
||||||||||||
| def parse_cpu_list(cpu_list_str: str) -> list[int]: | ||||||||||||
| def parse_cpu_list(cpu_list_str: str) -> List[int]: | ||||||||||||
| """ | ||||||||||||
| Converts a CPU range string like "1,3,5-7" to a list of individual CPU numbers [1, 3, 5, 6, 7]. | ||||||||||||
|
|
||||||||||||
|
|
@@ -138,11 +138,18 @@ def process_input_dpdk_plugin(settings): | |||||||||||
| workers_cpu_list = cpu_list[:rx_queues] | ||||||||||||
|
|
||||||||||||
| # Main parameter for DPDK with $eal_opts | ||||||||||||
| primary_param = f"-i \"dpdk;p={','.join(str(i) for i in range(nic_count))};" | ||||||||||||
| first_cpu = workers_cpu_list[0] | ||||||||||||
| if first_cpu is not None: | ||||||||||||
| primary_param = f"-i \"dpdk@{first_cpu};p={','.join(str(i) for i in range(nic_count))};" | ||||||||||||
| else: | ||||||||||||
| primary_param = f"-i \"dpdk;p={','.join(str(i) for i in range(nic_count))};" | ||||||||||||
|
Comment on lines
+142
to
+145
|
||||||||||||
| if first_cpu is not None: | |
| primary_param = f"-i \"dpdk@{first_cpu};p={','.join(str(i) for i in range(nic_count))};" | |
| else: | |
| primary_param = f"-i \"dpdk;p={','.join(str(i) for i in range(nic_count))};" | |
| primary_param = f"-i \"dpdk@{first_cpu};p={','.join(str(i) for i in range(nic_count))};" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indexing
workers_cpu_list[0]without checking if the list is non-empty can lead toIndexError; add a guard (e.g.,if not workers_cpu_list: ...) before accessing it.