Merge pull request #17416 from ioito/hotfix/qx-storage-offline-reason

fix(host): log storage offline reason
This commit is contained in:
Zexi Li
2023-06-29 20:16:22 +08:00
committed by GitHub
4 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -371,7 +371,7 @@ func (self *SStorage) PerformOnline(ctx context.Context, userCred mcclient.Token
func (self *SStorage) PerformOffline(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
if self.Status != api.STORAGE_OFFLINE {
err := self.SetStatus(userCred, api.STORAGE_OFFLINE, "")
err := self.SetStatus(userCred, api.STORAGE_OFFLINE, data.String())
if err != nil {
return nil, err
}
+2 -2
View File
@@ -1498,7 +1498,7 @@ func (h *SHostInfo) PutHostOnline() error {
}
_, err := modules.Hosts.PerformAction(
h.GetSession(), h.HostId, "online", data)
h.GetSession(), h.HostId, api.HOST_ONLINE, data)
if err != nil {
logclient.AddSimpleActionLog(h, logclient.ACT_ONLINE, data, hostutils.GetComputeSession(context.Background()).GetToken(), false)
}
@@ -2062,7 +2062,7 @@ func (h *SHostInfo) unregister() {
input := api.HostOfflineInput{
Reason: "host stop",
}
_, err := modules.Hosts.PerformAction(h.GetSession(), h.HostId, "offline", jsonutils.Marshal(input))
_, err := modules.Hosts.PerformAction(h.GetSession(), h.HostId, api.HOST_OFFLINE, jsonutils.Marshal(input))
if err != nil {
if errors.Cause(err) == httperrors.ErrResourceNotFound {
log.Errorf("host not found on region, may be removed, exit cleanly")
+4 -2
View File
@@ -394,12 +394,14 @@ func (s *SRbdStorage) SyncStorageInfo() (jsonutils.JSONObject, error) {
if len(s.StorageId) > 0 {
client, err := s.GetClient()
if err != nil {
return modules.Storages.PerformAction(hostutils.GetComputeSession(context.Background()), s.StorageId, "offline", nil)
reason := jsonutils.Marshal(map[string]string{"reason": errors.Wrapf(err, "GetClient").Error()})
return modules.Storages.PerformAction(hostutils.GetComputeSession(context.Background()), s.StorageId, api.STORAGE_OFFLINE, reason)
}
defer client.Close()
capacity, err := client.GetCapacity()
if err != nil {
return modules.Storages.PerformAction(hostutils.GetComputeSession(context.Background()), s.StorageId, "offline", nil)
reason := jsonutils.Marshal(map[string]string{"reason": errors.Wrapf(err, "GetCapacity").Error()})
return modules.Storages.PerformAction(hostutils.GetComputeSession(context.Background()), s.StorageId, api.STORAGE_OFFLINE, reason)
}
content = map[string]interface{}{
+1 -1
View File
@@ -171,7 +171,7 @@ func (self *CephClient) GetCapacity() (*SCapacity, error) {
stats := cephStats{}
err = resp.Unmarshal(&stats)
if err != nil {
return nil, errors.Wrapf(err, "ret.Unmarshal")
return nil, errors.Wrapf(err, "ret.Unmarshal %s", resp)
}
result.CapacitySizeKb = stats.Stats.TotalBytes / 1024
result.UsedCapacitySizeKb = stats.Stats.TotalUsedBytes / 1024