Skip to content

Conversation

@haseebsyed12
Copy link
Contributor

No description provided.

@haseebsyed12 haseebsyed12 force-pushed the puc-1297-dynamic-lookup-network-node branch 2 times, most recently from 0a15219 to e72d9aa Compare November 7, 2025 10:51
@haseebsyed12 haseebsyed12 requested a review from a team November 7, 2025 10:51
@haseebsyed12 haseebsyed12 marked this pull request as ready for review November 7, 2025 11:05
@haseebsyed12 haseebsyed12 force-pushed the puc-1297-dynamic-lookup-network-node branch from e72d9aa to cfbcc73 Compare November 7, 2025 17:12
return bool(uuid_pattern.match(value))


def fetch_network_node_trunk_id() -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This funtion is quite long and does a lot of things, consider splitting it into small functions. Also I see no test for it and it seems to be important to test it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty expensive function to be called regularly in some of the other flows as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall I use oslo.cache or generic one ?

Copy link
Contributor

@cardoe cardoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the big O on this is gonna be costly. I would change this around to not get all trunks and walk them and call Ironic over and over again. You can call Ironic once for the gateway node to get its ID then get the ports owned by that ID. Then get the trunks owned by those ports. Now you've got a much smaller list to iterate over.

In the current code if we have 1000 trunk ports (which isn't even the possible max for a site) you would make 1000 calls to Ironic inside of a function that's expected to complete in 20 seconds or less.

Comment on lines 101 to 105
utils.fetch_trunk_plugin().add_subports(
context=n_context.get_admin_context(),
trunk_id=cfg.CONF.ml2_understack.network_node_trunk_uuid,
trunk_id=utils.fetch_network_node_trunk_id(),
subports=subports,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably get the trunk_id = utils.fetch_network_node_trunk_id() on its own line so that if there's an issue we'll get a clearer backtrace for the line number.

Comment on lines +111 to +116
def _is_uuid(value: str) -> bool:
"""Check if a string is a UUID."""
uuid_pattern = re.compile(
r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", re.IGNORECASE
)
return bool(uuid_pattern.match(value))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _is_uuid(value: str) -> bool:
"""Check if a string is a UUID."""
uuid_pattern = re.compile(
r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", re.IGNORECASE
)
return bool(uuid_pattern.match(value))
def _is_uuid(value: str) -> bool:
"""Check if a string is a UUID."""
try:
uuid.UUID(value)
return True
except ValueError:
return False

return bool(uuid_pattern.match(value))


def fetch_network_node_trunk_id() -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty expensive function to be called regularly in some of the other flows as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants