upgrade go chassis, fix graceful shutdown panic (#46)
diff --git a/go.mod b/go.mod
index ecdf543..7ddf3e1 100644
--- a/go.mod
+++ b/go.mod
@@ -6,13 +6,13 @@
github.com/envoyproxy/go-control-plane v0.6.0
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-chassis/foundation v0.0.0-20190203091418-304855ea28bf
- github.com/go-chassis/go-archaius v0.7.0
- github.com/go-chassis/go-chassis v1.2.3-0.20190305021215-3e7fe2d6b2af
+ github.com/go-chassis/go-archaius v0.14.0
+ github.com/go-chassis/go-cc-client v0.6.0
+ github.com/go-chassis/go-chassis v1.4.0
github.com/go-chassis/gohessian v0.0.0-20180702061429-e5130c25af55
- github.com/go-mesh/openlogging v0.0.0-20181122085847-3daf3ad8ed35
+ github.com/go-mesh/openlogging v0.0.0-20181205082104-3d418c478b2d
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.2.0
- github.com/golang/snappy v0.0.1 // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/lyft/protoc-gen-validate v0.0.11 // indirect
@@ -51,4 +51,4 @@
google.golang.org/appengine v1.2.0 => github.com/golang/appengine v1.2.0
google.golang.org/genproto v0.0.0-20181101192439-c830210a61df => github.com/google/go-genproto v0.0.0-20181101192439-c830210a61df
google.golang.org/grpc v1.14.0 => github.com/grpc/grpc-go v1.14.0
-)
\ No newline at end of file
+)
diff --git a/pkg/egress/egress_test.go b/pkg/egress/egress_test.go
index ff54e5c..c97ed5f 100644
--- a/pkg/egress/egress_test.go
+++ b/pkg/egress/egress_test.go
@@ -26,7 +26,11 @@
config.Init()
mesherconfig.Init()
egress.Init()
- control.Init()
+ opts := control.Options{
+ Infra: config.GlobalDefinition.Panel.Infra,
+ Address: config.GlobalDefinition.Panel.Settings["address"],
+ }
+ control.Init(opts)
var yamlContent = `---
egress:
infra: cse # pilot or cse
diff --git a/pkg/egress/pilot/pilotsource.go b/pkg/egress/pilot/pilotsource.go
index 5216b19..16a71f8 100644
--- a/pkg/egress/pilot/pilotsource.go
+++ b/pkg/egress/pilot/pilotsource.go
@@ -74,11 +74,11 @@
type pilotSource struct {
refreshInverval time.Duration
fetcher istioinfra.XdsClient
-
- mu sync.RWMutex
- pmu sync.RWMutex
- Configurations map[string]interface{}
- PortToService map[string]string
+ priority int
+ mu sync.RWMutex
+ pmu sync.RWMutex
+ Configurations map[string]interface{}
+ PortToService map[string]string
}
func newPilotSource(o egress.Options) (*pilotSource, error) {
@@ -95,6 +95,7 @@
Configurations: map[string]interface{}{},
PortToService: map[string]string{},
fetcher: *xdsClient,
+ priority: egressPilotSourcePriority,
}, nil
}
@@ -112,7 +113,7 @@
}
func (r *pilotSource) GetSourceName() string { return egressPilotSourceName }
-func (r *pilotSource) GetPriority() int { return egressPilotSourcePriority }
+func (r *pilotSource) GetPriority() int { return r.priority }
func (r *pilotSource) Cleanup() error { return nil }
func (r *pilotSource) AddDimensionInfo(d string) (map[string]string, error) { return nil, nil }
@@ -179,6 +180,10 @@
r.pmu.RUnlock()
}
+//SetPriority custom priority
+func (r *pilotSource) SetPriority(priority int) {
+ r.priority = priority
+}
func (r *pilotSource) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
// Periodically refresh configurations
ticker := time.NewTicker(r.refreshInverval)
diff --git a/protocol/http/http_server.go b/protocol/http/http_server.go
index d6dbda0..bbc73e1 100644
--- a/protocol/http/http_server.go
+++ b/protocol/http/http_server.go
@@ -29,12 +29,14 @@
"net/http"
"strings"
+ "context"
chassisCom "github.com/go-chassis/go-chassis/core/common"
chassisConfig "github.com/go-chassis/go-chassis/core/config"
"github.com/go-chassis/go-chassis/core/lager"
"github.com/go-chassis/go-chassis/core/server"
chassisTLS "github.com/go-chassis/go-chassis/core/tls"
"github.com/go-mesh/mesher/pkg/runtime"
+ "github.com/go-mesh/openlogging"
)
const (
@@ -181,13 +183,13 @@
func (hs *httpServer) Stop() error {
//go 1.8+ drain connections before stop server
if hs.server == nil {
- lager.Logger.Info("http server don't need to be stopped")
+ openlogging.Info("http server don't need to be stopped")
return nil
}
- if err := hs.server.Shutdown(nil); err != nil {
+ if err := hs.server.Shutdown(context.TODO()); err != nil {
panic(err)
}
- lager.Logger.Info("Mesher gracefully stopped")
+ openlogging.Info("Mesher gracefully stopped")
return nil
}
diff --git a/server/server.go b/server/server.go
index 1bee253..90875e3 100644
--- a/server/server.go
+++ b/server/server.go
@@ -11,6 +11,7 @@
"github.com/go-chassis/go-chassis"
"github.com/go-chassis/go-chassis/core/lager"
+ "github.com/go-mesh/openlogging"
)
// Run run mesher proxy server
@@ -25,7 +26,7 @@
bootstrap.RegisterFramework()
bootstrap.SetHandlers()
if err := chassis.Init(); err != nil {
- lager.Logger.Error("Go chassis init failed, Mesher is not available: " + err.Error())
+ openlogging.Error("Go chassis init failed, Mesher is not available: " + err.Error())
panic(err)
}
if err := bootstrap.InitEgressChain(); err != nil {
@@ -34,12 +35,12 @@
}
if err := bootstrap.Start(); err != nil {
- lager.Logger.Error("Bootstrap failed: " + err.Error())
+ openlogging.Error("Bootstrap failed: " + err.Error())
panic(err)
}
lager.Logger.Infof("Version is %s", version.Ver().Version)
if err := health.Run(); err != nil {
- lager.Logger.Error("Health manager start failed: " + err.Error())
+ openlogging.Error("Health manager start failed: " + err.Error())
panic(err)
}
profile()
@@ -53,9 +54,9 @@
if config.GetConfig().PProf.Listen == "" {
config.GetConfig().PProf.Listen = "127.0.0.1:6060"
}
- lager.Logger.Warn("Enable pprof on " + config.GetConfig().PProf.Listen)
+ openlogging.Warn("Enable pprof on " + config.GetConfig().PProf.Listen)
if err := http.ListenAndServe(config.GetConfig().PProf.Listen, nil); err != nil {
- lager.Logger.Error("Can not enable pprof: " + err.Error())
+ openlogging.Error("Can not enable pprof: " + err.Error())
}
}()
}