mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
[REV] add timout status in event
This commit is contained in:
parent
82b30ab29d
commit
0cc3bba57e
@ -98,7 +98,7 @@ func (n *node) UpdateNodeStatus(nid, status string) (*client.HostNode, *util.API
|
||||
var gc client.HostNode
|
||||
res.Bean = &gc
|
||||
req := fmt.Sprintf(`{"status":"%s"}`, status)
|
||||
code, err := n.DoRequest(n.prefix+"/"+nid+"/status", "POST", bytes.NewBuffer([]byte(req)), &res)
|
||||
code, err := n.DoRequest(n.prefix+"/"+nid+"/status", "PUT", bytes.NewBuffer([]byte(req)), &res)
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleError(code, err)
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ func finalUpdateEvent(target *model.ServiceEvent, old *model.ServiceEvent) {
|
||||
if target.FinalStatus != "" {
|
||||
old.FinalStatus = target.FinalStatus
|
||||
}
|
||||
|
||||
old.EndTime = time.Now().String()
|
||||
if old.Status == "failure" && old.OptType == "callback" {
|
||||
old.DeployVersion = old.OldDeployVersion
|
||||
|
@ -286,25 +286,20 @@ func (h *handleMessageStore) handleBarrelEvent() {
|
||||
eventID := event[1]
|
||||
status := event[2]
|
||||
message := event[3]
|
||||
// webhook.GetManager().RunWebhookWithParameter(webhook.UpDateEventStatus, nil,
|
||||
// map[string]interface{}{"event_id": eventID, "status": status, "message": message})
|
||||
|
||||
event := model.ServiceEvent{}
|
||||
event.EventID = eventID
|
||||
event.Status = status
|
||||
event.Message = message
|
||||
logrus.Infof("updating event %s's status: %s", eventID, status)
|
||||
cdb.GetManager().ServiceEventDao().UpdateModel(&event)
|
||||
|
||||
//todo get version_info by event_id ,update final_status,optional delete
|
||||
if err := cdb.GetManager().ServiceEventDao().UpdateModel(&event); err != nil {
|
||||
logrus.Errorf("update event status failure %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
if event[0] == "code-version" { //代码版本
|
||||
if len(event) == 3 {
|
||||
eventID := event[1]
|
||||
codeVersion := strings.TrimSpace(event[2])
|
||||
// webhook.GetManager().RunWebhookWithParameter(webhook.UpdateEventCodeVersion, nil,
|
||||
// map[string]interface{}{"event_id": eventID, "code_version": codeVersion})
|
||||
event := model.ServiceEvent{}
|
||||
event.EventID = eventID
|
||||
event.CodeVersion = codeVersion
|
||||
|
@ -610,13 +610,19 @@ func installNode(node *client.HostNode) {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.Installing)
|
||||
if _, err := clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.Installing); err != nil {
|
||||
logrus.Errorf("update node %s status failure %s", node.ID, err.Error())
|
||||
}
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
logrus.Errorf("Error executing shell script %s", err.Error())
|
||||
clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.InstallFailed)
|
||||
if _, err := clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.InstallFailed); err != nil {
|
||||
logrus.Errorf("update node %s status failure %s", node.ID, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
if _, err := clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.InstallSuccess); err != nil {
|
||||
logrus.Errorf("update node %s status failure %s", node.ID, err.Error())
|
||||
}
|
||||
logrus.Infof("Install node %s successful", node.ID)
|
||||
clients.RegionClient.Nodes().UpdateNodeStatus(node.ID, client.InstallSuccess)
|
||||
}
|
||||
|
@ -161,7 +161,9 @@ func (n *Cluster) getKubeNodeCount() int {
|
||||
//handleNodeStatus Master integrates node status and kube node status
|
||||
func (n *Cluster) handleNodeStatus(v *client.HostNode) {
|
||||
if v.Status == client.NotInstalled || v.Status == client.Installing || v.Status == client.InstallFailed {
|
||||
return
|
||||
if v.NodeStatus.Status != "running" {
|
||||
return
|
||||
}
|
||||
}
|
||||
if time.Now().Sub(v.NodeStatus.NodeUpdateTime) > time.Minute*1 {
|
||||
v.Status = client.Unknown
|
||||
|
@ -81,8 +81,8 @@ type HostNode struct {
|
||||
AvailableMemory int64 `json:"available_memory"`
|
||||
AvailableCPU int64 `json:"available_cpu"`
|
||||
Mode string `json:"mode"`
|
||||
Role HostRule `json:"role"` //compute, manage, storage,loadbalance
|
||||
Status string `json:"status"` //node status is: running, unknow
|
||||
Role HostRule `json:"role"` //compute, manage, storage,loadbalance
|
||||
Status string `json:"status"`
|
||||
Labels map[string]string `json:"labels"` //节点标签 内置标签+用户自定义标签
|
||||
Unschedulable bool `json:"unschedulable"` //设置值
|
||||
PodCIDR string `json:"podCIDR"`
|
||||
|
@ -167,6 +167,11 @@ func GetCallbackLoggerOption() map[string]string {
|
||||
return map[string]string{"step": "callback", "status": "failure"}
|
||||
}
|
||||
|
||||
//GetTimeoutLoggerOption get callback logger
|
||||
func GetTimeoutLoggerOption() map[string]string {
|
||||
return map[string]string{"step": "callback", "status": "timeout"}
|
||||
}
|
||||
|
||||
//GetLastLoggerOption get last logger
|
||||
func GetLastLoggerOption() map[string]string {
|
||||
return map[string]string{"step": "last", "status": "success"}
|
||||
|
@ -45,8 +45,12 @@ func (s *scalingController) Begin() {
|
||||
defer wait.Done()
|
||||
service.Logger.Info("App runtime begin horizontal scaling app service "+service.ServiceAlias, getLoggerOption("starting"))
|
||||
if err := s.scalingOne(service); err != nil {
|
||||
service.Logger.Error(fmt.Sprintf("horizontal scaling service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("horizontal scaling service %s failure %s", service.ServiceAlias, err.Error())
|
||||
if err != ErrWaitTimeOut {
|
||||
service.Logger.Error(fmt.Sprintf("horizontal scaling service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("horizontal scaling service %s failure %s", service.ServiceAlias, err.Error())
|
||||
} else {
|
||||
service.Logger.Error(fmt.Sprintf("horizontal scaling service timeout,please waiting it complete"), GetTimeoutLoggerOption())
|
||||
}
|
||||
} else {
|
||||
service.Logger.Info(fmt.Sprintf("horizontal scaling service %s success", service.ServiceAlias), GetLastLoggerOption())
|
||||
}
|
||||
|
@ -61,9 +61,10 @@ func (s *startController) Begin() {
|
||||
service.Logger.Error(fmt.Sprintf("Start service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("start service %s failure %s", service.ServiceAlias, err.Error())
|
||||
s.errorCallback(service)
|
||||
} else {
|
||||
logrus.Debugf("Start service %s timeout, please wait or read service log.", service.ServiceAlias)
|
||||
service.Logger.Error(fmt.Sprintf("Start service %s timeout,please wait or read service log.", service.ServiceAlias), GetTimeoutLoggerOption())
|
||||
}
|
||||
logrus.Debugf("Start service %s timeout, please wait or read service log.", service.ServiceAlias)
|
||||
service.Logger.Error(fmt.Sprintf("Start service %s timeout,please wait or read service log.", service.ServiceAlias), GetCallbackLoggerOption())
|
||||
} else {
|
||||
logrus.Debugf("Start service %s success", service.ServiceAlias)
|
||||
service.Logger.Info(fmt.Sprintf("Start service %s success", service.ServiceAlias), GetLastLoggerOption())
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"github.com/goodrain/rainbond/event"
|
||||
"github.com/goodrain/rainbond/worker/appm/store"
|
||||
"github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
//ErrWaitTimeOut wait time out
|
||||
@ -123,7 +124,6 @@ func WaitUpgradeReady(store store.Storer, a *v1.AppService, timeout time.Duratio
|
||||
case <-ticker.C:
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func printLogger(a *v1.AppService, logger event.Logger) {
|
||||
var ready int32
|
||||
@ -134,4 +134,12 @@ func printLogger(a *v1.AppService, logger event.Logger) {
|
||||
ready = a.GetDeployment().Status.ReadyReplicas
|
||||
}
|
||||
logger.Info(fmt.Sprintf("current instance(count:%d ready:%d notready:%d)", len(a.GetPods()), ready, int32(len(a.GetPods()))-ready), map[string]string{"step": "appruntime", "status": "running"})
|
||||
pods := a.GetPods()
|
||||
for _, pod := range pods {
|
||||
for _, con := range pod.Status.Conditions {
|
||||
if con.Status == corev1.ConditionFalse {
|
||||
logger.Debug(fmt.Sprintf("instance %s %s status is %s: %s", pod.Name, con.Type, con.Status, con.Message), map[string]string{"step": "appruntime", "status": "running"})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,12 @@ func (s *stopController) Begin() {
|
||||
defer wait.Done()
|
||||
service.Logger.Info("App runtime begin stop app service "+service.ServiceAlias, getLoggerOption("starting"))
|
||||
if err := s.stopOne(service); err != nil {
|
||||
service.Logger.Error(fmt.Sprintf("stop service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("stop service %s failure %s", service.ServiceAlias, err.Error())
|
||||
if err != ErrWaitTimeOut {
|
||||
service.Logger.Error(fmt.Sprintf("stop service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("stop service %s failure %s", service.ServiceAlias, err.Error())
|
||||
} else {
|
||||
service.Logger.Error(fmt.Sprintf("stop service timeout,please waiting it closed"), GetTimeoutLoggerOption())
|
||||
}
|
||||
} else {
|
||||
service.Logger.Info(fmt.Sprintf("stop service %s success", service.ServiceAlias), GetLastLoggerOption())
|
||||
}
|
||||
|
@ -45,8 +45,12 @@ func (s *upgradeController) Begin() {
|
||||
defer wait.Done()
|
||||
service.Logger.Info("App runtime begin upgrade app service "+service.ServiceAlias, getLoggerOption("starting"))
|
||||
if err := s.upgradeOne(service); err != nil {
|
||||
service.Logger.Error(fmt.Sprintf("upgrade service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("upgrade service %s failure %s", service.ServiceAlias, err.Error())
|
||||
if err != ErrWaitTimeOut {
|
||||
service.Logger.Error(fmt.Sprintf("upgrade service %s failure %s", service.ServiceAlias, err.Error()), GetCallbackLoggerOption())
|
||||
logrus.Errorf("upgrade service %s failure %s", service.ServiceAlias, err.Error())
|
||||
} else {
|
||||
service.Logger.Error(fmt.Sprintf("upgrade service timeout,please waiting it complete"), GetTimeoutLoggerOption())
|
||||
}
|
||||
} else {
|
||||
service.Logger.Info(fmt.Sprintf("upgrade service %s success", service.ServiceAlias), GetLastLoggerOption())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user