Ignore "no such process" error (#1686)

* Cleanup how status is updated for service. Ignore "no such process" error as it could be that the pid died

* add nice error log to record process error exit
This commit is contained in:
Dominic Wong
2020-06-08 10:47:25 +01:00
parent d613804b0a
commit 86dfcb819b
4 changed files with 35 additions and 26 deletions

View File

@@ -167,11 +167,10 @@ func (k *kubernetes) getService(labels map[string]string, opts ...client.GetOpti
// parse out deployment status and inject into service metadata
if len(kdep.Status.Conditions) > 0 {
svc.Metadata["status"] = kdep.Status.Conditions[0].Type
svc.Status(kdep.Status.Conditions[0].Type, nil)
svc.Metadata["started"] = kdep.Status.Conditions[0].LastUpdateTime
delete(svc.Metadata, "error")
} else {
svc.Metadata["status"] = "n/a"
svc.Status("n/a", nil)
}
// get the real status
@@ -214,8 +213,7 @@ func (k *kubernetes) getService(labels map[string]string, opts ...client.GetOpti
}
}
// TODO: set from terminated
svc.Metadata["status"] = status
svc.Status(status, nil)
}
// save deployment

View File

@@ -3,6 +3,7 @@ package kubernetes
import (
"encoding/json"
"strings"
"time"
"github.com/micro/go-micro/v2/logger"
"github.com/micro/go-micro/v2/runtime"
@@ -185,8 +186,10 @@ func (s *service) Update(k client.Client, opts ...client.UpdateOption) error {
}
func (s *service) Status(status string, err error) {
s.Metadata["lastStatusUpdate"] = time.Now().Format(time.RFC3339)
if err == nil {
s.Metadata["status"] = status
delete(s.Metadata, "error")
return
}
s.Metadata["status"] = "error"