-
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
Reorganize validations for the frameworks and the externalFrameworks #2130
Reorganize validations for the frameworks and the externalFrameworks #2130
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.
|
ddbb2c5
to
ddbbfdd
Compare
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
LabelKeysToCopy []string | ||
IntegrationOptions map[string]any | ||
EnabledFrameworks sets.Set[string] | ||
EnabledExternalFrameworks []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.
EnabledExternalFrameworks []string | |
EnabledExternalFrameworks sets.Set[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.
I'm not sure about the advantage of sets.Set
here because the EnabledExternalFrameworks
is used only in
kueue/pkg/controller/jobframework/setup.go
Lines 50 to 54 in ddbbfdd
for _, fwkName := range options.EnabledExternalFrameworks { | |
if err := RegisterExternalJobType(fwkName); err != nil { | |
return err | |
} | |
} |
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.
Conceptually there should be no duplicates (in my opinion).
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.
Correct. Actually, we verify the duplications here:
kueue/pkg/config/validation.go
Line 134 in ddbbfdd
allErrs = append(allErrs, field.Duplicate(integrationsExternalFrameworkPath.Index(idx), framework)) |
But, I'll convert type to Set
here for the users who set up external controller without
func SetupControllers(mgr ctrl.Manager, log logr.Logger, opts ...Option) error { |
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.
DONE.
@@ -135,6 +136,16 @@ func WithEnabledFrameworks(i *configapi.Integrations) Option { | |||
} | |||
} | |||
|
|||
// WithEnabledExternalFrameworks adds framework names managed by external controller in the Config API. | |||
func WithEnabledExternalFrameworks(i *configapi.Integrations) Option { |
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 just pass the string slice of external integrations.
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, I was thinking about a similar thing, but I would like to keep using this arg since I want to perform null pointer check here, not in advance.
If we use the external frameworks as an arg here, we need to verify null pointer like this, right?
var external []string
if config.Integratons != nil {
external = config.Integratons.ExternalFrameworks
}
[...]
.WithEnabledExternalFrameworks(external)
[...]
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.
In my opinion the nil check should be performed by the caller, also the fact that we get that pointer when the option is created and only use it when the option is applied can be seen as problematic.
In case config.Integratons is nil, we are failing before this because of:
Line 272 in 6cceaa0
jobframework.WithIntegrationOptions(corev1.SchemeGroupVersion.WithKind("Pod").String(), cfg.Integrations.PodOptions), |
For this PR, I guess, we can have it like this as well but we'll need a cleanup PR for this and WithEnabledFrameworks
.
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.
Uhm, that sounds reasonable.
Let me try to refactor the WithEnabledFrameworks
and WithIntegrationOptions
in another PR, first.
Thanks.
/hold
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.
Wait, I just remembered the reason why I didn't implement the null pointer check here.
Line 272 in 6cceaa0
jobframework.WithIntegrationOptions(corev1.SchemeGroupVersion.WithKind("Pod").String(), cfg.Integrations.PodOptions), |
We already checked if the cfg.integrations
is not null here:
kueue/pkg/config/validation.go
Lines 128 to 130 in 6cceaa0
if c.Integrations == nil { | |
return field.ErrorList{field.Required(integrationsPath, "cannot be empty")} | |
} |
So, I don't this that we should verify the null pointer for the WithIntegrationOptions
.
But I agree with passing the integrations.Frameworks
to the WithEnabledFrameworks
instead of the integrations
.
I just can change the arg of the WithEnabledFrameworks
in this PR.
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.
/hold cancel
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 just can change the arg of the WithEnabledFrameworks in this PR.
It seems that we need to change many places if we want to change the arg of the WithEnabledFrameworks
.
So, let me do it in the follow-ups.
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.
/hold cancel
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.
After the fair sharing PR is merged, I will rebase this PR since both PR have conflicts. |
ddbbfdd
to
11b4061
Compare
/hold cancel |
Signed-off-by: Yuki Iwai <[email protected]>
11b4061
to
0335c34
Compare
I'm not sure the reason why the
/assign @trasc |
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: 6f0c2a3e541a6587bc56d23ac3c14f63a5ac9cd8
|
…ubernetes-sigs#2130) Signed-off-by: Yuki Iwai <[email protected]>
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
To re-organize the frameworks and externalFrameworks validation, I changed the following:
pkg/config
package.SetUpControllers
function in the jobframework package.Which issue(s) this PR fixes:
Part-of #1601
Special notes for your reviewer:
Does this PR introduce a user-facing change?