base debugging

This commit is contained in:
Alex Dadgar
2016-04-19 16:33:25 -07:00
parent cd92e45e4b
commit aac0aeb591

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/nomad/structs"
)
@@ -295,6 +296,26 @@ func (s *GenericScheduler) computeJobAllocs() error {
diff := diffAllocs(s.job, tainted, groups, allocs)
s.logger.Printf("[DEBUG] sched: %#v: %#v", s.eval, diff)
// XXX: For debugging purposes only. An issue was observed where a job had a
// task group with count > 0 that produced a diff where no action would be
// taken (every slice was empty). Below we dump debug information if this
// condition is hit.
//diffSum := len(diff.stop) + len(diff.place) + len(diff.ignore) +
//len(diff.update) + len(diff.migrate)
//if diffSum == 0 && len(groups) != 0 {
if true {
s.logger.Printf("[ERR] sched: %d tasks to schedule but scheduler believes there is no work", len(groups))
// Get the original set of allocations for the job.
jobAllocs, err := s.state.AllocsByJob(s.eval.JobID)
if err != nil {
return fmt.Errorf("failed to get allocs for job '%s': %v", s.eval.JobID, err)
}
s.logger.Printf("[DEBUG] sched: AllocsByJob(%q) returned: %#v", s.eval.JobID, spew.Sdump(jobAllocs))
s.logger.Printf("[DEBUG] sched: filterCompleteAllocs(): %#v", spew.Sdump(allocs))
s.logger.Printf("[DEBUG] sched: taintedNodes(): %#v", spew.Sdump(tainted))
}
// Add all the allocs to stop
for _, e := range diff.stop {
s.plan.AppendUpdate(e.Alloc, structs.AllocDesiredStatusStop, allocNotNeeded)