Merge branch 'V5.1' into feature/volume

This commit is contained in:
凡羊羊 2019-12-19 18:06:29 +08:00
commit 84eaf21e51
4 changed files with 23 additions and 6 deletions

View File

@ -85,6 +85,7 @@ func NewDependServiceHealthController() (*DependServiceHealthController, error)
//Check check all conditions
func (d *DependServiceHealthController) Check() {
logrus.Info("start denpenent health check.")
ticker := time.NewTicker(d.interval)
defer ticker.Stop()
check := func() bool {
@ -97,7 +98,7 @@ func (d *DependServiceHealthController) Check() {
}
for {
if check() {
logrus.Info("Depend services all check passed,will start service")
logrus.Info("Depend services all check passed, will start service")
return
}
select {
@ -115,6 +116,8 @@ func (d *DependServiceHealthController) checkClusters() bool {
}
func (d *DependServiceHealthController) checkEDS() bool {
logrus.Infof("start checking eds; dependent service cluster names: %s", d.dependServiceClusterNames)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@ -131,6 +134,13 @@ func (d *DependServiceHealthController) checkEDS() bool {
clusterLoadAssignments := envoyv2.ParseLocalityLbEndpointsResource(res.Resources)
readyClusters := make(map[string]bool, len(clusterLoadAssignments))
logrus.Infof("received cluster load assignments; length: %v; names: %s", len(clusterLoadAssignments), func() string {
var clusternames []string
for _, cla := range clusterLoadAssignments {
clusternames = append(clusternames, cla.GetClusterName())
}
return strings.Join(clusternames, ",")
}())
for _, cla := range clusterLoadAssignments {
// clusterName := fmt.Sprintf("%s_%s_%s_%d", namespace, serviceAlias, destServiceAlias, service.Spec.Ports[0].Port)
clusterName := cla.GetClusterName()
@ -144,13 +154,16 @@ func (d *DependServiceHealthController) checkEDS() bool {
}
}
}
return false
}()
logrus.Infof("cluster name: %s; ready: %v", clusterName, ready)
readyClusters[clusterName] = ready
}
for _, cn := range d.dependServiceClusterNames {
if _, ok := readyClusters[cn]; !ok {
if ready := readyClusters[cn]; !ready {
logrus.Infof("%s not ready.", cn)
return false
}
}

View File

@ -128,6 +128,9 @@ func (m *filePlugin) GetMessages(serviceID, level string, length int) (interface
if err != nil {
break
}
if len(line) == 0 {
continue
}
lines = append(lines, string(line))
}
return lines, nil

View File

@ -23,7 +23,6 @@ import (
"strconv"
"github.com/go-chi/chi"
util "github.com/goodrain/rainbond/util"
httputil "github.com/goodrain/rainbond/util/http"
)
@ -35,5 +34,5 @@ func (s *SocketServer) getDockerLogs(w http.ResponseWriter, r *http.Request) {
rows = 100
}
loglist := s.storemanager.GetDockerLogs(serviceID, rows)
httputil.ReturnSuccess(r, w, util.Reverse(loglist))
httputil.ReturnSuccess(r, w, loglist)
}

View File

@ -255,7 +255,9 @@ func (h *dockerLogStore) GetHistoryMessage(eventID string, length int) (re []str
defer h.rwLock.RUnlock()
if ba, ok := h.barrels[eventID]; ok {
for _, m := range ba.barrel {
re = append(re, string(m.Content))
if len(m.Content) > 0 {
re = append(re, string(m.Content))
}
}
}
logrus.Debugf("want length: %d; the length of re: %d;", length, len(re))
@ -272,6 +274,6 @@ func (h *dockerLogStore) GetHistoryMessage(eventID string, length int) (re []str
if result == nil || err != nil {
return re
}
re = append(re, result.([]string)...)
re = append(result.([]string), re...)
return re
}