mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-07 06:02:09 +08:00
fix: system server randomly lose connectivity in vpc network
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
app_common "yunion.io/x/onecloud/pkg/cloudcommon/app"
|
||||
common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
|
||||
"yunion.io/x/onecloud/pkg/util/atexit"
|
||||
@@ -60,6 +61,7 @@ func main() {
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
ctx = context.WithValue(ctx, "wg", wg)
|
||||
ctx = context.WithValue(ctx, appctx.APP_CONTEXT_KEY_APPNAME, "vpcagent")
|
||||
wg.Add(1)
|
||||
go w.Start(ctx)
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ func GetModels(opts *GetModelsOptions) error {
|
||||
}
|
||||
|
||||
listOptions := options.BaseListOptions{
|
||||
System: options.Bool(true),
|
||||
Admin: options.Bool(true),
|
||||
Details: options.Bool(opts.IncludeDetails),
|
||||
ShowEmulated: options.Bool(opts.IncludeEmulated),
|
||||
|
||||
@@ -236,7 +236,14 @@ func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
skipLog = true
|
||||
}
|
||||
if !skipLog {
|
||||
log.Infof("%s %d %s %s %s (%s) %.2fms", app.hostId, lrw.status, rid, r.Method, r.URL, r.RemoteAddr, duration)
|
||||
peerServiceName := r.Header.Get("X-Yunion-Peer-Service-Name")
|
||||
var remote string
|
||||
if len(peerServiceName) > 0 {
|
||||
remote = fmt.Sprintf("%s:%s", r.RemoteAddr, peerServiceName)
|
||||
} else {
|
||||
remote = r.RemoteAddr
|
||||
}
|
||||
log.Infof("%s %d %s %s %s (%s) %.2fms", app.hostId, lrw.status, rid, r.Method, r.URL, remote, duration)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func init() {
|
||||
"guestnetwork",
|
||||
"guestnetworks",
|
||||
[]string{"Guest_ID", "Guest",
|
||||
"Network_ID", "Network", "Mac_addr",
|
||||
"Network_ID", "Network", "Mac_addr", "Mapped_Ip_Addr",
|
||||
"IP_addr", "Driver", "BW_limit", "Index",
|
||||
"Virtual", "Ifname", "team_with"},
|
||||
[]string{},
|
||||
|
||||
@@ -541,6 +541,8 @@ func (opts *ServerCreateOptionalOptions) OptionalParams() (*computeapi.ServerCre
|
||||
// set description
|
||||
params.Description = opts.Desc
|
||||
|
||||
params.IsSystem = &opts.System
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -494,14 +494,18 @@ func requestInternal(client sClient, ctx context.Context, method THttpMethod, ur
|
||||
}
|
||||
ctxData := appctx.FetchAppContextData(ctx)
|
||||
var clientTrace *trace.STrace
|
||||
if !ctxData.Trace.IsZero() {
|
||||
if len(ctxData.ServiceName) > 0 {
|
||||
if !ctxData.Trace.IsZero() {
|
||||
clientTrace = &ctxData.Trace
|
||||
}
|
||||
addr, port, err := GetAddrPort(urlStr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
clientTrace = trace.StartClientTrace(&ctxData.Trace, addr, port, ctxData.ServiceName)
|
||||
clientTrace = trace.StartClientTrace(clientTrace, addr, port, ctxData.ServiceName)
|
||||
clientTrace.AddClientRequestHeader(header)
|
||||
}
|
||||
|
||||
if len(ctxData.RequestId) > 0 {
|
||||
header.Set("X-Request-Id", ctxData.RequestId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user