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

Signal and fail deployment when no eligible nodes are found #381

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ func (l *levantDeployment) evaluationInspector(evalID *string) error {
group, len(metrics.ConstraintFiltered), cf)
}
}

eligibleNodes := 0
for dc, cnt := range metrics.NodesAvailable {
if cnt == 0 {
log.Error().Msgf("levant/deploy: no nodes are available in datacenter %s", dc)
}
eligibleNodes += cnt
}
if eligibleNodes == 0 {
log.Error().Msgf("levant/deploy: no nodes were eligible for evaluation")
l.failDeployement(*evalID)
return fmt.Errorf("no nodes were eligible for evaluation")
}
}

// Do not return an error here; there could well be information from
Expand All @@ -271,13 +284,21 @@ func (l *levantDeployment) evaluationInspector(evalID *string) error {
}
}

func (l *levantDeployment) failDeployement(evalID string) {
if depID, err := l.getDeploymentID(evalID); err == nil {
if _, _, err := l.nomad.Deployments().Fail(depID, nil); err == nil {
log.Info().Msgf("levant/deploy: deployment %s failed", depID)
}
}
}

func (l *levantDeployment) deploymentWatcher(depID string) (success bool) {

var canaryChan chan interface{}
deploymentChan := make(chan interface{})

t := time.Now()
wt := 5 * time.Second
wt := 1 * time.Second

// Setup the canaryChan and launch the autoPromote go routine if autoPromote
// has been enabled.
Expand Down