Skip to content

Add local-queue annotation to use created local queue by default in g… #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions support/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (

// Storage bucket credentials
storageDefaultEndpoint = "AWS_DEFAULT_ENDPOINT"
storageDefaultRegion = "AWS_DEFAULT_REGION"
storageAccessKeyId = "AWS_ACCESS_KEY_ID"
storageSecretKey = "AWS_SECRET_ACCESS_KEY"
storageBucketName = "AWS_STORAGE_BUCKET"
Expand Down Expand Up @@ -133,6 +134,11 @@ func GetStorageBucketDefaultEndpoint() (string, bool) {
return storage_endpoint, exists
}

func GetStorageBucketDefaultRegion() (string, bool) {
storage_default_region, exists := os.LookupEnv(storageDefaultRegion)
return storage_default_region, exists
}

func GetStorageBucketAccessKeyId() (string, bool) {
storage_access_key_id, exists := os.LookupEnv(storageAccessKeyId)
return storage_access_key_id, exists
Expand Down
22 changes: 20 additions & 2 deletions support/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,20 @@ func CreateKueueClusterQueue(t Test, clusterQueueSpec kueuev1beta1.ClusterQueueS
return clusterQueue
}

func CreateKueueLocalQueue(t Test, namespace, clusterQueueName string) *kueuev1beta1.LocalQueue {
var AsDefaultQueue = defaultLocalQueueOption{}

type defaultLocalQueueOption struct {
}

func (d defaultLocalQueueOption) applyTo(to *kueuev1beta1.LocalQueue) error {
if to.Annotations == nil {
to.Annotations = make(map[string]string)
}
to.Annotations["kueue.x-k8s.io/default-queue"] = "true"
return nil
}

func CreateKueueLocalQueue(t Test, namespace string, clusterQueueName string, options ...Option[*kueuev1beta1.LocalQueue]) *kueuev1beta1.LocalQueue {
t.T().Helper()

localQueue := &kueuev1beta1.LocalQueue{
Expand All @@ -82,7 +95,12 @@ func CreateKueueLocalQueue(t Test, namespace, clusterQueueName string) *kueuev1b
},
}

localQueue, err := t.Client().Kueue().KueueV1beta1().LocalQueues(namespace).Create(t.Ctx(), localQueue, metav1.CreateOptions{})
//Apply options
for _, opt := range options {
t.Expect(opt.applyTo(localQueue)).To(gomega.Succeed())
}

localQueue, err := t.Client().Kueue().KueueV1beta1().LocalQueues(localQueue.Namespace).Create(t.Ctx(), localQueue, metav1.CreateOptions{})
t.Expect(err).NotTo(gomega.HaveOccurred())
t.T().Logf("Created Kueue LocalQueue %s/%s successfully", localQueue.Namespace, localQueue.Name)

Expand Down
12 changes: 12 additions & 0 deletions support/kueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,20 @@ func TestCreateKueueLocalQueue(t *testing.T) {

test.Expect(lq).To(gomega.Not(gomega.BeNil()))
test.Expect(lq.GenerateName).To(gomega.Equal("lq-"))
annotationKey := "kueue.x-k8s.io/default-queue"
_, exists := lq.Annotations[annotationKey]
test.Expect(exists).To(gomega.BeFalse(), "Annotation key %s should not exist", annotationKey)
test.Expect(lq.Namespace).To(gomega.Equal("ns-1"))
test.Expect(lq.Spec.ClusterQueue).To(gomega.Equal(kueuev1beta1.ClusterQueueReference("cq-1")))

default_lq := CreateKueueLocalQueue(test, "ns-2", "cq-2", AsDefaultQueue)

test.Expect(default_lq).To(gomega.Not(gomega.BeNil()))
test.Expect(default_lq.GenerateName).To(gomega.Equal("lq-"))
test.Expect(default_lq.Annotations["kueue.x-k8s.io/default-queue"]).To(gomega.Equal("true"))
test.Expect(default_lq.Namespace).To(gomega.Equal("ns-2"))
test.Expect(default_lq.Spec.ClusterQueue).To(gomega.Equal(kueuev1beta1.ClusterQueueReference("cq-2")))

}

func TestGetKueueWorkloads(t *testing.T) {
Expand Down