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

Add pod importer #1825

Merged
merged 8 commits into from Mar 20, 2024
Merged

Add pod importer #1825

merged 8 commits into from Mar 20, 2024

Conversation

trasc
Copy link
Contributor

@trasc trasc commented Mar 12, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Add a CLI tool able to import existing pods into Kueue.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 12, 2024
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 12, 2024
Copy link

netlify bot commented Mar 12, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit e6e41fb
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/65fb0514966904000878b4ce

@trasc trasc force-pushed the importer branch 5 times, most recently from f545a9f to 00aa28a Compare March 18, 2024 09:39
@yaroslava-serdiuk
Copy link
Contributor

Could you add README file with short description how to use the script, please?

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 19, 2024
cmd/importer/main.go Show resolved Hide resolved
cmd/importer/main.go Outdated Show resolved Hide resolved
cmd/importer/main.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 19, 2024
@trasc trasc changed the title [WIP]Importer Add pod importer Mar 19, 2024
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 19, 2024
@trasc trasc marked this pull request as ready for review March 19, 2024 15:25
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 19, 2024
cmd/importer/main.go Outdated Show resolved Hide resolved
cmd/importer/README.md Show resolved Hide resolved
cmd/importer/main.go Show resolved Hide resolved
cmd/importer/README.md Outdated Show resolved Hide resolved
cmd/importer/pod/check.go Outdated Show resolved Hide resolved
cmd/importer/main.go Outdated Show resolved Hide resolved
cmd/importer/pod/import.go Outdated Show resolved Hide resolved
cmd/importer/pod/import.go Outdated Show resolved Hide resolved
cmd/importer/util/util.go Outdated Show resolved Hide resolved
cmd/importer/util/util.go Outdated Show resolved Hide resolved
test/integration/importer/importer_test.go Show resolved Hide resolved
cmd/importer/README.md Outdated Show resolved Hide resolved
cmd/importer/README.md Outdated Show resolved Hide resolved
- The label key (`queuelabel`) providing the queue mapping is provided.
- A mapping from ane of the encountered `queuelabel` values to an existing LocalQueue exists.
- The LocalQueues involved in the import are using an existing ClusterQueue.
- The ClusterQueues involved have at least one ResourceGroup using an existing ResourceFlavor. This ResourceFlavor is used when the importer creates the admission for the created workloads.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why at least one? What will happen if it uses non-existing ResourceFlavors?
Probably we should at least log warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the first resource flavor is not created, the check will fail.

### Example

```bash
./bin/importer import -n ns1,ns2 --queuelabel=src.lbl --queuemapping=src-val=user-queue,src-val=user-queue --dry-run=false
Copy link
Contributor

Choose a reason for hiding this comment

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

Why queuemapping has two identical parameters with src-val label, which was not specified in --queuelabel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why queuemapping has two identical parameters with src-val label

fixed

cmd/importer/README.md Outdated Show resolved Hide resolved
cmd/importer/pod/check.go Outdated Show resolved Hide resolved
cmd/importer/pod/import.go Outdated Show resolved Hide resolved
log := ctrl.LoggerFrom(ctx)
log.Info("Check done", "checked", summary.TotalPods, "failed", summary.FailedPods)
for e, pods := range summary.ErrorsForPods {
log.Info("Error", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])
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
log.Info("Error", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])
log.Info("Check failed for Pod", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

log := ctrl.LoggerFrom(ctx)
log.Info("Import done", "checked", summary.TotalPods, "failed", summary.FailedPods)
for e, pods := range summary.ErrorsForPods {
log.Info("Error", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])
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
log.Info("Error", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])
log.Info("Could not import Pod", "err", e, "occurrences", len(pods), "obsevedFirstIn", pods[0])

Copy link
Contributor

Choose a reason for hiding this comment

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

also, klog.KRef(pods[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pods is []string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return fmt.Errorf("%q flavor %q: %w", cq.Name, rf, util.ErrCQInvalid)
}

// do some additional checks like:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's enhance the dry run:

Let's produce a list of the assignments to be done for each pod (local queue name, cluster queue name, flavor).

Copy link
Contributor

Choose a reason for hiding this comment

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

As V(2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someting like "log.Info("Check succeeded" , "pod", kref.., "lq", LocalQueue ....)"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe more like:
Dry run: Pod to be imported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

Copy link
Contributor

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 45d53443f4403e435ec314b656d77f7537bf3f00

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, trasc

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 20, 2024
@k8s-ci-robot k8s-ci-robot merged commit 530fafc into kubernetes-sigs:main Mar 20, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.7 milestone Mar 20, 2024
@trasc trasc deleted the importer branch March 22, 2024 06:14
vsoch pushed a commit to researchapps/kueue that referenced this pull request Apr 18, 2024
* [pod] Export `FromObject()`

* [cmd/importer] Initial implementation.

* Review Remarks

* Add extra labels

* Review Remarks

* Review Remarks

* Review Remarks

* Review Remarks
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants