Skip to content

refactor: update dhcp on dns server change#447

Draft
MaikRe wants to merge 1 commit into
canonical:3.7from
MaikRe:update_dhcp_on_dns_change
Draft

refactor: update dhcp on dns server change#447
MaikRe wants to merge 1 commit into
canonical:3.7from
MaikRe:update_dhcp_on_dns_change

Conversation

@MaikRe

@MaikRe MaikRe commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@maas-lander

Copy link
Copy Markdown
Collaborator

Check where you would like a Mattermost message to be sent to when CI completes and this PR is merged

  • Direct message
  • ~maas

@MaikRe MaikRe marked this pull request as draft July 9, 2026 17:42

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[maas-code-reviewer review]

LLM-generated review from https://github.com/canonical/maas-code-reviewer.
Intended to assist a human reviewer, not replace one — suggestions may be
incorrect, please verify before acting.

The change to trigger a DHCP workflow when dns_servers are updated is a great addition and the new tests look good. However, there is a critical bug in update_dhcp introduced by expanding the watched fields without updating the signal handler's unpacking logic, which will result in runtime crashes.

update_dhcp,
Subnet,
["vlan_id"],
["vlan_id", "dns_servers"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By adding "dns_servers" to the watched fields, old_values passed to update_dhcp will now contain two elements: (old_vlan_id, old_dns_servers). However, update_dhcp (around line 110, just above this hunk) unpacks it as [old_vlan_id] = old_values, which expects a single element. This will raise a ValueError: too many values to unpack (expected 1) and crash whenever a Subnet is saved.

You must update update_dhcp to handle the additional field. For example:

old_vlan_id, old_dns_servers = old_values

Performance tip: Since old_vlan_id == instance.vlan_id when only dns_servers change, you could also optimise update_dhcp to skip the VLAN.objects.get(id=old_vlan_id) query if old_vlan_id == instance.vlan_id.

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.

2 participants