Skip to content

Commit

Permalink
lxd: Disable networks during evacuation (from Incus) (#13985)
Browse files Browse the repository at this point in the history
Stop networks when a cluster member has been evacuated.

Includes cherry-picks from lxc/incus#747
  • Loading branch information
tomponline authored Aug 27, 2024
2 parents f0eb9a8 + 8c66943 commit 16eab51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 9 additions & 0 deletions lxd/api_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,9 @@ func evacuateClusterMember(s *state.State, gateway *cluster.Gateway, r *http.Req
return err
}

// Stop networks after evacuation.
networkShutdown(s)

revert.Success()
return nil
}
Expand Down Expand Up @@ -3439,6 +3442,12 @@ func restoreClusterMember(d *Daemon, r *http.Request) response.Response {

metadata := make(map[string]any)

// Restart the networks.
err = networkStartup(d.State())
if err != nil {
return err
}

// Restart the local instances.
for _, inst := range localInstances {
// Don't start instances which were stopped by the user.
Expand Down
11 changes: 7 additions & 4 deletions lxd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,10 +1600,13 @@ func (d *Daemon) init() error {
})

// Setup the networks.
logger.Infof("Initializing networks")
err = networkStartup(d.State())
if err != nil {
return err
if !d.db.Cluster.LocalNodeIsEvacuated() {
logger.Infof("Initializing networks")

err = networkStartup(d.State())
if err != nil {
return err
}
}

// Setup tertiary listeners that may use managed network addresses and must be started after networks.
Expand Down

0 comments on commit 16eab51

Please sign in to comment.