Repository: armadaproject/armada
Pull request #3477 (2024-03-27 09:26:07)

Filter out non-scheduler annotations in the scheduler ingester 


Patch:
diff --git a/internal/armada/configuration/constants.go b/internal/armada/configuration/constants.go
index 49e0051f..b5bb9be9 100644
--- a/internal/armada/configuration/constants.go
+++ b/internal/armada/configuration/constants.go
@@ -21,3 +21,17 @@ const (
 	// Instead, the job the pod is part of fails immediately.
 	FailFastAnnotation = "armadaproject.io/failFast"
 )
+
+var schedulingAnnotations = map[string]bool{
+	GangIdAnnotation:                  true,
+	GangCardinalityAnnotation:         true,
+	GangMinimumCardinalityAnnotation:  true,
+	GangNodeUniformityLabelAnnotation: true,
+	GangNumJobsScheduledAnnotation:    true,
+	FailFastAnnotation:                true,
+}
+
+func IsSchedulingAnnotation(annotation string) bool {
+	_, ok := schedulingAnnotations[annotation]
+	return ok
+}
diff --git a/internal/scheduleringester/instructions.go b/internal/scheduleringester/instructions.go
index 45ea4188..50934667 100644
--- a/internal/scheduleringester/instructions.go
+++ b/internal/scheduleringester/instructions.go
@@ -9,6 +9,7 @@ import (
 	"golang.org/x/exp/maps"
 	"golang.org/x/exp/slices"
 
+	"github.com/armadaproject/armada/internal/armada/configuration"
 	"github.com/armadaproject/armada/internal/common/armadacontext"
 	"github.com/armadaproject/armada/internal/common/compress"
 	"github.com/armadaproject/armada/internal/common/ingest"
@@ -415,7 +416,11 @@ func SchedulingInfoFromSubmitJob(submitJob *armadaevents.SubmitJob, submitTime t
 			if podRequirements.Annotations == nil {
 				podRequirements.Annotations = make(map[string]string, len(submitJob.MainObject.ObjectMeta.Annotations))
 			}
-			maps.Copy(podRequirements.Annotations, submitJob.MainObject.ObjectMeta.Annotations)
+			for k, v := range submitJob.MainObject.ObjectMeta.Annotations {
+				if configuration.IsSchedulingAnnotation(k) {
+					podRequirements.Annotations[k] = v
+				}
+			}
 		}
 		schedulingInfo.ObjectRequirements = append(
 			schedulingInfo.ObjectRequirements,


Test patch:
diff --git a/internal/common/ingest/testfixtures/event.go b/internal/common/ingest/testfixtures/event.go
index fbc3143f..a4a4fa16 100644
--- a/internal/common/ingest/testfixtures/event.go
+++ b/internal/common/ingest/testfixtures/event.go
@@ -8,6 +8,7 @@ import (
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
 
+	"github.com/armadaproject/armada/internal/armada/configuration"
 	"github.com/armadaproject/armada/internal/common/eventutil"
 	"github.com/armadaproject/armada/internal/common/types"
 	"github.com/armadaproject/armada/internal/scheduler/schedulerobjects"
@@ -93,6 +94,12 @@ var Submit = &armadaevents.EventSequence_Event{
 				Name:      "test-job",
 			},
 			MainObject: &armadaevents.KubernetesMainObject{
+				ObjectMeta: &armadaevents.ObjectMeta{
+					Annotations: map[string]string{
+						"foo":                            "bar",
+						configuration.FailFastAnnotation: "true",
+					},
+				},
 				Object: &armadaevents.KubernetesMainObject_PodSpec{
 					PodSpec: &armadaevents.PodSpecWithAvoidList{
 						PodSpec: &v1.PodSpec{
diff --git a/internal/scheduleringester/instructions_test.go b/internal/scheduleringester/instructions_test.go
index 2389320b..87598bfb 100644
--- a/internal/scheduleringester/instructions_test.go
+++ b/internal/scheduleringester/instructions_test.go
@@ -10,6 +10,7 @@ import (
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
 
+	"github.com/armadaproject/armada/internal/armada/configuration"
 	"github.com/armadaproject/armada/internal/common/compress"
 	"github.com/armadaproject/armada/internal/common/ingest/metrics"
 	f "github.com/armadaproject/armada/internal/common/ingest/testfixtures"
@@ -321,6 +322,9 @@ func getExpectedSubmitMessageSchedulingInfo(t *testing.T) *schedulerobjects.JobS
 								"cpu":    resource.MustParse("150m"),
 							},
 						},
+						Annotations: map[string]string{
+							configuration.FailFastAnnotation: "true",
+						},
 					},
 				},
 			},