Skip to content

Instantly share code, notes, and snippets.

@drewwells
Created November 13, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewwells/a0ab033ef692f1d31199 to your computer and use it in GitHub Desktop.
Save drewwells/a0ab033ef692f1d31199 to your computer and use it in GitHub Desktop.
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