Skip to content

Error in switch port settings update can cause port settings corruption #6000

Closed

Description

@rcgoodfellow

In the following code, a switch port settings update happens by:

  1. Deleting the current settings.
  2. Creating new settings.
  3. Re-associating switch ports that use the settings being changed with the new settings id.

If something goes wrong in step 2, then we're left with a situation where the original settings have been deleted, no new settings have taken their place, and the switch ports that referenced the original settings now reference settings that no longer exist.

self.switch_port_settings_delete(
opctx,
&params::SwitchPortSettingsSelector {
port_settings: Some(NameOrId::Id(switch_port_settings_id)),
},
)
.await?;
// create new settings
let result = self
.switch_port_settings_create(
opctx,
new_settings.clone(),
Some(switch_port_settings_id),
)
.await?;
let ports = self
.db_datastore
.switch_ports_using_settings(opctx, switch_port_settings_id)
.await?;
for (switch_port_id, _switch_port_name) in ports.into_iter() {
self.set_switch_port_settings_id(
&opctx,
switch_port_id,
Some(switch_port_settings_id),
UpdatePrecondition::DontCare,
)
.await?;
}

One possible solution to this is putting steps 1, 2, and 3 into a database transaction.

This bug surfaced while testing network settings update scenarios for release 9.

Activity

  1. added
    bug
    networking
    on Jul 4, 2024
  2. added this to the 9 milestone on Jul 4, 2024
  3. self-assigned this
    on Jul 4, 2024
  4. added a commit that references this issue on Jul 4, 2024
    a7fc65b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugnetworking

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions