Skip to content
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

Conversation

tenzen-y
Copy link
Member

@tenzen-y tenzen-y commented May 5, 2024

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:

  1. Moved frameworks and externalFrameworks validations to the pkg/config package.
  2. Moved registration of externalFrameworks to the SetUpControllers function in the jobframework package.
  3. Expand validations
    1. Added the duplication error for the frameworks.
    2. Added the invalid format error for the externalFrameworks.

Which issue(s) this PR fixes:

Part-of #1601

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels May 5, 2024
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from kerthcet and trasc May 5, 2024 02:10
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 5, 2024
Copy link

netlify bot commented May 5, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 0335c34
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/663bb158e1e0050008214e0d

@tenzen-y tenzen-y force-pushed the move-integrations-validation-to-dedicated-pkg branch from ddbb2c5 to ddbbfdd Compare May 5, 2024 02:11
@tenzen-y tenzen-y changed the title Reorganize validatins for the frameworks and externalFrameworks Reorganize validations for the frameworks and the externalFrameworks May 5, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 6, 2024
@k8s-ci-robot
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EnabledExternalFrameworks []string
EnabledExternalFrameworks sets.Set[string]

Copy link
Member Author

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

for _, fwkName := range options.EnabledExternalFrameworks {
if err := RegisterExternalJobType(fwkName); err != nil {
return err
}
}

Copy link
Contributor

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).

Copy link
Member Author

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:

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.

Copy link
Member Author

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 {
Copy link
Contributor

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.

Copy link
Member Author

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)
[...]

Copy link
Contributor

@trasc trasc May 8, 2024

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:

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 .

Copy link
Member Author

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

Copy link
Member Author

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.

jobframework.WithIntegrationOptions(corev1.SchemeGroupVersion.WithKind("Pod").String(), cfg.Integrations.PodOptions),

We already checked if the cfg.integrations is not null here:

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold cancel

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold cancel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE.

@tenzen-y
Copy link
Member Author

tenzen-y commented May 8, 2024

After the fair sharing PR is merged, I will rebase this PR since both PR have conflicts.

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels May 8, 2024
@tenzen-y tenzen-y force-pushed the move-integrations-validation-to-dedicated-pkg branch from ddbbfdd to 11b4061 Compare May 8, 2024 17:04
@tenzen-y
Copy link
Member Author

tenzen-y commented May 8, 2024

/hold cancel

@tenzen-y tenzen-y force-pushed the move-integrations-validation-to-dedicated-pkg branch from 11b4061 to 0335c34 Compare May 8, 2024 17:07
@tenzen-y
Copy link
Member Author

tenzen-y commented May 8, 2024

I'm not sure the reason why the needs-rebase label is not removed 🧐

0335c34 (HEAD -> move-integrations-validation-to-dedicated-pkg, origin/move-integrations-validation-to-dedicated-pkg) Reorganize validations for the frameworks and the externalFrameworks
54d1c01 (origin/main, origin/HEAD) Add APIs for configuring fair sharing (#2070)
6cceaa0 [KEP] Support new ProvisioningRequest's conditions (#2042)

/assign @trasc

Copy link
Contributor

@trasc trasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 8, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6f0c2a3e541a6587bc56d23ac3c14f63a5ac9cd8

@k8s-ci-robot k8s-ci-robot merged commit 156529d into kubernetes-sigs:main May 8, 2024
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.7 milestone May 8, 2024
@tenzen-y tenzen-y deleted the move-integrations-validation-to-dedicated-pkg branch May 8, 2024 17:36
kannon92 pushed a commit to openshift-kannon92/kubernetes-sigs-kueue that referenced this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants