Only run specific client during Instance polling
@@ -363,18 +363,14 @@ func (imc *InstanceManagerController) pollProcesses(im *longhorn.InstanceManager
return errors.New("Instance Manager IP was not set before polling")
}
+ switch im.Spec.Type {
+ case types.InstanceManagerTypeEngine:
engineClient := client.NewEngineManagerClient(im.Status.IP + defaultManagerPort)
engines, err := engineClient.EngineList()
if err != nil {
return err
}
- processClient := client.NewProcessManagerClient(im.Status.IP + defaultManagerPort)
- processes, err := processClient.ProcessList()
- if err != nil {
- return err
- }
-
updatedInstanceMap := make(map[string]types.InstanceProcessStatus)
for name, engine := range engines {
updatedInstanceMap[name] = types.InstanceProcessStatus{
@@ -388,6 +384,15 @@ func (imc *InstanceManagerController) pollProcesses(im *longhorn.InstanceManager
Type: types.InstanceTypeEngine,
}
}
+ im.Status.Instances = updatedInstanceMap
+ case types.InstanceManagerTypeReplica:
+ processClient := client.NewProcessManagerClient(im.Status.IP + defaultManagerPort)
+ processes, err := processClient.ProcessList()
+ if err != nil {
+ return err
+ }
+
+ updatedInstanceMap := make(map[string]types.InstanceProcessStatus)
for name, process := range processes {
updatedInstanceMap[name] = types.InstanceProcessStatus{
ErrorMsg: process.ProcessStatus.ErrorMsg,
@@ -399,6 +404,9 @@ func (imc *InstanceManagerController) pollProcesses(im *longhorn.InstanceManager
}
}
im.Status.Instances = updatedInstanceMap
+ default:
+ return fmt.Errorf("BUG: instance manager %v has invalid type %v", im.Name, im.Spec.Type)
+ }
return nil
}
