Created
November 13, 2015 17:38
-
-
Save drewwells/a0ab033ef692f1d31199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugins/system/system.go b/plugins/system/system.go | |
index 5df57d9..bedefcc 100644 | |
--- a/plugins/system/system.go | |
+++ b/plugins/system/system.go | |
@@ -549,11 +549,14 @@ func (sp *Plugin) getCurrentSystemState() (SystemState, error) { | |
state.NumCpus = runtime.NumCPU() | |
state.Hostname, err = os.Hostname() | |
- state.PoolID = sp.GetPoolID(state.Hostname) | |
if err != nil { | |
slog.Printf("Failed to get hostname") | |
state.Hostname = "Unknown" | |
} | |
+ state.PoolID, err = sp.GetPoolID(state.Hostname) | |
+ if err != nil { | |
+ return SystemState{}, err | |
+ } | |
concreteSigar := sigar.ConcreteSigar{} | |
@@ -637,7 +640,7 @@ func (sp *Plugin) commitSystemDetails(state SystemState) error { | |
var hasInitializedPoolID bool | |
-func (sp *Plugin) GetPoolID(hostname string) string { | |
+func (sp *Plugin) GetPoolID(hostname string) (string, error) { | |
poolID := "default" | |
if sp.storelibClient != nil && !hasInitializedPoolID { | |
req := stack.PoolRequest{ | |
@@ -649,6 +652,7 @@ func (sp *Plugin) GetPoolID(hostname string) string { | |
slog.WarnPrintf("unable to assign host %s to pool %s due to error: %s", hostname, sp.PoolID, err) | |
status.SendHostAssignInitialPool(sp.hostID, hostname, sp.PoolID, err) | |
sp.PoolID = poolID | |
+ return "", err | |
} else { | |
slog.InfoPrintf("assigning host %s to initial pool %s", hostname, sp.PoolID) | |
status.SendHostAssignInitialPool(sp.hostID, hostname, sp.PoolID, err) | |
@@ -660,7 +664,7 @@ func (sp *Plugin) GetPoolID(hostname string) string { | |
} | |
infoSaveMu.Lock() | |
defer infoSaveMu.Unlock() | |
- return poolID | |
+ return poolID, nil | |
} | |
func init() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment