-
Notifications
You must be signed in to change notification settings - Fork 288
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
Utilize jobframework setups #1630
Utilize jobframework setups #1630
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tenzen-y The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
9425583
to
b60d7ed
Compare
bfedab3
to
5d17773
Compare
pkg/config/config.go
Outdated
return sets.New(cfg.Integrations.Frameworks...) | ||
} | ||
|
||
func IsWaitForPodsReadyEnable(cfg *configapi.Configuration) bool { |
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.
func IsWaitForPodsReadyEnable(cfg *configapi.Configuration) bool { | |
func IsWaitForPodsReadyEnabled(cfg *configapi.Configuration) bool { |
maybe this will read better
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.
SGTM
gotWls := &kueue.WorkloadList{} | ||
if tc.wantFieldMatcherError { | ||
// Given that the `wantFieldMatcherError` is `true`, a list operation without fieldMatcher should succeed. | ||
if gotListErr := k8sClient.List(ctx, gotWls, client.InNamespace(testNamespace)); gotListErr != nil { |
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.
IIUC, this operation would succeed also when wantFieldMatcherError=false, right? If so, what is the purpose of this check and making it conditional?
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.
IIUC, this operation would succeed also when wantFieldMatcherError=false, right?
Yes, that's right.
the purpose of this check
I wanted to verify that this operation would succeeded when we don't use the fieldMatcher
.
We probably also should verify that the gotWls
has the proper workloads here.
making it conditional?
I wanted to avoid unnecessary checks when the wantFieldMatcherError=false
.
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.
We probably also should verify that the gotWls has the proper workloads here.
I think so.
I wanted to avoid unnecessary checks when the wantFieldMatcherError=false.
I see, but maybe we can remove the conditional for simplicity. Or, alternatively, add a comment why it is checked.
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 see, but maybe we can remove the conditional for simplicity.
I'm ok with removing the conditional since this is a unit test, and increasing the test execution time almost wouldn't happen.
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.
updated.
} | ||
for name, tc := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
ctx := context.Background() |
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.
Make sure the ctx is closed at the end of each test case
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.
Does this mean the following?
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
IIUC, the context.Background()
generates an empty context.
So I think that we need not such a check.
If my understanding isn't correct, let me know.
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 see, it is empty. Still, we need to be careful passing it to other functions. When a function starts goroutines using the context they may leak because the context is not closed. Thus, it seems a safe practice to use the snippet as you pasted to make sure the context passed to any functions is closed after the test case.
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.
It makes sense. Let's make sure that the context is closed.
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.
Done.
}, | ||
modifyOpts: func(fwkName string, opts ...Option) ([]Option, error) { return opts, nil }, | ||
}, | ||
"modifyOptions returns errors": { |
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 we add a test case when kubeflow is enabled, but there is no mapper for it?
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.
Proving no errors occur would be valuable In that case. Thanks!
log.Info("No matching API in the server for job framework, skipped setup of controller and webhook") |
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.
Done.
filter client.ListOption | ||
wantError error | ||
wantFieldMatcherError bool | ||
wantList []string |
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.
wantList []string | |
wantWorkloads []string |
nit
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.
Done.
|
||
cases := map[string]struct { | ||
opts []Option | ||
wls []client.Object |
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.
wls []client.Object | |
workloads []client.Object |
nit
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.
Done.
26f0985
to
e823204
Compare
e823204
to
67ef390
Compare
/lgtm |
It seems that I need to rebase this PR. |
1d86f51
to
eefbe1e
Compare
/assign @alculquicondor |
cmd/kueue/main.go
Outdated
jobframework.WithManageJobsWithoutQueueName(manageJobsWithoutQueueName), | ||
jobframework.WithWaitForPodsReady(waitForPodsReady(cfg)), | ||
jobframework.WithManageJobsWithoutQueueName(cfg.ManageJobsWithoutQueueName), | ||
jobframework.WithWaitForPodsReady(config.IsWaitForPodsReadyEnabled(cfg.WaitForPodsReady)), |
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.
What about something like this?
I don't think we should need two separate functions to process the configuration.
jobframework.WithWaitForPodsReady(config.IsWaitForPodsReadyEnabled(cfg.WaitForPodsReady)), | |
jobframework.WithWaitForPodsReady(cfg.WaitForPodsReady), |
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.
It makes sense.
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.
Also I think we can apply the same way to EnabledFrameworks
.
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.
Done.
|
||
func SetupControllers( | ||
mgr ctrl.Manager, | ||
setupLog logr.Logger, |
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.
setupLog logr.Logger, | |
log logr.Logger, |
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.
Done.
13ffe8c
to
27ab24f
Compare
f519b21
to
8c31eff
Compare
Signed-off-by: tenzen-y <[email protected]>
8c31eff
to
78acd53
Compare
/hold cancel @alculquicondor I rebased this PR. Please take another look. |
// The controllers won't work until the webhooks are operating, and the webhook won't work until the | ||
// certs are all in place. | ||
cert.WaitForCertsReady(log, certsReady) |
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.
Did you forget to remove this from main?
Or maybe it shouldn't be here.
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.
Both here and the main one is intended although I should replace
Lines 222 to 226 in 78acd53
// The controllers won't work until the webhooks are operating, and the webhook won't work until the | |
// certs are all in place. | |
setupLog.Info("Waiting for certificate generation to complete") | |
<-certsReady | |
setupLog.Info("Certs ready") |
cert.WaitForCertsReady().
I think we need to perform cert.WaitForCertsReady()
here since in the in-house custom job kueue-manager, only this function launches controllers and webhooks.
However, the kueue-manager launches controllers and webooks in this function and main's setupControllers()
.
So, I think both Is needed. @alculquicondor WDYT?
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.
yeah, but maybe they didn't setup certs at all? I think they can call the function if they need it.
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.
It makes sense. Let's remove it from here.
They can call WaitForCertsReady()
since it is an exported one.
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.
Done.
errFailedMappingResource = errors.New("restMapper failed mapping resource") | ||
) | ||
|
||
func SetupControllers(mgr ctrl.Manager, log logr.Logger, certsReady chan struct{}, opts ...Option) error { |
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.
Add comments for how/when this should be used
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.
It makes sense.
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.
Done.
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.
maybe this file should be named setup.go
?
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.
SGTM
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.
Done.
Signed-off-by: tenzen-y <[email protected]>
Signed-off-by: tenzen-y <[email protected]>
Signed-off-by: tenzen-y <[email protected]>
Signed-off-by: tenzen-y <[email protected]>
The above CI error occurred due to a connection error with the go proxy server.
|
@alculquicondor I addressed all comments. PTAL, thanks. |
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.
/lgtm
LGTM label has been added. Git tree hash: f0805ea43f86cb0c0af3ba4d381d4e41ebe05325
|
* Utilize jobframework setups Signed-off-by: tenzen-y <[email protected]> * Use WaitForCertsReady function in main setupControllers Signed-off-by: tenzen-y <[email protected]> * Add a comment how/when use the utilized functions Signed-off-by: tenzen-y <[email protected]> * Rename jobframework.go with setup.go Signed-off-by: tenzen-y <[email protected]> * No wait for certs get ready inside the SetupControlers Signed-off-by: tenzen-y <[email protected]> --------- Signed-off-by: tenzen-y <[email protected]>
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
I utilized setup functions for the jobframeworks so that the platform developers can avoid to copy those functions to separate in-house controllers.
Which issue(s) this PR fixes:
Part-of #1601
Special notes for your reviewer:
Does this PR introduce a user-facing change?