Skip to content

Commit

Permalink
Remove Gogo Proto From Everywhere except schedulerobjects (#3771)
Browse files Browse the repository at this point in the history
* remove timestamp

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>

* remove timestamp

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>

* fix import order

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>

---------

Signed-off-by: Chris Martin <chris@cmartinit.co.uk>
Co-authored-by: Chris Martin <chris@cmartinit.co.uk>
  • Loading branch information
d80tb7 and d80tb7 authored Jul 5, 2024
1 parent 7627a74 commit ca801e0
Show file tree
Hide file tree
Showing 34 changed files with 1,094 additions and 2,966 deletions.
31 changes: 16 additions & 15 deletions internal/armada/event/conversion/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,38 @@ func FromEventSequence(es *armadaevents.EventSequence) ([]*api.EventMessage, err

for _, event := range es.Events {
var convertedEvents []*api.EventMessage = nil
eventTs := protoutil.ToStdTime(event.Created)
switch esEvent := event.GetEvent().(type) {
case *armadaevents.EventSequence_Event_SubmitJob:
convertedEvents, err = FromInternalSubmit(es.UserId, es.Groups, es.Queue, es.JobSetName, *event.Created, esEvent.SubmitJob)
convertedEvents, err = FromInternalSubmit(es.UserId, es.Groups, es.Queue, es.JobSetName, eventTs, esEvent.SubmitJob)
case *armadaevents.EventSequence_Event_CancelledJob:
convertedEvents, err = FromInternalCancelled(es.UserId, es.Queue, es.JobSetName, *event.Created, esEvent.CancelledJob)
convertedEvents, err = FromInternalCancelled(es.UserId, es.Queue, es.JobSetName, eventTs, esEvent.CancelledJob)
case *armadaevents.EventSequence_Event_CancelJob:
convertedEvents, err = FromInternalCancel(es.UserId, es.Queue, es.JobSetName, *event.Created, esEvent.CancelJob)
convertedEvents, err = FromInternalCancel(es.UserId, es.Queue, es.JobSetName, eventTs, esEvent.CancelJob)
case *armadaevents.EventSequence_Event_JobPreemptionRequested:
convertedEvents, err = FromInternalPreemptionRequested(es.UserId, es.Queue, es.JobSetName, *event.Created, esEvent.JobPreemptionRequested)
convertedEvents, err = FromInternalPreemptionRequested(es.UserId, es.Queue, es.JobSetName, eventTs, esEvent.JobPreemptionRequested)
case *armadaevents.EventSequence_Event_ReprioritiseJob:
convertedEvents, err = FromInternalReprioritiseJob(es.UserId, es.Queue, es.JobSetName, *event.Created, esEvent.ReprioritiseJob)
convertedEvents, err = FromInternalReprioritiseJob(es.UserId, es.Queue, es.JobSetName, eventTs, esEvent.ReprioritiseJob)
case *armadaevents.EventSequence_Event_ReprioritisedJob:
convertedEvents, err = FromInternalReprioritisedJob(es.UserId, es.Queue, es.JobSetName, *event.Created, esEvent.ReprioritisedJob)
convertedEvents, err = FromInternalReprioritisedJob(es.UserId, es.Queue, es.JobSetName, eventTs, esEvent.ReprioritisedJob)
case *armadaevents.EventSequence_Event_JobRunLeased:
convertedEvents, err = FromInternalLogJobRunLeased(es.Queue, es.JobSetName, *event.Created, esEvent.JobRunLeased)
convertedEvents, err = FromInternalLogJobRunLeased(es.Queue, es.JobSetName, eventTs, esEvent.JobRunLeased)
case *armadaevents.EventSequence_Event_JobRunErrors:
convertedEvents, err = FromInternalJobRunErrors(es.Queue, es.JobSetName, *event.Created, esEvent.JobRunErrors)
convertedEvents, err = FromInternalJobRunErrors(es.Queue, es.JobSetName, eventTs, esEvent.JobRunErrors)
case *armadaevents.EventSequence_Event_JobSucceeded:
convertedEvents, err = FromInternalJobSucceeded(es.Queue, es.JobSetName, *event.Created, esEvent.JobSucceeded)
convertedEvents, err = FromInternalJobSucceeded(es.Queue, es.JobSetName, eventTs, esEvent.JobSucceeded)
case *armadaevents.EventSequence_Event_JobErrors:
convertedEvents, err = FromInternalJobErrors(es.Queue, es.JobSetName, *event.Created, esEvent.JobErrors)
convertedEvents, err = FromInternalJobErrors(es.Queue, es.JobSetName, eventTs, esEvent.JobErrors)
case *armadaevents.EventSequence_Event_JobRunRunning:
convertedEvents, err = FromInternalJobRunRunning(es.Queue, es.JobSetName, *event.Created, esEvent.JobRunRunning)
convertedEvents, err = FromInternalJobRunRunning(es.Queue, es.JobSetName, eventTs, esEvent.JobRunRunning)
case *armadaevents.EventSequence_Event_JobRunAssigned:
convertedEvents, err = FromInternalJobRunAssigned(es.Queue, es.JobSetName, *event.Created, esEvent.JobRunAssigned)
convertedEvents, err = FromInternalJobRunAssigned(es.Queue, es.JobSetName, eventTs, esEvent.JobRunAssigned)
case *armadaevents.EventSequence_Event_ResourceUtilisation:
convertedEvents, err = FromInternalResourceUtilisation(es.Queue, es.JobSetName, *event.Created, esEvent.ResourceUtilisation)
convertedEvents, err = FromInternalResourceUtilisation(es.Queue, es.JobSetName, eventTs, esEvent.ResourceUtilisation)
case *armadaevents.EventSequence_Event_StandaloneIngressInfo:
convertedEvents, err = FromInternalStandaloneIngressInfo(es.Queue, es.JobSetName, *event.Created, esEvent.StandaloneIngressInfo)
convertedEvents, err = FromInternalStandaloneIngressInfo(es.Queue, es.JobSetName, eventTs, esEvent.StandaloneIngressInfo)
case *armadaevents.EventSequence_Event_JobRunPreempted:
convertedEvents, err = FromInternalJobRunPreempted(es.Queue, es.JobSetName, *event.Created, esEvent.JobRunPreempted)
convertedEvents, err = FromInternalJobRunPreempted(es.Queue, es.JobSetName, eventTs, esEvent.JobRunPreempted)
case *armadaevents.EventSequence_Event_ReprioritiseJobSet,
*armadaevents.EventSequence_Event_CancelJobSet,
*armadaevents.EventSequence_Event_JobRunSucceeded,
Expand Down
46 changes: 23 additions & 23 deletions internal/armada/event/conversion/conversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var (
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)
)

const (
Expand All @@ -43,12 +45,10 @@ const (
podNumber = 6
)

var baseTime, _ = time.Parse("2006-01-02T15:04:05.000Z", "2022-03-01T15:04:05.000Z")

func TestConvertSubmitted(t *testing.T) {
// Submit
submit := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_SubmitJob{
SubmitJob: &armadaevents.SubmitJob{
JobId: jobIdProto,
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestConvertSubmitted(t *testing.T) {

func TestConvertCancel(t *testing.T) {
cancel := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_CancelJob{
CancelJob: &armadaevents.CancelJob{
JobId: jobIdProto,
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestConvertCancel(t *testing.T) {

func TestConvertCancelled(t *testing.T) {
cancel := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_CancelledJob{
CancelledJob: &armadaevents.CancelledJob{
JobId: jobIdProto,
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestConvertCancelled(t *testing.T) {

func TestConvertReprioritising(t *testing.T) {
reprioritising := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_ReprioritiseJob{
ReprioritiseJob: &armadaevents.ReprioritiseJob{
JobId: jobIdProto,
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestConvertReprioritising(t *testing.T) {

func TestConvertReprioritised(t *testing.T) {
reprioritised := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_ReprioritisedJob{
ReprioritisedJob: &armadaevents.ReprioritisedJob{
JobId: jobIdProto,
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestConvertReprioritised(t *testing.T) {

func TestConvertLeased(t *testing.T) {
leased := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunLeased{
JobRunLeased: &armadaevents.JobRunLeased{
JobId: jobIdProto,
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestConvertLeased(t *testing.T) {

func TestConvertLeaseExpired(t *testing.T) {
leaseExpired := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunErrors{
JobRunErrors: &armadaevents.JobRunErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestConvertLeaseExpired(t *testing.T) {

func TestConvertPodUnschedulable(t *testing.T) {
unschedulable := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunErrors{
JobRunErrors: &armadaevents.JobRunErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -370,7 +370,7 @@ func TestConvertPodUnschedulable(t *testing.T) {

func TestConvertPodLeaseReturned(t *testing.T) {
leaseReturned := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunErrors{
JobRunErrors: &armadaevents.JobRunErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestConvertPodLeaseReturned(t *testing.T) {

func TestConvertPodTerminated(t *testing.T) {
terminated := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunErrors{
JobRunErrors: &armadaevents.JobRunErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -475,7 +475,7 @@ func TestConvertPodTerminated(t *testing.T) {

func TestConvertJobError(t *testing.T) {
errored := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobErrors{
JobErrors: &armadaevents.JobErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -514,7 +514,7 @@ func TestConvertJobError(t *testing.T) {
}

maxRunsExceeded := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobErrors{
JobErrors: &armadaevents.JobErrors{
JobId: jobIdProto,
Expand Down Expand Up @@ -581,7 +581,7 @@ func TestConvertJobError(t *testing.T) {

func TestConvertJobSucceeded(t *testing.T) {
succeeded := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobSucceeded{
JobSucceeded: &armadaevents.JobSucceeded{
JobId: jobIdProto,
Expand Down Expand Up @@ -631,7 +631,7 @@ func TestConvertJobSucceeded(t *testing.T) {

func TestConvertJobRunning(t *testing.T) {
running := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunRunning{
JobRunRunning: &armadaevents.JobRunRunning{
RunId: runIdProto,
Expand Down Expand Up @@ -682,7 +682,7 @@ func TestConvertJobRunning(t *testing.T) {

func TestIgnoredEventDoesntDuplicate(t *testing.T) {
leaseExpired := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunErrors{
JobRunErrors: &armadaevents.JobRunErrors{
JobId: jobIdProto,
Expand All @@ -700,7 +700,7 @@ func TestIgnoredEventDoesntDuplicate(t *testing.T) {
}

cancel := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_CancelJobSet{
CancelJobSet: &armadaevents.CancelJobSet{},
},
Expand All @@ -726,7 +726,7 @@ func TestIgnoredEventDoesntDuplicate(t *testing.T) {

func TestConvertJobAssigned(t *testing.T) {
running := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunAssigned{
JobRunAssigned: &armadaevents.JobRunAssigned{
RunId: runIdProto,
Expand Down Expand Up @@ -776,7 +776,7 @@ func TestConvertJobAssigned(t *testing.T) {

func TestConvertResourceUtilisation(t *testing.T) {
utilisation := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_ResourceUtilisation{
ResourceUtilisation: &armadaevents.ResourceUtilisation{
RunId: runIdProto,
Expand Down Expand Up @@ -841,7 +841,7 @@ func TestConvertResourceUtilisation(t *testing.T) {

func TestConvertIngressInfo(t *testing.T) {
utilisation := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_StandaloneIngressInfo{
StandaloneIngressInfo: &armadaevents.StandaloneIngressInfo{
RunId: runIdProto,
Expand Down Expand Up @@ -892,7 +892,7 @@ func TestConvertIngressInfo(t *testing.T) {

func TestConvertJobPreemptionRequested(t *testing.T) {
preemptRequest := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobPreemptionRequested{
JobPreemptionRequested: &armadaevents.JobPreemptionRequested{
JobId: jobIdProto,
Expand Down Expand Up @@ -921,7 +921,7 @@ func TestConvertJobPreemptionRequested(t *testing.T) {

func TestConvertJobRunPreempted(t *testing.T) {
preempted := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunPreempted{
JobRunPreempted: &armadaevents.JobRunPreempted{
PreemptedJobId: jobIdProto,
Expand Down
7 changes: 4 additions & 3 deletions internal/armada/event/event_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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)
)

const (
Expand All @@ -43,7 +44,7 @@ const (

// Assigned
var assigned = &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunAssigned{
JobRunAssigned: &armadaevents.JobRunAssigned{
RunId: runIdProto,
Expand All @@ -69,7 +70,7 @@ var assigned = &armadaevents.EventSequence_Event{

// Running
var running = &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunRunning{
JobRunRunning: &armadaevents.JobRunRunning{
RunId: runIdProto,
Expand All @@ -89,7 +90,7 @@ var running = &armadaevents.EventSequence_Event{
}

var runSucceeded = &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunSucceeded{
JobRunSucceeded: &armadaevents.JobRunSucceeded{
RunId: runIdProto,
Expand Down
9 changes: 6 additions & 3 deletions internal/armada/event/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func TestEventServer_ForceNew(t *testing.T) {
jobIdString := "01f3j0g1md4qx7z5qb148qnh4r"
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))

Expand All @@ -82,7 +83,7 @@ func TestEventServer_ForceNew(t *testing.T) {
stream := &eventStreamMock{}

assigned := &armadaevents.EventSequence_Event{
Created: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunAssigned{
JobRunAssigned: &armadaevents.JobRunAssigned{
RunId: runIdProto,
Expand Down Expand Up @@ -216,11 +217,12 @@ func TestEventServer_GetJobSetEvents_ErrorIfMissing(t *testing.T) {
jobIdString := "01f3j0g1md4qx7z5qb148qnh4r"
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: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunAssigned{
JobRunAssigned: &armadaevents.JobRunAssigned{
RunId: runIdProto,
Expand Down Expand Up @@ -260,11 +262,12 @@ func TestEventServer_GetJobSetEvents_ErrorIfMissing(t *testing.T) {
jobIdString := "01f3j0g1md4qx7z5qb148qnh4r"
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: &baseTime,
Created: baseTimeProto,
Event: &armadaevents.EventSequence_Event_JobRunAssigned{
JobRunAssigned: &armadaevents.JobRunAssigned{
RunId: runIdProto,
Expand Down
Loading

0 comments on commit ca801e0

Please sign in to comment.