Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced DCS information #506

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 99 additions & 8 deletions core/integration/dcs/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Plugin struct {

dcsClient *RpcClient
pendingEORs map[string] /*envId*/ int64

detectorMatrix []*dcspb.DetectorInfo
}

type DCSDetectors []dcspb.Detector
Expand All @@ -77,10 +79,11 @@ func NewPlugin(endpoint string) integration.Plugin {
portNumber, _ := strconv.Atoi(u.Port())

return &Plugin{
dcsHost: u.Hostname(),
dcsPort: portNumber,
dcsClient: nil,
pendingEORs: make(map[string]int64),
dcsHost: u.Hostname(),
dcsPort: portNumber,
dcsClient: nil,
pendingEORs: make(map[string]int64),
detectorMatrix: make([]*dcspb.DetectorInfo, 0),
}
}

Expand Down Expand Up @@ -113,6 +116,8 @@ func (p *Plugin) GetData(_ []any) string {
outMap := make(map[string]interface{})
outMap["partitions"] = p.partitionStatesForEnvs(environmentIds)

outMap["detectors"] = p.detectorMatrix

out, err := json.Marshal(outMap)
if err != nil {
return ""
Expand Down Expand Up @@ -176,7 +181,25 @@ func (p *Plugin) Init(instanceId string) error {
time.Sleep(3 * time.Second)
break
}
log.WithField("event", ev.String()).Debug("received DCS event")

if ev != nil && ev.Eventtype == dcspb.EventType_HEARTBEAT {
log.Trace("received DCS heartbeat event")
if dm := ev.GetDetectorMatrix(); len(dm) > 0 {
p.detectorMatrix = dm
}
continue
}

if ev != nil && ev.Eventtype == dcspb.EventType_STATE_CHANGE_EVENT {
log.Trace("received DCS state change event")
if dm := ev.GetDetectorMatrix(); len(dm) > 0 {
p.detectorMatrix = dm
}
continue
}

log.WithField("event", ev.String()).
Debug("received DCS event")
}

log.WithField("endpoint", viper.GetString("dcsServiceEndpoint")).
Expand Down Expand Up @@ -456,7 +479,29 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
if dcsEvent.GetState() == dcspb.DetectorState_SOR_FAILURE {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s PFR failure event from DCS", ecsDet)
logErr := fmt.Errorf("%s PFR failure reported by DCS", ecsDet)
if err != nil {
logErr = fmt.Errorf("%v : %v", err, logErr)
}
log.WithError(logErr).
WithField("event", dcsEvent).
WithField("detector", ecsDet).
WithField("level", infologger.IL_Ops).
WithField("endpoint", viper.GetString("dcsServiceEndpoint")).
WithField("partition", envId).
WithField("call", "PrepareForRun").
Error("DCS error")

call.VarStack["__call_error_reason"] = logErr.Error()
call.VarStack["__call_error"] = callFailedStr

return
}

if dcsEvent.GetState() == dcspb.DetectorState_TIMEOUT {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s PFR timeout reported by DCS", ecsDet)
if err != nil {
logErr = fmt.Errorf("%v : %v", err, logErr)
}
Expand Down Expand Up @@ -793,7 +838,30 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
if dcsEvent.GetState() == dcspb.DetectorState_SOR_FAILURE {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s SOR failure event from DCS", ecsDet)
logErr := fmt.Errorf("%s SOR failure reported by DCS", ecsDet)
if err != nil {
logErr = fmt.Errorf("%v : %v", err, logErr)
}
log.WithError(logErr).
WithField("event", dcsEvent).
WithField("detector", ecsDet).
WithField("level", infologger.IL_Ops).
WithField("endpoint", viper.GetString("dcsServiceEndpoint")).
WithField("run", runNumber64).
WithField("partition", envId).
WithField("call", "StartOfRun").
Error("DCS error")

call.VarStack["__call_error_reason"] = logErr.Error()
call.VarStack["__call_error"] = callFailedStr

return
}

if dcsEvent.GetState() == dcspb.DetectorState_TIMEOUT {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s SOR timeout reported by DCS", ecsDet)
if err != nil {
logErr = fmt.Errorf("%v : %v", err, logErr)
}
Expand Down Expand Up @@ -1106,7 +1174,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
if dcsEvent.GetState() == dcspb.DetectorState_EOR_FAILURE {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s EOR failure event from DCS", ecsDet)
logErr := fmt.Errorf("%s EOR failure reported by DCS", ecsDet)
if err != nil {
if errors.Is(err, io.EOF) {
err = fmt.Errorf("DCS EOR stream unexpectedly terminated from DCS side before completion: %w", err)
Expand All @@ -1129,6 +1197,29 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
return
}

if dcsEvent.GetState() == dcspb.DetectorState_TIMEOUT {
ecsDet := dcsToEcsDetector(dcsEvent.GetDetector())

logErr := fmt.Errorf("%s EOR timeout reported by DCS", ecsDet)
if err != nil {
logErr = fmt.Errorf("%v : %v", err, logErr)
}
log.WithError(logErr).
WithField("event", dcsEvent).
WithField("detector", ecsDet).
WithField("level", infologger.IL_Ops).
WithField("endpoint", viper.GetString("dcsServiceEndpoint")).
WithField("run", runNumber64).
WithField("partition", envId).
WithField("call", "EndOfRun").
Error("DCS error")

call.VarStack["__call_error_reason"] = logErr.Error()
call.VarStack["__call_error"] = callFailedStr

return
}

detectorStatusMap[dcsEvent.GetDetector()] = dcsEvent.GetState()

if dcsEvent.GetState() == dcspb.DetectorState_RUN_OK {
Expand Down
Loading
Loading