mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-05 05:07:38 +08:00
Merge pull request #413 from GLYASAI/eventstatus
[FIX] wrong status for oom event
This commit is contained in:
commit
1948c2fb83
@ -58,7 +58,10 @@ var EventFinalStatusRunning EventFinalStatus = "running"
|
||||
// EventFinalStatusEmpty -
|
||||
var EventFinalStatusEmpty EventFinalStatus = "empty"
|
||||
|
||||
// EventFinalStatus -
|
||||
// EventFinalStatusEmptyComplete -
|
||||
var EventFinalStatusEmptyComplete EventFinalStatus = "emptycomplete"
|
||||
|
||||
// EventStatus -
|
||||
type EventStatus string
|
||||
|
||||
// String -
|
||||
|
@ -122,7 +122,7 @@ func (c *EventDaoImpl) GetEventsByTarget(target, targetID string, offset, limit
|
||||
if err := db.Find(&result).Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err := db.Offset(offset).Limit(limit).Order("start_time DESC, id DESC").Find(&result).Error; err != nil {
|
||||
if err := db.Offset(offset).Limit(limit).Order("create_time DESC, id DESC").Find(&result).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return result, 0, nil
|
||||
}
|
||||
@ -171,7 +171,7 @@ func (c *EventDaoImpl) UnfinishedEvents(target, targetID string, optTypes ...str
|
||||
// LatestFailurePodEvent returns the latest failure pod event.
|
||||
func (c *EventDaoImpl) LatestFailurePodEvent(podName string) (*model.ServiceEvent, error) {
|
||||
var event model.ServiceEvent
|
||||
if err := c.DB.Where("target=? and target_id=? and status=?", model.TargetTypePod, podName, model.EventStatusFailure.String()).
|
||||
if err := c.DB.Where("target=? and target_id=? and status=? and final_status<>?", model.TargetTypePod, podName, model.EventStatusFailure.String(), model.EventFinalStatusEmptyComplete.String()).
|
||||
Last(&event).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -19,19 +19,18 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
cdb "github.com/goodrain/rainbond/db"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
"github.com/goodrain/rainbond/eventlog/conf"
|
||||
"github.com/goodrain/rainbond/eventlog/db"
|
||||
"github.com/goodrain/rainbond/eventlog/util"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type handleMessageStore struct {
|
||||
@ -288,7 +287,11 @@ func (h *handleMessageStore) handleBarrelEvent() {
|
||||
|
||||
} else {
|
||||
event.Status = status
|
||||
event.FinalStatus = "complete"
|
||||
if event.FinalStatus == "empty" {
|
||||
event.FinalStatus = model.EventFinalStatusEmptyComplete.String()
|
||||
} else {
|
||||
event.FinalStatus = "complete"
|
||||
}
|
||||
event.Message = message
|
||||
event.EndTime = time.Now().Format(time.RFC3339)
|
||||
logrus.Infof("updating event %s's status: %s", eventID, status)
|
||||
|
@ -113,25 +113,10 @@ func podEventHandler(clientset kubernetes.Interface, store Storer) cache.Resourc
|
||||
AddFunc: func(obj interface{}) {
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
pod := obj.(*corev1.Pod)
|
||||
tenantID, serviceID, _, _ := k8sutil.ExtractLabels(pod.GetLabels())
|
||||
if hasUnfinishedUserActions(serviceID) {
|
||||
return
|
||||
}
|
||||
|
||||
if store.IsSvcClosed(serviceID) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err := createSystemEvent(tenantID, serviceID, pod.GetName(), PodEventTypeAbnormalShtdown.String(), model.EventStatusSuccess.String())
|
||||
if err != nil {
|
||||
logrus.Warningf("pod: %s; type: %s; error creating event: %v", pod.GetName(), PodEventTypeAbnormalShtdown.String(), err)
|
||||
return
|
||||
}
|
||||
},
|
||||
UpdateFunc: func(old, cur interface{}) {
|
||||
cpod := cur.(*corev1.Pod)
|
||||
|
||||
|
||||
recordUpdateEvent(clientset, cpod, defDetermineOptType)
|
||||
},
|
||||
}
|
||||
@ -193,7 +178,7 @@ func recordUpdateEvent(clientset kubernetes.Interface, pod *corev1.Pod, f determ
|
||||
logrus.Debugf("Service id: %s; %s.", serviceID, msg)
|
||||
loggerOpt := event.GetLoggerOption("failure")
|
||||
if time.Now().Sub(state.Running.StartedAt.Time) > 2*time.Minute {
|
||||
loggerOpt = event.GetLastLoggerOption() // TODO
|
||||
loggerOpt = event.GetCallbackLoggerOption()
|
||||
_, err := createSystemEvent(tenantID, serviceID, pod.GetName(), PodEventTypeAbnormalRecovery.String(), model.EventStatusSuccess.String())
|
||||
if err != nil {
|
||||
logrus.Warningf("pod: %s; type: %s; error creating event: %v", pod.GetName(), PodEventTypeAbnormalRecovery.String(), err)
|
||||
|
Loading…
Reference in New Issue
Block a user