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

Migrate to openapi-generator and okhttp3 #709

Closed
wants to merge 12 commits into from

Conversation

fabiokung
Copy link

@fabiokung fabiokung commented Sep 21, 2019

Replaces #595. Requires yue9944882/gen#1 and sundrio/sundrio#156, kubernetes/pom.xml needs to be updated in this PR after it gets merged.

Fixes #482.

@yue9944882 @brendanburns I got everything compiling with these changes. They will break backwards compatibility, so a new major version release will be required.

EDIT: more requirements: OpenAPITools/openapi-generator#4226, OpenAPITools/openapi-generator#4182

@k8s-ci-robot
Copy link
Contributor

Welcome @fabiokung!

It looks like this is your first PR to kubernetes-client/java 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/java has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 21, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fabiokung
To complete the pull request process, please assign yue9944882
You can assign the PR to them by writing /assign @yue9944882 in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 21, 2019
@fabiokung
Copy link
Author

/assign @yue9944882

@fabiokung fabiokung changed the title Openapi Migrate to openapi-generator and okhttp3 Sep 21, 2019
@fabiokung
Copy link
Author

fabiokung commented Sep 21, 2019

Tests are also passing with a patched sundrio. The only way I can think of making CI happy before sundrio/sundrio#156 gets merged and released, would be to vendor a patched jar in here (ugh).

@fabiokung
Copy link
Author

I take it back, bootstrapping SSL needs some work (okhttp3 does not like a null SSLContextFactory), and the YAML test needs some fixing since the schema changed for IntOrString.

@brendandburns
Copy link
Contributor

What do you mean "Schema changed for IntOrString" the Schema should definitely not change in the API.

The last time I tried this, the custom type registration stuff in the generator (e.g. the stuff that makes IntOrString work correctly) was broken, that was the main problem that prevented us from switching.

Please make sure that IntOrString, Quantity, and the other custom types are parsing correctly.

Thanks!

@fabiokung
Copy link
Author

I see. I meant that I was just assuming the new generator explicitly wanted to map IntOrString to String.

I missed the custom generators stuff. Your comment makes sense. I will take a look later today or tomorrow.

@brendandburns
Copy link
Contributor

I had a thread (a while ago) with one of the OpenAPI maintainers. If you send mail to bburns [at] microsoft I will try to add you to the thread where I discussed some of the challenges I saw...

@yue9944882
Copy link
Member

hi @fabiokung any plans to revive this thread?

@fabiokung
Copy link
Author

Hi! Yes. I just had no time in the past weeks, but I can spend some cycles early next week, unless you want to pick it up?

@yue9944882
Copy link
Member

appreciated if you can continue the work! i added this to my list, and will be coming back for review soon!

@yue9944882
Copy link
Member

[ERROR] Failed to execute goal on project client-java-api: Could not resolve dependencies for project io.kubernetes:client-java-api:bundle:7.0.0-SNAPSHOT: Failure to find io.sundr:builder-annotations:jar:0.19-SNAPSHOT in https://oss.sonatype.org/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of sonatype-snapshots has elapsed or updates are forced -> [Help 1]

CI's complaining about failing to find io.sundr:builder-annotations:jar:0.19-SNAPSHOT, guess we should probably drop the suffix?

@yue9944882
Copy link
Member

@fabiokung the diff is so large that my browser can hardly load it, i did review locally in my IDE:

  1. pls generate the project from the latest release-1.15 branch, we are not skipping 1.15.

  2. plz add the following content back to the .openapi-generator-ignore file

# Remove this once swagger-codegen 2.3.0 is released and we update. 
# Verify the following PRs are in the release:
#   * https://github.com/swagger-api/swagger-codegen/pull/6230
src/main/java/io/kubernetes/client/JSON.java
# src/main/java/io/kubernetes/client/ApiClient.java (NOTE: probably want to add this back for further manual edits)
  1. plz resolve the git conflicts

  2. i see unexpected diffs in util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java, split this out as another PR:

    if (apiClient.getHttpClient().readTimeoutMillis() > 0) {
      log.warn("HttpClient has a read timeout, removing it so watch calls don't terminate early");
      OkHttpClient httpClient =
          apiClient.getHttpClient().newBuilder().readTimeout(0, TimeUnit.MILLISECONDS).build();
      apiClient.setHttpClient(httpClient);
    }
  1. in util/src/main/java/io/kubernetes/client/util/WebSocketStreamHandler.java line 109, why is the try-catch block dropped?

--- Thanks, Min

@yue9944882
Copy link
Member

yue9944882 commented Oct 14, 2019

@brendandburns do you think we should cut an alpha release for this pull? it will be breaking compatiblities and we can probably missing sth in this migration.. i can start by trying the alpha release out in our internal projects.

@fabiokung
Copy link
Author

CI's complaining about failing to find io.sundr:builder-annotations:jar:0.19-SNAPSHOT, guess we should probably drop the suffix?

I mentioned this in the PR description, we need to wait until sundrio/sundrio#156 gets merged, then update this to the right released version. In order to test this I had a locally built snapshot in my local maven repo, with the patched sundrio.

@fabiokung
Copy link
Author

@yue9944882 comments inline:

  1. pls generate the project from the latest release-1.15 branch, we are not skipping 1.15.

Sure, let me give it a try.

  1. plz add the following content back to the .openapi-generator-ignore file
# Remove this once swagger-codegen 2.3.0 is released and we update. 
# Verify the following PRs are in the release:
#   * https://github.com/swagger-api/swagger-codegen/pull/6230
src/main/java/io/kubernetes/client/JSON.java
# src/main/java/io/kubernetes/client/ApiClient.java (NOTE: probably want to add this back for further manual edits)

I'm reviewing the custom types with the new openapi-generator, and we may not need this anymore with openapi-generator.

  1. plz resolve the git conflicts
  2. i see unexpected diffs in util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java, split this out as another PR:

These are not unrelated changes, they are part of moving to okhttp3 (used by openapi-generator). The previous swagger-codegen used an older version of okhttp.

  1. in util/src/main/java/io/kubernetes/client/util/WebSocketStreamHandler.java line 109, why is the try-catch block dropped?

Same thing, the close() method with okhttp3 does not throw an IOException anymore.

@fabiokung
Copy link
Author

Regenerated against 1.15, and fixed the merge conflict.

Now we wait for OpenAPITools/openapi-generator#4182 to get IntOrString and Quantity working properly.

@fabiokung
Copy link
Author

Custom types look OK now. The last remaining issue is that SSL bootstraping in ApiClient (as generated by openapi-generator) is currently throwing NullPointerException.

@brendandburns
Copy link
Contributor

Thanks for the continued effort here, I'm looking forward to merging this!

@fabiokung
Copy link
Author

@yue9944882 AFAICT all the necessary changes have been merged to openapi-generator, and sundrio. I will leave it up to you if pointing kubernetes-client/gen to the master branch of openapi-generator is acceptable and regenerating all clients and models with it, or if we need to wait for a formal release of openapi-generator first.

@brendanburns
Copy link
Contributor

brendanburns commented Oct 24, 2019 via email

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Changes required to make everything compile with models generated by
openapi-generator (instead of swagger-codegen).

These changes break backwards compatibility, it will require a new major
version release.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
it includes sundrio/sundrio#156
to make javax.annotation.Generated work with Java 9
... when tests take more than 10min to complete.
Reapply changes from kubernetes-client#366 to the code generated by openapi-generator,
and keep the JSON file pinned (ignored by the generator) until those
changes make it into the generator.
@yue9944882
Copy link
Member

had confirmed w/ @wing328, the next release 4.2.0 will be landing by the end of october. https://github.com/OpenAPITools/openapi-generator/milestone/25. how about wait for 5-ish days? @brendandburns @fabiokung

@brendanburns
Copy link
Contributor

brendanburns commented Oct 25, 2019 via email

@fabiokung
Copy link
Author

how about wait for 5-ish days?

sgtm, no worries

@yue9944882
Copy link
Member

yue9944882 commented Oct 28, 2019

@fabiokung can you rename the generated package name to io.kubernetes.openapi in settings file per #744? the old project structure is causing issues in OSGi integration. besides i think we should reserve the old sources and deprecate them by following https://stackoverflow.com/a/23019294.

/**
 * @deprecated As of release 7.0.0, replaced by {@link io.kubernetes.openapi;}
 */
@Deprecated
package io.kubernetes.client; // TODO: completely remove it after release 9.0.0

@fabiokung
Copy link
Author

I will give that a try, not sure some of the non-generated classes will be backwards compatible, so keeping old classes may not do much. I will update with more info as I learn more.

@yue9944882
Copy link
Member

not sure some of the non-generated classes will be backwards compatible,

can you elaborate? there's no non-generated classes under client-java-api module AFAIK. i agree it won't save us from breaking compatibility but at least comfort those users who find their project broken from compiling after upgrading to new libraries in some sense..

@yue9944882
Copy link
Member

yue9944882 commented Oct 31, 2019

@fabiokung am changing my mind, let's completely remove the old generated classes and re-generated w/ the new name io.kubernetes.openapi. it's okay to lost compatibility between major versions.

@fabiokung
Copy link
Author

Awesome! I've been pretty swamped this week, but will get to it asap.

@yue9944882
Copy link
Member

yue9944882 commented Nov 5, 2019

@fabiokung anything i can help to move it forward? thanks

@fabiokung
Copy link
Author

On my end I still haven't been able to carve up some time to work on it. I expect to be able to get it done by the end of this week. Would that work for you? If not, we can find ways to hand over the remaining work to you.

@yue9944882
Copy link
Member

@fabiokung @brendandburns i just opened a pull to continue the work from this pull #778, PTAL

@fabiokung
Copy link
Author

@yue9944882 would you rather I bring your commits to this PR and rebase everything here, or continue on your PR? There's some important history here, but either way works for me.

@yue9944882
Copy link
Member

it's fine to separate the discussion/history and the actual pull #778 i suppose. thank you for your great effort in moving this forward!

@fabiokung
Copy link
Author

continuing in #778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
5 participants