Skip to content

Commit

Permalink
0 compute == error
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Jul 3, 2017
1 parent 2b0f088 commit ca38020
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions client/fingerprint/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ func (f *CPUFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (bo
tt = cfg.CpuCompute
}

// Set the node compute resources if they are detected/configured
if tt > 0 {
node.Attributes["cpu.totalcompute"] = fmt.Sprintf("%d", tt)

if node.Resources == nil {
node.Resources = &structs.Resources{}
}

node.Resources.CPU = tt
} else {
f.logger.Printf("[INFO] fingerprint.cpu: cannot detect cpu total compute. "+
// Return an error if no cpu was detected or explicitly set as this
// node would be unable to receive any allocations.
if tt == 0 {
return false, fmt.Errorf("cannot detect cpu total compute. "+
"CPU compute must be set manually using the client config option %q",
"cpu_total_compute")
}

node.Attributes["cpu.totalcompute"] = fmt.Sprintf("%d", tt)

if node.Resources == nil {
node.Resources = &structs.Resources{}
}

node.Resources.CPU = tt
return true, nil
}

0 comments on commit ca38020

Please sign in to comment.