Skip to content

Commit

Permalink
incusd/network/physical: Handle changes in parent value
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sponsored-by: Luizalabs (https://luizalabs.com)
  • Loading branch information
stgraber committed Oct 18, 2024
1 parent a525df8 commit 6666510
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/server/network/driver_physical.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/lxc/incus/v6/internal/server/cluster/request"
"github.com/lxc/incus/v6/internal/server/db"
"github.com/lxc/incus/v6/internal/server/ip"
"github.com/lxc/incus/v6/internal/server/network/ovs"
"github.com/lxc/incus/v6/shared/api"
"github.com/lxc/incus/v6/shared/logger"
"github.com/lxc/incus/v6/shared/util"
Expand Down Expand Up @@ -340,6 +341,24 @@ func (n *physical) Update(newNetwork api.NetworkPut, targetNode string, clientTy
return err
}

// Update OVS bridge entries (for dependent OVN networks).
if hostNameChanged {
vswitch, err := n.state.OVS()
if err == nil {
ovsBridge := fmt.Sprintf("incusovn%d", n.id)

err := vswitch.DeleteBridgePort(context.TODO(), ovsBridge, oldNetwork.Config["parent"])
if err != nil && err != ovs.ErrNotFound {
return err
}

err = vswitch.CreateBridgePort(context.TODO(), ovsBridge, newNetwork.Config["parent"], true)
if err != nil && err != ovs.ErrNotFound {
return err
}
}
}

revert.Success()

// Notify dependent networks (those using this network as their uplink) of the changes.
Expand Down

0 comments on commit 6666510

Please sign in to comment.