Skip to content

Commit

Permalink
[YUNIKORN-1097] ERMProxy DEBUG cannot log event with channel
Browse files Browse the repository at this point in the history
  • Loading branch information
steinsgateted committed Mar 1, 2022
1 parent dc98d22 commit c61bf9a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
46 changes: 46 additions & 0 deletions pkg/rmproxy/rmevent/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,49 @@ type RMNodeUpdateEvent struct {
AcceptedNodes []*si.AcceptedNode
RejectedNodes []*si.RejectedNode
}

//log only
func GetEventWithoutChan(ev interface{}) interface{} {
m := map[string]interface{}{}
switch v := ev.(type) {
case *RMRegistrationEvent:
c := <-v.Channel
m["RMRegistrationEvent"] = map[string]interface{}{
"Registration": v.Registration,
"Channel": c,
}
return m
case *RMConfigUpdateEvent:
c := <-v.Channel
m["RMConfigUpdateEvent"] = map[string]interface{}{
"RmID": v.RmID,
"Channel": c,
}
return m
case *RMPartitionsRemoveEvent:
c := <-v.Channel
m["RMPartitionsRemoveEvent"] = map[string]interface{}{
"RmID": v.RmID,
"Channel": c,
}
return m
case *RMNewAllocationsEvent:
c := <-v.Channel
m["RMNewAllocationsEvent"] = map[string]interface{}{
"RmID": v.RmID,
"Allocations": v.Allocations,
"Channel": c,
}
return m
case *RMReleaseAllocationEvent:
c := <-v.Channel
m["RMPartitionsRemoveEvent"] = map[string]interface{}{
"RmID": v.RmID,
"ReleasedAllocations": v.ReleasedAllocations,
"Channel": c,
}
return m
default:
return ev
}
}
2 changes: 1 addition & 1 deletion pkg/rmproxy/rmproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func enqueueAndCheckFull(queue chan interface{}, ev interface{}) {
select {
case queue <- ev:
log.Logger().Debug("enqueue event",
zap.Any("event", ev),
zap.Any("event", rmevent.GetEventWithoutChan(ev)),
zap.Int("currentQueueSize", len(queue)))
default:
log.Logger().Panic("failed to enqueue event",
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func enqueueAndCheckFull(queue chan interface{}, ev interface{}) {
case queue <- ev:
log.Logger().Debug("enqueued event",
zap.String("eventType", reflect.TypeOf(ev).String()),
zap.Any("event", ev),
zap.Any("event", rmevent.GetEventWithoutChan(ev)),
zap.Int("currentQueueSize", len(queue)))
default:
log.Logger().DPanic("failed to enqueue event",
Expand Down

0 comments on commit c61bf9a

Please sign in to comment.