From a0ac70ecf9cf2d0144113ed61e7a1885b73719c2 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 22 Aug 2024 14:46:53 +0100 Subject: [PATCH 1/3] wip Signed-off-by: Chris Martin --- .../eventingester/convert/conversions_test.go | 21 ++- .../server/event/conversion/conversions.go | 149 ++++-------------- .../event/conversion/conversions_test.go | 85 +++++----- .../server/event/event_repository_test.go | 15 +- internal/server/event/event_test.go | 20 +-- 5 files changed, 86 insertions(+), 204 deletions(-) diff --git a/internal/eventingester/convert/conversions_test.go b/internal/eventingester/convert/conversions_test.go index ca36b11a812..d9e52e03bcc 100644 --- a/internal/eventingester/convert/conversions_test.go +++ b/internal/eventingester/convert/conversions_test.go @@ -7,7 +7,6 @@ import ( "github.com/apache/pulsar-client-go/pulsar" "github.com/gogo/protobuf/proto" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/armadaproject/armada/internal/common/armadacontext" @@ -26,8 +25,6 @@ const ( ) var ( - jobIdProto, _ = armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto = armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) baseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") baseTimeProto = protoutil.ToTimestamp(baseTime) ) @@ -37,8 +34,8 @@ var jobRunSucceeded = &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunSucceeded{ JobRunSucceeded: &armadaevents.JobRunSucceeded{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, }, }, } @@ -48,7 +45,7 @@ var cancelled = &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelledJob{ CancelledJob: &armadaevents.CancelledJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -93,8 +90,8 @@ func TestCancelled(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelJob{ CancelJob: &armadaevents.CancelJob{ - JobId: jobIdProto, - Reason: "some reason 1", + JobIdStr: jobIdString, + Reason: "some reason 1", }, }, }, &armadaevents.EventSequence_Event{ @@ -108,8 +105,8 @@ func TestCancelled(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelledJob{ CancelledJob: &armadaevents.CancelledJob{ - JobId: jobIdProto, - Reason: "some reason 3", + JobIdStr: jobIdString, + Reason: "some reason 3", }, }, }) @@ -124,7 +121,7 @@ func TestCancelled(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelJob{ CancelJob: &armadaevents.CancelJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, }, @@ -138,7 +135,7 @@ func TestCancelled(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelledJob{ CancelledJob: &armadaevents.CancelledJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, }, diff --git a/internal/server/event/conversion/conversions.go b/internal/server/event/conversion/conversions.go index 02200dbde80..9698cffa22a 100644 --- a/internal/server/event/conversion/conversions.go +++ b/internal/server/event/conversion/conversions.go @@ -75,18 +75,13 @@ func FromEventSequence(es *armadaevents.EventSequence) ([]*api.EventMessage, err } func FromInternalSubmit(owner string, groups []string, queue string, jobSet string, time time.Time, e *armadaevents.SubmitJob) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - job, err := eventutil.ApiJobFromLogSubmitJob(owner, groups, queue, jobSet, time, e) if err != nil { return nil, err } submitEvent := &api.JobSubmittedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSet, Queue: queue, Created: protoutil.ToTimestamp(time), @@ -94,7 +89,7 @@ func FromInternalSubmit(owner string, groups []string, queue string, jobSet stri } queuedEvent := &api.JobQueuedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSet, Queue: queue, Created: protoutil.ToTimestamp(time), @@ -115,16 +110,11 @@ func FromInternalSubmit(owner string, groups []string, queue string, jobSet stri } func FromInternalPreemptionRequested(userId string, queueName string, jobSetName string, time time.Time, e *armadaevents.JobPreemptionRequested) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - return []*api.EventMessage{ { Events: &api.EventMessage_Preempting{ Preempting: &api.JobPreemptingEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -136,16 +126,11 @@ func FromInternalPreemptionRequested(userId string, queueName string, jobSetName } func FromInternalCancel(userId string, queueName string, jobSetName string, time time.Time, e *armadaevents.CancelJob) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - return []*api.EventMessage{ { Events: &api.EventMessage_Cancelling{ Cancelling: &api.JobCancellingEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -157,16 +142,11 @@ func FromInternalCancel(userId string, queueName string, jobSetName string, time } func FromInternalCancelled(userId string, queueName string, jobSetName string, time time.Time, e *armadaevents.CancelledJob) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - return []*api.EventMessage{ { Events: &api.EventMessage_Cancelled{ Cancelled: &api.JobCancelledEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -178,15 +158,11 @@ func FromInternalCancelled(userId string, queueName string, jobSetName string, t } func FromInternalReprioritiseJob(userId string, queueName string, jobSetName string, time time.Time, e *armadaevents.ReprioritiseJob) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } return []*api.EventMessage{ { Events: &api.EventMessage_Reprioritizing{ Reprioritizing: &api.JobReprioritizingEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -199,15 +175,11 @@ func FromInternalReprioritiseJob(userId string, queueName string, jobSetName str } func FromInternalReprioritisedJob(userId string, queueName string, jobSetName string, time time.Time, e *armadaevents.ReprioritisedJob) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } return []*api.EventMessage{ { Events: &api.EventMessage_Reprioritized{ Reprioritized: &api.JobReprioritizedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -220,15 +192,11 @@ func FromInternalReprioritisedJob(userId string, queueName string, jobSetName st } func FromInternalLogJobRunLeased(queueName string, jobSetName string, time time.Time, e *armadaevents.JobRunLeased) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } return []*api.EventMessage{ { Events: &api.EventMessage_Leased{ Leased: &api.JobLeasedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -240,13 +208,8 @@ func FromInternalLogJobRunLeased(queueName string, jobSetName string, time time. } func FromInternalJobSucceeded(queueName string, jobSetName string, time time.Time, e *armadaevents.JobSucceeded) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - apiEvent := &api.JobSucceededEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -272,11 +235,6 @@ func FromInternalJobSucceeded(queueName string, jobSetName string, time time.Tim } func FromInternalJobRunErrors(queueName string, jobSetName string, time time.Time, e *armadaevents.JobRunErrors) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - events := make([]*api.EventMessage, 0) for _, msgErr := range e.GetErrors() { switch reason := msgErr.Reason.(type) { @@ -284,7 +242,7 @@ func FromInternalJobRunErrors(queueName string, jobSetName string, time time.Tim event := &api.EventMessage{ Events: &api.EventMessage_LeaseExpired{ LeaseExpired: &api.JobLeaseExpiredEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -297,7 +255,7 @@ func FromInternalJobRunErrors(queueName string, jobSetName string, time time.Tim event := &api.EventMessage{ Events: &api.EventMessage_UnableToSchedule{ UnableToSchedule: &api.JobUnableToScheduleEvent{ - JobId: jobId, + JobId: e.JobIdStr, ClusterId: objectMeta.GetExecutorId(), PodNamespace: objectMeta.GetNamespace(), PodName: objectMeta.GetName(), @@ -317,7 +275,7 @@ func FromInternalJobRunErrors(queueName string, jobSetName string, time time.Tim event := &api.EventMessage{ Events: &api.EventMessage_LeaseReturned{ LeaseReturned: &api.JobLeaseReturnedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -338,10 +296,6 @@ func FromInternalJobRunErrors(queueName string, jobSetName string, time time.Tim } func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, e *armadaevents.JobErrors) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } events := make([]*api.EventMessage, 0) for _, msgErr := range e.GetErrors() { if !msgErr.Terminal { @@ -351,7 +305,7 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, case *armadaevents.Error_PodError: event := &api.EventMessage{ Events: &api.EventMessage_Failed{ - Failed: makeJobFailed(jobId, queueName, jobSetName, time, reason), + Failed: makeJobFailed(e.JobIdStr, queueName, jobSetName, time, reason), }, } events = append(events, event) @@ -359,7 +313,7 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, event := &api.EventMessage{ Events: &api.EventMessage_Failed{ Failed: &api.JobFailedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -372,7 +326,7 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, event := &api.EventMessage{ Events: &api.EventMessage_Failed{ Failed: &api.JobFailedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -385,7 +339,7 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, event := &api.EventMessage{ Events: &api.EventMessage_Failed{ Failed: &api.JobFailedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -398,7 +352,7 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, event := &api.EventMessage{ Events: &api.EventMessage_Failed{ Failed: &api.JobFailedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -409,11 +363,11 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, } events = append(events, event) default: - log.Warnf("unknown error %T for job %s", reason, jobId) + log.Warnf("unknown error %T for job %s", reason, e.JobIdStr) event := &api.EventMessage{ Events: &api.EventMessage_Failed{ Failed: &api.JobFailedEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -427,13 +381,8 @@ func FromInternalJobErrors(queueName string, jobSetName string, time time.Time, } func FromInternalJobRunRunning(queueName string, jobSetName string, time time.Time, e *armadaevents.JobRunRunning) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - apiEvent := &api.JobRunningEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -459,13 +408,8 @@ func FromInternalJobRunRunning(queueName string, jobSetName string, time time.Ti } func FromInternalJobRunAssigned(queueName string, jobSetName string, time time.Time, e *armadaevents.JobRunAssigned) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - apiEvent := &api.JobPendingEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -494,39 +438,12 @@ func FromInternalJobRunPreempted(queueName string, jobSetName string, time time. return nil, nil } - jobId, err := armadaevents.UlidStringFromProtoUuid(e.PreemptedJobId) - if err != nil { - return nil, err - } - runId, err := armadaevents.UuidStringFromProtoUuid(e.PreemptedRunId) - if err != nil { - return nil, err - } - - preemptiveJobId := "" - preemptiveRunId := "" - - if e.PreemptiveJobId != nil { - preemptiveJobId, err = armadaevents.UlidStringFromProtoUuid(e.PreemptiveJobId) - if err != nil { - return nil, err - } - } - if e.PreemptiveRunId != nil { - preemptiveRunId, err = armadaevents.UuidStringFromProtoUuid(e.PreemptiveRunId) - if err != nil { - return nil, err - } - } - apiEvent := &api.JobPreemptedEvent{ - JobId: jobId, - JobSetId: jobSetName, - Queue: queueName, - Created: protoutil.ToTimestamp(time), - RunId: runId, - PreemptiveJobId: preemptiveJobId, - PreemptiveRunId: preemptiveRunId, + JobId: e.PreemptedJobIdStr, + JobSetId: jobSetName, + Queue: queueName, + Created: protoutil.ToTimestamp(time), + RunId: e.PreemptedRunIdStr, } return []*api.EventMessage{ @@ -539,13 +456,8 @@ func FromInternalJobRunPreempted(queueName string, jobSetName string, time time. } func FromInternalResourceUtilisation(queueName string, jobSetName string, time time.Time, e *armadaevents.ResourceUtilisation) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - apiEvent := &api.JobUtilisationEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), @@ -569,13 +481,8 @@ func FromInternalResourceUtilisation(queueName string, jobSetName string, time t } func FromInternalStandaloneIngressInfo(queueName string, jobSetName string, time time.Time, e *armadaevents.StandaloneIngressInfo) ([]*api.EventMessage, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - return nil, err - } - apiEvent := &api.JobIngressInfoEvent{ - JobId: jobId, + JobId: e.JobIdStr, JobSetId: jobSetName, Queue: queueName, Created: protoutil.ToTimestamp(time), diff --git a/internal/server/event/conversion/conversions_test.go b/internal/server/event/conversion/conversions_test.go index fbe3ef0c840..625f1e21fc5 100644 --- a/internal/server/event/conversion/conversions_test.go +++ b/internal/server/event/conversion/conversions_test.go @@ -5,7 +5,6 @@ import ( "time" "github.com/gogo/protobuf/proto" - "github.com/google/uuid" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" v11 "k8s.io/api/networking/v1" @@ -18,19 +17,13 @@ import ( ) const ( - jobIdString = "01f3j0g1md4qx7z5qb148qnh4r" - preemptiveJobIdString = "02f3j0g1md4qx7z5qb148qnh4r" - runIdString = "123e4567-e89b-12d3-a456-426614174000" - preemptiveRunIdString = "123e4567-e89b-12d3-a456-426614174001" + jobIdString = "01f3j0g1md4qx7z5qb148qnh4r" + runIdString = "123e4567-e89b-12d3-a456-426614174000" ) var ( - jobIdProto, _ = armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto = armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) - preemptiveJobIdProto, _ = armadaevents.ProtoUuidFromUlidString(preemptiveJobIdString) - preemptiveRunIdRunIdProto = armadaevents.ProtoUuidFromUuid(uuid.MustParse(preemptiveRunIdString)) - baseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") - baseTimeProto = protoutil.ToTimestamp(baseTime) + baseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") + baseTimeProto = protoutil.ToTimestamp(baseTime) ) const ( @@ -51,7 +44,7 @@ func TestConvertSubmitted(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_SubmitJob{ SubmitJob: &armadaevents.SubmitJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, Priority: priority, ObjectMeta: &armadaevents.ObjectMeta{ Namespace: namespace, @@ -126,7 +119,7 @@ func TestConvertCancel(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelJob{ CancelJob: &armadaevents.CancelJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -155,7 +148,7 @@ func TestConvertCancelled(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_CancelledJob{ CancelledJob: &armadaevents.CancelledJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -184,7 +177,7 @@ func TestConvertReprioritising(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_ReprioritiseJob{ ReprioritiseJob: &armadaevents.ReprioritiseJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -213,7 +206,7 @@ func TestConvertReprioritised(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_ReprioritisedJob{ ReprioritisedJob: &armadaevents.ReprioritisedJob{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -242,7 +235,7 @@ func TestConvertLeased(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunLeased{ JobRunLeased: &armadaevents.JobRunLeased{ - JobId: jobIdProto, + JobIdStr: jobIdString, ExecutorId: executorId, PodRequirementsOverlay: &schedulerobjects.PodRequirements{ Tolerations: []v1.Toleration{ @@ -281,8 +274,8 @@ func TestConvertLeaseExpired(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunErrors{ JobRunErrors: &armadaevents.JobRunErrors{ - JobId: jobIdProto, - RunId: runIdProto, + JobIdStr: jobIdString, + RunIdStr: runIdString, Errors: []*armadaevents.Error{ { Terminal: true, @@ -318,8 +311,8 @@ func TestConvertPodUnschedulable(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunErrors{ JobRunErrors: &armadaevents.JobRunErrors{ - JobId: jobIdProto, - RunId: runIdProto, + JobIdStr: jobIdString, + RunIdStr: runIdString, Errors: []*armadaevents.Error{ { Terminal: false, @@ -372,8 +365,8 @@ func TestConvertPodLeaseReturned(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunErrors{ JobRunErrors: &armadaevents.JobRunErrors{ - JobId: jobIdProto, - RunId: runIdProto, + JobIdStr: jobIdString, + RunIdStr: runIdString, Errors: []*armadaevents.Error{ { Terminal: true, @@ -424,7 +417,7 @@ func TestConvertJobError(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobErrors{ JobErrors: &armadaevents.JobErrors{ - JobId: jobIdProto, + JobIdStr: jobIdString, Errors: []*armadaevents.Error{ { Terminal: true, @@ -463,7 +456,7 @@ func TestConvertJobError(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobErrors{ JobErrors: &armadaevents.JobErrors{ - JobId: jobIdProto, + JobIdStr: jobIdString, Errors: []*armadaevents.Error{ { Terminal: true, @@ -530,7 +523,7 @@ func TestConvertJobSucceeded(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobSucceeded{ JobSucceeded: &armadaevents.JobSucceeded{ - JobId: jobIdProto, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { ObjectMeta: &armadaevents.ObjectMeta{ @@ -580,8 +573,8 @@ func TestConvertJobRunning(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunRunning{ JobRunRunning: &armadaevents.JobRunRunning{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { ObjectMeta: &armadaevents.ObjectMeta{ @@ -631,8 +624,8 @@ func TestIgnoredEventDoesntDuplicate(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunErrors{ JobRunErrors: &armadaevents.JobRunErrors{ - JobId: jobIdProto, - RunId: runIdProto, + JobIdStr: jobIdString, + RunIdStr: runIdString, Errors: []*armadaevents.Error{ { Terminal: true, @@ -675,8 +668,8 @@ func TestConvertJobAssigned(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunAssigned{ JobRunAssigned: &armadaevents.JobRunAssigned{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { ObjectMeta: &armadaevents.ObjectMeta{ @@ -725,8 +718,8 @@ func TestConvertResourceUtilisation(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_ResourceUtilisation{ ResourceUtilisation: &armadaevents.ResourceUtilisation{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfo: &armadaevents.KubernetesResourceInfo{ ObjectMeta: &armadaevents.ObjectMeta{ ExecutorId: executorId, @@ -790,8 +783,8 @@ func TestConvertIngressInfo(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_StandaloneIngressInfo{ StandaloneIngressInfo: &armadaevents.StandaloneIngressInfo{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ObjectMeta: &armadaevents.ObjectMeta{ ExecutorId: executorId, Namespace: namespace, @@ -841,7 +834,7 @@ func TestConvertJobPreemptionRequested(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobPreemptionRequested{ JobPreemptionRequested: &armadaevents.JobPreemptionRequested{ - JobId: jobIdProto, + JobIdStr: jobIdString, }, }, } @@ -870,10 +863,8 @@ func TestConvertJobRunPreempted(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunPreempted{ JobRunPreempted: &armadaevents.JobRunPreempted{ - PreemptedJobId: jobIdProto, - PreemptedRunId: runIdProto, - PreemptiveJobId: preemptiveJobIdProto, - PreemptiveRunId: preemptiveRunIdRunIdProto, + PreemptedJobIdStr: jobIdString, + PreemptedRunIdStr: runIdString, }, }, } @@ -882,13 +873,11 @@ func TestConvertJobRunPreempted(t *testing.T) { { Events: &api.EventMessage_Preempted{ Preempted: &api.JobPreemptedEvent{ - JobId: jobIdString, - JobSetId: jobSetName, - Queue: queue, - Created: protoutil.ToTimestamp(baseTime), - RunId: runIdString, - PreemptiveJobId: preemptiveJobIdString, - PreemptiveRunId: preemptiveRunIdString, + JobId: jobIdString, + JobSetId: jobSetName, + Queue: queue, + Created: protoutil.ToTimestamp(baseTime), + RunId: runIdString, }, }, }, diff --git a/internal/server/event/event_repository_test.go b/internal/server/event/event_repository_test.go index e21ea7e0047..36012050795 100644 --- a/internal/server/event/event_repository_test.go +++ b/internal/server/event/event_repository_test.go @@ -5,7 +5,6 @@ import ( "time" "github.com/gogo/protobuf/proto" - "github.com/google/uuid" "github.com/redis/go-redis/v9" "github.com/stretchr/testify/assert" @@ -23,8 +22,6 @@ const ( ) var ( - jobIdProto, _ = armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto = armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) baseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") baseTimeProto = protoutil.ToTimestamp(baseTime) ) @@ -47,8 +44,8 @@ var assigned = &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunAssigned{ JobRunAssigned: &armadaevents.JobRunAssigned{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { ObjectMeta: &armadaevents.ObjectMeta{ @@ -73,8 +70,8 @@ var running = &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunRunning{ JobRunRunning: &armadaevents.JobRunRunning{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { Info: &armadaevents.KubernetesResourceInfo_PodInfo{ @@ -93,8 +90,8 @@ var runSucceeded = &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunSucceeded{ JobRunSucceeded: &armadaevents.JobRunSucceeded{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, ResourceInfos: []*armadaevents.KubernetesResourceInfo{ { Info: &armadaevents.KubernetesResourceInfo_PodInfo{ diff --git a/internal/server/event/event_test.go b/internal/server/event/event_test.go index 7662798a354..44410a98210 100644 --- a/internal/server/event/event_test.go +++ b/internal/server/event/event_test.go @@ -7,7 +7,6 @@ import ( "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/types" - "github.com/google/uuid" "github.com/jackc/pgx/v5/pgxpool" "github.com/redis/go-redis/v9" "github.com/stretchr/testify/assert" @@ -74,8 +73,6 @@ func TestEventServer_ForceNew(t *testing.T) { runIdString := "123e4567-e89b-12d3-a456-426614174000" baseTime, _ := time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") baseTimeProto := protoutil.ToTimestamp(baseTime) - jobIdProto, _ := armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto := armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) err := s.queueRepository.(armadaqueue.QueueRepository).CreateQueue(ctx, q) require.NoError(t, err) @@ -86,8 +83,8 @@ func TestEventServer_ForceNew(t *testing.T) { Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunAssigned{ JobRunAssigned: &armadaevents.JobRunAssigned{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, }, }, } @@ -218,15 +215,13 @@ func TestEventServer_GetJobSetEvents_ErrorIfMissing(t *testing.T) { runIdString := "123e4567-e89b-12d3-a456-426614174000" baseTime, _ := time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") baseTimeProto := protoutil.ToTimestamp(baseTime) - jobIdProto, _ := armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto := armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) assigned := &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunAssigned{ JobRunAssigned: &armadaevents.JobRunAssigned{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, }, }, } @@ -263,15 +258,12 @@ func TestEventServer_GetJobSetEvents_ErrorIfMissing(t *testing.T) { runIdString := "123e4567-e89b-12d3-a456-426614174000" baseTime, _ := time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z") baseTimeProto := protoutil.ToTimestamp(baseTime) - jobIdProto, _ := armadaevents.ProtoUuidFromUlidString(jobIdString) - runIdProto := armadaevents.ProtoUuidFromUuid(uuid.MustParse(runIdString)) - assigned := &armadaevents.EventSequence_Event{ Created: baseTimeProto, Event: &armadaevents.EventSequence_Event_JobRunAssigned{ JobRunAssigned: &armadaevents.JobRunAssigned{ - RunId: runIdProto, - JobId: jobIdProto, + RunIdStr: runIdString, + JobIdStr: jobIdString, }, }, } From 98bca91dd3c900cbdbb082a05136d6cef45ab48d Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Thu, 22 Aug 2024 14:56:44 +0100 Subject: [PATCH 2/3] wip Signed-off-by: Chris Martin --- internal/common/eventutil/eventutil.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/common/eventutil/eventutil.go b/internal/common/eventutil/eventutil.go index 9c808403a02..5f311e7a735 100644 --- a/internal/common/eventutil/eventutil.go +++ b/internal/common/eventutil/eventutil.go @@ -83,11 +83,6 @@ func ShortSequenceString(sequence *armadaevents.EventSequence) string { // ApiJobFromLogSubmitJob converts a SubmitJob log message into an api.Job struct, which is used by Armada internally. func ApiJobFromLogSubmitJob(ownerId string, groups []string, queueName string, jobSetName string, time time.Time, e *armadaevents.SubmitJob) (*api.Job, error) { - jobId, err := armadaevents.UlidStringFromProtoUuid(e.JobId) - if err != nil { - err = errors.WithStack(err) - return nil, err - } if e == nil || e.MainObject == nil || e.MainObject.Object == nil { return nil, errors.Errorf("SubmitJob or one of its member pointers is nil") @@ -146,7 +141,7 @@ func ApiJobFromLogSubmitJob(ownerId string, groups []string, queueName string, j } return &api.Job{ - Id: jobId, + Id: e.JobIdStr, ClientId: e.DeduplicationId, Queue: queueName, JobSetId: jobSetName, From 88e1aa36e2020db6b15f6b14db545fabe8035365 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Fri, 23 Aug 2024 09:37:36 +0100 Subject: [PATCH 3/3] wip Signed-off-by: Chris Martin --- internal/common/eventutil/eventutil.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/common/eventutil/eventutil.go b/internal/common/eventutil/eventutil.go index 5f311e7a735..a5eb49f9b61 100644 --- a/internal/common/eventutil/eventutil.go +++ b/internal/common/eventutil/eventutil.go @@ -83,7 +83,6 @@ func ShortSequenceString(sequence *armadaevents.EventSequence) string { // ApiJobFromLogSubmitJob converts a SubmitJob log message into an api.Job struct, which is used by Armada internally. func ApiJobFromLogSubmitJob(ownerId string, groups []string, queueName string, jobSetName string, time time.Time, e *armadaevents.SubmitJob) (*api.Job, error) { - if e == nil || e.MainObject == nil || e.MainObject.Object == nil { return nil, errors.Errorf("SubmitJob or one of its member pointers is nil") }