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

fix(sdk): Add Kubernetes refs to the JobSet OpenAPI swagger #810

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

andreyvelich
Copy link
Member

@andreyvelich andreyvelich commented Mar 3, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

After we migrated to the latest OpenAPI generator: openapi-generator-cli:v7.11.0, it generates JobSet models using the Pydantic library. It requires for all external models to be presented, otherwise serialization will fail:

from_dict()
to_dict()

As you can see, the JobsetV1alpha2JobSet class depends on V1ObjectMeta class which we don't import in the jobset_v1alpha2_job_set.py file.

To solve this problem, I've updated JobSet swagger to include external Kubernetes models, for instance

"$ref": "https://raw.githubusercontent.com/kubernetes/kubernetes/refs/tags/v1.32.2/api/openapi-spec/swagger.json#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"

cc @tenzen-y @kannon92 @ahg-g @Electronic-Waste @danielvegamyhre @epicseven-cup @astefanutti

Special notes for your reviewer:

We need this fix for Kubeflow Trainer integration: kubeflow/trainer#2466

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 3, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @andreyvelich. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 3, 2025
Copy link

netlify bot commented Mar 3, 2025

Deploy Preview for kubernetes-sigs-jobset ready!

Name Link
🔨 Latest commit 70cb4cc
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-jobset/deploys/67c61fd47c662b0008ac35f9
😎 Deploy Preview https://deploy-preview-810--kubernetes-sigs-jobset.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ahg-g
Copy link
Contributor

ahg-g commented Mar 3, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 3, 2025
@ahg-g
Copy link
Contributor

ahg-g commented Mar 3, 2025

Is this embedding all jobset api dependencies in jobset's python sdk? is this a common practice?

@kannon92
Copy link
Contributor

kannon92 commented Mar 3, 2025

/hold

@andreyvelich is working on this for kubeflow. I don't have a strong stance on this but I'd like to get buy in from kubeflow's PR until we merge this one.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2025
@andreyvelich
Copy link
Member Author

Is this embedding all jobset api dependencies in jobset's python sdk?

Yes, otherwise the serialization will fail.
As I said, currently JobSet models uses Kubernetes models that don't exist in JobSet SDK package: https://github.com/kubernetes-sigs/jobset/blob/main/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py#L33.

is this a common practice?

I noticed that Argo Workflows also import all Kubernetes dependencies in their SDK models: https://github.com/argoproj/argo-workflows/blob/main/sdks/python/client/argo_workflows/model/object_meta.py.

Argo Workflows has the valid OpenAPI spec swagger with all definitions: https://github.com/argoproj/argo-workflows/blob/main/api/openapi-spec/swagger.json

@andreyvelich
Copy link
Member Author

@kannon92 @ahg-g FYI, this fix also blocks us to use v0.8.0 JobSet Python package in our Kubeflow SDK.
I had to downgrade the JobSet version to avoid error in e2e: https://github.com/kubeflow/trainer/pull/2470/files#diff-271810b5660339392a509b5e1e83a9272497a323dabc5eb82910292c2f4ce87aR34-R36

The same error user reported in Slack:
https://cloud-native.slack.com/archives/C0742LDFZ4K/p1741077959344629?thread_ts=1740708722.833979&cid=C0742LDFZ4K

@andreyvelich
Copy link
Member Author

Do we want to consider to cherry-pick it for v0.8.1 if that makes sense?

@ahg-g
Copy link
Contributor

ahg-g commented Mar 4, 2025

Do we want to consider to cherry-pick it for v0.8.1 if that makes sense?

I am ok to cherry-pick if this unblocks kubeflow trainer

Copy link
Contributor

@kannon92 kannon92 left a comment

Choose a reason for hiding this comment

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

/lgtm

Have we got consensus on the KubeFlow PR for this?

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andreyvelich, kannon92

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 4, 2025
@andreyvelich
Copy link
Member Author

Have we got consensus on the KubeFlow PR for this?

I think, so.
@tenzen-y @Electronic-Waste @astefanutti @saileshd1402 @deepanker13 @shravan-achar @akshaychitneni Any concerns to merge this PR?

Copy link

@Electronic-Waste Electronic-Waste left a comment

Choose a reason for hiding this comment

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

I'm ok for this PR:)

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

/lgtm

Thank you.

@tenzen-y
Copy link
Member

tenzen-y commented Mar 5, 2025

/lgtm

Have we got consensus on the KubeFlow PR for this?

Based on this comment.
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 5, 2025
@k8s-ci-robot k8s-ci-robot merged commit d5c7bce into kubernetes-sigs:main Mar 5, 2025
12 checks passed
@andreyvelich andreyvelich deleted the fix-swagger-ref branch March 5, 2025 16:13
@kannon92
Copy link
Contributor

kannon92 commented Mar 5, 2025

/cherry-pick release-0.8

1 similar comment
@tenzen-y
Copy link
Member

tenzen-y commented Mar 5, 2025

/cherry-pick release-0.8

@kannon92
Copy link
Contributor

kannon92 commented Mar 5, 2025

@tenzen-y what are we missing to do this? Some kind of test-infra plugin?

@tenzen-y
Copy link
Member

tenzen-y commented Mar 5, 2025

@tenzen-y what are we missing to do this? Some kind of test-infra plugin?

This one: kubernetes/test-infra#34463

@tenzen-y
Copy link
Member

tenzen-y commented Mar 5, 2025

/cherry-pick release-0.8

@k8s-infra-cherrypick-robot

@tenzen-y: Failed to get PR patch from GitHub. This PR will need to be manually cherrypicked.

Error messagestatus code 406 not one of [200], body: {"message":"Sorry, the diff exceeded the maximum number of lines (20000)","errors":[{"resource":"PullRequest","field":"diff","code":"too_large"}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#get-a-pull-request","status":"406"}

In response to this:

/cherry-pick release-0.8

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.

@tenzen-y
Copy link
Member

tenzen-y commented Mar 5, 2025

status code 406 not one of [200], body: {"message":"Sorry, the diff exceeded the maximum number of lines (20000)","errors":[{"resource":"PullRequest","field":"diff","code":"too_large"}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#get-a-pull-request","status":"406"}

It seems that diff size exceeds the limits 😓

@kannon92
Copy link
Contributor

kannon92 commented Mar 5, 2025

@andreyvelich can you create a manually cherry-pick for this into 0.8?

andreyvelich added a commit to andreyvelich/jobset that referenced this pull request Mar 5, 2025
…es-sigs#810)

* Add Kubernetes refs to the JobSet OpenAPI spec

* Remove SDK docs from generation
k8s-ci-robot pushed a commit that referenced this pull request Mar 5, 2025
)

* Add Kubernetes refs to the JobSet OpenAPI spec

* Remove SDK docs from generation
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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

7 participants