This is an automated email from the ASF dual-hosted git repository.
ccondit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new 0ccc82f4 [YUNIKORN-1965] Display a unique id on the REST interface
when returning events (#647)
0ccc82f4 is described below
commit 0ccc82f41af0a6e1e7309620ffbdcedab6280a91
Author: Peter Bacsko <[email protected]>
AuthorDate: Wed Sep 13 16:45:29 2023 -0500
[YUNIKORN-1965] Display a unique id on the REST interface when returning
events (#647)
Code review
Closes: #647
Signed-off-by: Craig Condit <[email protected]>
---
pkg/scheduler/context.go | 7 +++++++
pkg/webservice/dao/event_record.go | 1 +
pkg/webservice/handlers.go | 1 +
pkg/webservice/handlers_test.go | 2 ++
4 files changed, 11 insertions(+)
diff --git a/pkg/scheduler/context.go b/pkg/scheduler/context.go
index 95e0fb21..853f0103 100644
--- a/pkg/scheduler/context.go
+++ b/pkg/scheduler/context.go
@@ -46,6 +46,7 @@ type ClusterContext struct {
partitions map[string]*PartitionContext
policyGroup string
rmEventHandler handler.EventHandler
+ uuid string
// config values that change scheduling behaviour
needPreemption bool
@@ -77,6 +78,7 @@ func NewClusterContext(rmID, policyGroup string, config
[]byte) (*ClusterContext
policyGroup: policyGroup,
reservationDisabled: common.GetBoolEnvVar(disableReservation,
false),
startTime: time.Now(),
+ uuid: common.GetNewUUID(),
}
// If reservation is turned off set the reservation delay to the
maximum duration defined.
// The time package does not export maxDuration so use the equivalent
from the math package.
@@ -97,6 +99,7 @@ func newClusterContext() *ClusterContext {
partitions: make(map[string]*PartitionContext),
reservationDisabled: common.GetBoolEnvVar(disableReservation,
false),
startTime: time.Now(),
+ uuid: common.GetNewUUID(),
}
// If reservation is turned off set the reservation delay to the
maximum duration defined.
// The time package does not export maxDuration so use the equivalent
from the math package.
@@ -977,3 +980,7 @@ func (cc *ClusterContext) SetLastHealthCheckResult(c
*dao.SchedulerHealthDAOInfo
defer cc.Unlock()
cc.lastHealthCheckResult = c
}
+
+func (cc *ClusterContext) GetUUID() string {
+ return cc.uuid
+}
diff --git a/pkg/webservice/dao/event_record.go
b/pkg/webservice/dao/event_record.go
index efa33505..324a99d6 100644
--- a/pkg/webservice/dao/event_record.go
+++ b/pkg/webservice/dao/event_record.go
@@ -23,6 +23,7 @@ import (
)
type EventRecordDAO struct {
+ InstanceUUID string
LowestID uint64
HighestID uint64
EventRecords []*si.EventRecord
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 6942b42c..dd51f49e 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -910,6 +910,7 @@ func getEvents(w http.ResponseWriter, r *http.Request) {
records, lowestID, highestID := eventSystem.GetEventsFromID(start,
count)
eventDao := dao.EventRecordDAO{
+ InstanceUUID: schedulerContext.GetUUID(),
LowestID: lowestID,
HighestID: highestID,
EventRecords: records,
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index df8e23be..a0199f85 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -1333,6 +1333,7 @@ func TestUsersAndGroupsResourceUsage(t *testing.T) {
}
func TestGetEvents(t *testing.T) {
+ prepareSchedulerContext(t, false)
appEvent, nodeEvent, queueEvent := addEvents(t)
checkAllEvents(t, []*si.EventRecord{appEvent, nodeEvent, queueEvent})
@@ -1420,6 +1421,7 @@ func checkSingleEvent(t *testing.T, event
*si.EventRecord, query string) {
req, err := http.NewRequest("GET", "/ws/v1/events/batch?"+query,
strings.NewReader(""))
assert.NilError(t, err)
eventDao := getEventRecordDao(t, req)
+ assert.Assert(t, eventDao.InstanceUUID != "")
assert.Equal(t, 1, len(eventDao.EventRecords))
compareEvents(t, event, eventDao.EventRecords[0])
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]