Skip to content

Commit e7513b2

Browse files
committed
[core] less verbose log in TRG plugin + fix missing run number
1 parent c3464f8 commit e7513b2

File tree

1 file changed

+41
-95
lines changed

1 file changed

+41
-95
lines changed

core/integration/trg/plugin.go

Lines changed: 41 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,17 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
558558
}
559559
// global runs only
560560
stack["RunLoad"] = func() (out string) { // must formally return string even when we return nothing
561-
log.WithField("partition", envId).
562-
WithField("level", infologger.IL_Ops).
561+
rn := varStack["run_number"]
562+
var runNumber64 int64
563+
runNumber64, err := strconv.ParseInt(rn, 10, 32)
564+
if err != nil {
565+
log.WithField("partition", envId).
566+
WithError(err).
567+
Error("cannot acquire run number for Run Load")
568+
}
569+
log := log.WithField("run", runNumber64).WithField("partition", envId)
570+
571+
log.WithField("level", infologger.IL_Ops).
563572
Info("ALIECS SOR operation : performing TRG Run Load Request")
564573

565574
parentRole, ok := call.GetParentRole().(callable.ParentRole)
@@ -570,30 +579,17 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
570579

571580
globalConfig, ok := varStack["trg_global_config"]
572581
log.WithField("globalConfig", globalConfig).
573-
WithField("partition", envId).
574582
Debug("not a TRG Global Run, continuing with TRG Run Start")
575583
if !ok {
576-
log.WithField("partition", envId).
577-
Debug("no TRG Global config set")
584+
log.Debug("no TRG Global config set")
578585
globalConfig = ""
579586
}
580587
// TODO (malexis): pass consul key to TRG if avail
581588

582-
rn := varStack["run_number"]
583-
var runNumber64 int64
584-
runNumber64, err := strconv.ParseInt(rn, 10, 32)
585-
if err != nil {
586-
log.WithField("partition", envId).
587-
WithError(err).
588-
Error("cannot acquire run number for Run Load")
589-
}
590-
591589
trgDetectorsParam, ok := varStack["trg_detectors"]
592590
if !ok {
593591
// "" -all required must be ready
594-
log.WithField("partition", envId).
595-
WithField("run", runNumber64).
596-
Debug("empty TRG detectors list provided")
592+
log.Debug("empty TRG detectors list provided")
597593
trgDetectorsParam = ""
598594
}
599595

@@ -603,7 +599,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
603599
if err != nil {
604600
log.WithError(err).
605601
WithField("level", infologger.IL_Support).
606-
WithField("partition", envId).
607602
WithField("call", "RunLoad").
608603
Error("TRG error")
609604
call.VarStack["__call_error_reason"] = err.Error()
@@ -615,9 +610,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
615610
// standalone run
616611
if len(strings.Split(detectors, " ")) < 2 && varStack["trg_global_run_enabled"] == "false" {
617612
// we do not load any run cause it is standalone
618-
log.WithField("partition", envId).
619-
WithField("run", runNumber64).
620-
Debug("not a TRG Global Run, continuing with TRG Run Start")
613+
log.Debug("not a TRG Global Run, continuing with TRG Run Start")
621614

622615
return
623616
}
@@ -629,7 +622,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
629622
if err != nil {
630623
log.WithError(err).
631624
WithField("level", infologger.IL_Support).
632-
WithField("partition", envId).
633625
WithField("call", "RunLoad").
634626
Warn("could not parse ctp_readout_enabled value")
635627
}
@@ -647,8 +639,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
647639
log.WithError(err).
648640
WithField("level", infologger.IL_Support).
649641
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
650-
WithField("run", runNumber64).
651-
WithField("partition", envId).
652642
WithField("call", "RunLoad").
653643
Error("TRG error")
654644

@@ -664,8 +654,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
664654
log.WithError(err).
665655
WithField("level", infologger.IL_Support).
666656
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
667-
WithField("run", runNumber64).
668-
WithField("partition", envId).
669657
WithField("call", "RunLoad").
670658
Error("TRG error")
671659

@@ -700,8 +688,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
700688
log.WithError(err).
701689
WithField("level", infologger.IL_Support).
702690
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
703-
WithField("run", runNumber64).
704-
WithField("partition", envId).
705691
WithField("call", "RunLoad").
706692
Error("TRG error")
707693

@@ -729,8 +715,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
729715
log.WithError(err).
730716
WithField("level", infologger.IL_Support).
731717
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
732-
WithField("run", runNumber64).
733-
WithField("partition", envId).
734718
WithField("call", "RunLoad").
735719
Error("TRG error")
736720

@@ -775,16 +759,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
775759
return
776760
}
777761
stack["RunStart"] = func() (out string) { // must formally return string even when we return nothing
778-
log.WithField("partition", envId).
779-
Info("ALIECS SOR operation : performing TRG Run Start")
780-
781-
runtimeConfig, ok := varStack["trg_runtime_config"]
782-
if !ok {
783-
log.WithField("partition", envId).
784-
Debug("no TRG config set, using default configuration")
785-
runtimeConfig = ""
786-
}
787-
788762
rn := varStack["run_number"]
789763
var runNumber64 int64
790764
runNumber64, err := strconv.ParseInt(rn, 10, 32)
@@ -793,13 +767,20 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
793767
WithField("partition", envId).
794768
Error("cannot acquire run number for Run Start")
795769
}
770+
log := log.WithField("run", runNumber64).WithField("partition", envId)
771+
772+
log.Info("ALIECS SOR operation : performing TRG Run Start")
773+
774+
runtimeConfig, ok := varStack["trg_runtime_config"]
775+
if !ok {
776+
log.Debug("no TRG config set, using default configuration")
777+
runtimeConfig = ""
778+
}
796779

797780
trgDetectorsParam, ok := varStack["trg_detectors"]
798781
if !ok {
799782
// "" it is a global run
800-
log.WithField("partition", envId).
801-
WithField("run", runNumber64).
802-
Debug("Detector for host is not available, starting global run")
783+
log.Debug("Detector for host is not available, starting global run")
803784
trgDetectorsParam = ""
804785
}
805786

@@ -810,8 +791,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
810791
log.WithError(err).
811792
WithField("level", infologger.IL_Support).
812793
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
813-
WithField("run", runNumber64).
814-
WithField("partition", envId).
815794
WithField("call", "RunStart").
816795
Error("TRG error")
817796

@@ -839,8 +818,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
839818
log.WithError(err).
840819
WithField("level", infologger.IL_Support).
841820
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
842-
WithField("run", runNumber64).
843-
WithField("partition", envId).
844821
WithField("call", "RunStart").
845822
Error("TRG error")
846823

@@ -855,8 +832,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
855832
log.WithError(err).
856833
WithField("level", infologger.IL_Support).
857834
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
858-
WithField("run", runNumber64).
859-
WithField("partition", envId).
860835
WithField("call", "RunStart").
861836
Error("TRG error")
862837

@@ -891,8 +866,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
891866
log.WithError(err).
892867
WithField("level", infologger.IL_Support).
893868
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
894-
WithField("run", runNumber64).
895-
WithField("partition", envId).
896869
WithField("call", "RunStart").
897870
Error("TRG error")
898871

@@ -919,8 +892,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
919892
log.WithError(err).
920893
WithField("level", infologger.IL_Support).
921894
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
922-
WithField("run", runNumber64).
923-
WithField("partition", envId).
924895
WithField("call", "RunStart").
925896
Error("TRG error")
926897

@@ -960,9 +931,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
960931

961932
// runStart successful, we cache the run number for eventual cleanup
962933
p.pendingRunStops[envId] = runNumber64
963-
log.WithField("partition", envId).
964-
WithField("run", runNumber64).
965-
Info("TRG RunStart success")
934+
log.Info("TRG RunStart success")
966935

967936
trgStartTimeS := strconv.FormatInt(trgStartTime.UnixMilli(), 10)
968937
parentRole, ok := call.GetParentRole().(callable.ParentRole)
@@ -974,12 +943,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
974943
return
975944
}
976945
runStopFunc := func(ctx context.Context, runNumber64 int64) (out string) {
946+
log := log.WithField("run", runNumber64).WithField("partition", envId)
947+
977948
trgDetectorsParam, ok := varStack["trg_detectors"]
978949
if !ok {
979950
// "" it is a global run
980-
log.WithField("partition", envId).
981-
WithField("run", runNumber64).
982-
Debug("Detector for host is not available, stoping global run")
951+
log.Debug("Detector for host is not available, stoping global run")
983952
trgDetectorsParam = ""
984953
}
985954

@@ -1007,8 +976,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
1007976
log.WithError(err).
1008977
WithField("level", infologger.IL_Support).
1009978
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1010-
WithField("run", runNumber64).
1011-
WithField("partition", envId).
1012979
WithField("call", "RunStop").
1013980
Error("TRG error")
1014981

@@ -1023,8 +990,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
1023990
log.WithError(err).
1024991
WithField("level", infologger.IL_Support).
1025992
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1026-
WithField("run", runNumber64).
1027-
WithField("partition", envId).
1028993
WithField("call", "RunStop").
1029994
Error("TRG error")
1030995

@@ -1055,8 +1020,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
10551020
log.WithError(err).
10561021
WithField("level", infologger.IL_Support).
10571022
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1058-
WithField("run", runNumber64).
1059-
WithField("partition", envId).
10601023
WithField("call", "RunStop").
10611024
Error("TRG error")
10621025

@@ -1083,8 +1046,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
10831046
log.WithError(err).
10841047
WithField("level", infologger.IL_Support).
10851048
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1086-
WithField("run", runNumber64).
1087-
WithField("partition", envId).
10881049
WithField("call", "RunStop").
10891050
Error("TRG error")
10901051

@@ -1124,24 +1085,21 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
11241085

11251086
// RunStop successful, we pop the run number from the cache
11261087
delete(p.pendingRunStops, envId)
1127-
log.WithField("partition", envId).
1128-
WithField("run", runNumber64).
1129-
Info("TRG RunStop success")
1088+
log.Info("TRG RunStop success")
11301089

11311090
trgEndTimeS := strconv.FormatInt(trgEndTime.UnixMilli(), 10)
11321091
parentRole, ok := call.GetParentRole().(callable.ParentRole)
11331092
if ok {
11341093
parentRole.SetGlobalRuntimeVar("trg_end_time_ms", trgEndTimeS)
11351094
} else {
1136-
log.WithField("partition", envId).
1137-
WithField("run", runNumber64).
1138-
WithField("trgEndTime", trgEndTimeS).
1095+
log.WithField("trgEndTime", trgEndTimeS).
11391096
Debug("could not get parentRole and set TRG end time")
11401097
}
11411098

11421099
return
11431100
}
11441101
runUnloadFunc := func(ctx context.Context, runNumber64 int64) (out string) {
1102+
log := log.WithField("run", runNumber64).WithField("partition", envId)
11451103

11461104
trgDetectorsParam, ok := varStack["trg_detectors"]
11471105
if !ok {
@@ -1155,9 +1113,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
11551113

11561114
// if global run then unload
11571115
if len(strings.Split(detectors, " ")) < 2 && varStack["trg_global_run_enabled"] == "false" {
1158-
log.WithField("partition", envId).
1159-
WithField("run", runNumber64).
1160-
Debug("not a TRG Global Run, skipping TRG Run Unload")
1116+
log.Debug("not a TRG Global Run, skipping TRG Run Unload")
11611117
return
11621118
}
11631119

@@ -1175,8 +1131,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
11751131
log.WithError(err).
11761132
WithField("level", infologger.IL_Support).
11771133
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1178-
WithField("run", runNumber64).
1179-
WithField("partition", envId).
11801134
WithField("call", "RunUnload").
11811135
Error("TRG error")
11821136

@@ -1191,8 +1145,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
11911145
log.WithError(err).
11921146
WithField("level", infologger.IL_Support).
11931147
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1194-
WithField("run", runNumber64).
1195-
WithField("partition", envId).
11961148
WithField("call", "RunUnload").
11971149
Error("TRG error")
11981150

@@ -1223,8 +1175,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
12231175
log.WithError(err).
12241176
WithField("level", infologger.IL_Support).
12251177
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1226-
WithField("run", runNumber64).
1227-
WithField("partition", envId).
12281178
WithField("call", "RunUnload").
12291179
Error("TRG error")
12301180

@@ -1251,8 +1201,6 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
12511201
log.WithError(err).
12521202
WithField("level", infologger.IL_Support).
12531203
WithField("endpoint", viper.GetString("trgServiceEndpoint")).
1254-
WithField("run", runNumber64).
1255-
WithField("partition", envId).
12561204
WithField("call", "RunUnload").
12571205
Error("TRG error")
12581206

@@ -1290,17 +1238,11 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
12901238

12911239
// RunUnload successful, we pop the run number from the cache
12921240
delete(p.pendingRunUnloads, envId)
1293-
log.WithField("partition", envId).
1294-
WithField("run", runNumber64).
1295-
Info("ALICECS EOR operation : TRG RunUnload success")
1241+
log.Info("ALICECS EOR operation : TRG RunUnload success")
12961242

12971243
return
12981244
}
12991245
stack["RunStop"] = func() (out string) {
1300-
log.WithField("partition", envId).
1301-
//WithField("run", runNumber64).
1302-
Info("ALIECS EOR operation : performing TRG Run Stop ")
1303-
13041246
rn := varStack["run_number"]
13051247
var runNumber64 int64
13061248
var err error
@@ -1311,17 +1253,17 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
13111253
Error("cannot acquire run number for TRG Run Stop")
13121254
}
13131255

1256+
log.WithField("partition", envId).
1257+
WithField("run", runNumber64).
1258+
Info("ALIECS EOR operation : performing TRG Run Stop ")
1259+
13141260
timeout := callable.AcquireTimeout(TRG_STOP_TIMEOUT, varStack, "RunStop", envId)
13151261
ctx, cancel := context.WithTimeout(context.Background(), timeout)
13161262
defer cancel()
13171263

13181264
return runStopFunc(ctx, runNumber64)
13191265
}
13201266
stack["RunUnload"] = func() (out string) {
1321-
log.WithField("partition", envId).
1322-
//WithField("run", runNumber64).
1323-
Info("ALIECS EOR operation : performing TRG Run Unload ")
1324-
13251267
rn := varStack["run_number"]
13261268
var runNumber64 int64
13271269
var err error
@@ -1332,6 +1274,10 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
13321274
Error("cannot acquire run number for TRG Run Unload")
13331275
}
13341276

1277+
log.WithField("partition", envId).
1278+
WithField("run", runNumber64).
1279+
Info("ALIECS EOR operation : performing TRG Run Unload ")
1280+
13351281
timeout := callable.AcquireTimeout(TRG_UNLOAD_TIMEOUT, varStack, "RunUnload", envId)
13361282
ctx, cancel := context.WithTimeout(context.Background(), timeout)
13371283
defer cancel()

0 commit comments

Comments
 (0)