Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incusd/instances: Don't start instances when evacuated #744

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cmd/incusd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1611,9 +1611,7 @@ func (d *Daemon) init() error {
d.tasks.Start(d.shutdownCtx)

// Restore instances
if !d.db.Cluster.LocalNodeIsEvacuated() {
instancesStart(d.State(), instances)
}
instancesStart(d.State(), instances)

// Re-balance in case things changed while the daemon was down
deviceTaskBalance(d.State())
Expand Down
8 changes: 8 additions & 0 deletions cmd/incusd/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,19 @@ func instanceShouldAutoStart(inst instance.Instance) bool {
}

func instancesStart(s *state.State, instances []instance.Instance) {
// Check if the cluster is currently evacuated.
if s.DB.Cluster.LocalNodeIsEvacuated() {
return
}

// Acquire startup lock.
instancesStartMu.Lock()
defer instancesStartMu.Unlock()

// Sort based on instance boot priority.
sort.Sort(instanceAutostartList(instances))

// Let's make up to 3 attempts to start instances.
maxAttempts := 3

// Start the instances
Expand Down
Loading