-
Notifications
You must be signed in to change notification settings - Fork 230
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
Added an option to control processing jobs with no queue name set #205
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ limitations under the License. | |
package job | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
|
@@ -27,9 +29,12 @@ import ( | |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
kueue "sigs.k8s.io/kueue/apis/core/v1alpha1" | ||
"sigs.k8s.io/kueue/pkg/constants" | ||
"sigs.k8s.io/kueue/pkg/controller/workload/job" | ||
workloadjob "sigs.k8s.io/kueue/pkg/controller/workload/job" | ||
"sigs.k8s.io/kueue/pkg/util/testing" | ||
"sigs.k8s.io/kueue/pkg/workload" | ||
|
@@ -46,10 +51,28 @@ const ( | |
priorityValue = 10 | ||
) | ||
|
||
var ( | ||
cfg *rest.Config | ||
k8sClient client.Client | ||
ctx context.Context | ||
fwk *framework.Framework | ||
crdPath = filepath.Join("..", "..", "..", "..", "config", "crd", "bases") | ||
) | ||
|
||
// +kubebuilder:docs-gen:collapse=Imports | ||
|
||
var _ = ginkgo.Describe("Job controller", func() { | ||
ginkgo.It("Should reconcile workload and job", func() { | ||
ginkgo.BeforeEach(func() { | ||
fwk = &framework.Framework{ | ||
ManagerSetup: managerSetup(job.WithProcessJobsWithoutQueueName(true)), | ||
CRDPath: crdPath, | ||
} | ||
ctx, cfg, k8sClient = fwk.Setup() | ||
}) | ||
ginkgo.AfterEach(func() { | ||
fwk.Teardown() | ||
}) | ||
ginkgo.It("Should reconcile workload and job for all jobs", func() { | ||
ginkgo.By("checking the job gets suspended when created unsuspended") | ||
priorityClass := testing.MakePriorityClass(priorityClassName). | ||
PriorityValue(int32(priorityValue)).Obj() | ||
|
@@ -221,3 +244,37 @@ var _ = ginkgo.Describe("Job controller", func() { | |
}, framework.Timeout, framework.Interval).Should(gomega.BeTrue()) | ||
}) | ||
}) | ||
|
||
var _ = ginkgo.Describe("Job controller for workloads with no queue set", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I would use a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the indentation is too much for me :) |
||
ginkgo.BeforeEach(func() { | ||
fwk = &framework.Framework{ | ||
ManagerSetup: managerSetup(), | ||
CRDPath: crdPath, | ||
} | ||
ctx, cfg, k8sClient = fwk.Setup() | ||
}) | ||
ginkgo.AfterEach(func() { | ||
fwk.Teardown() | ||
}) | ||
ginkgo.It("Should reconcile jobs only when queue is set", func() { | ||
ginkgo.By("checking the workload is not created when queue name is not set") | ||
job := testing.MakeJob(jobName, jobNamespace).Obj() | ||
gomega.Expect(k8sClient.Create(ctx, job)).Should(gomega.Succeed()) | ||
lookupKey := types.NamespacedName{Name: jobName, Namespace: jobNamespace} | ||
createdJob := &batchv1.Job{} | ||
gomega.Expect(k8sClient.Get(ctx, lookupKey, createdJob)).Should(gomega.Succeed()) | ||
|
||
createdWorkload := &kueue.Workload{} | ||
gomega.Consistently(func() bool { | ||
return apierrors.IsNotFound(k8sClient.Get(ctx, lookupKey, createdWorkload)) | ||
}, framework.ConsistentDuration, framework.Interval).Should(gomega.BeTrue()) | ||
|
||
ginkgo.By("checking the workload is created when queue name is set") | ||
jobQueueName := "test-queue" | ||
createdJob.Annotations = map[string]string{constants.QueueAnnotation: jobQueueName} | ||
gomega.Expect(k8sClient.Update(ctx, createdJob)).Should(gomega.Succeed()) | ||
gomega.Eventually(func() error { | ||
return k8sClient.Get(ctx, lookupKey, createdWorkload) | ||
}, framework.Timeout, framework.Interval).Should(gomega.Succeed()) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Should this be
queueName(&job) || "" && !r.processJobsWithoutQueueName
, if users don't set the queue name, we do not have a default queue name for them now IIRC.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify again the question? this basically says if
r.processJobsWithoutQueueName=false
, then don't manage jobs that don't set the queue-name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A default queue name can be added, but it needs to be set via a webhook at job creation time if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean whether we should only check
r.processJobsWithoutQueueName
here and if queueName not set, we will add a default queue name likedefault
automatically inConstructWorkloadFor
. But this means we should have default queue and default cq in initialization.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem we are trying to solve here is not that the queue is missing per se; see #63 (comment)
basically we don't want to miss up with potentially existing jobs when kueue is first installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved discussion here #208