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 terminating thread kube #3610

Closed
wants to merge 39 commits into from
Closed

Conversation

jrhizor
Copy link
Contributor

@jrhizor jrhizor commented May 26, 2021

Definitely not mergable, but I wanted to demonstrate one way we can do this.

HttpClientUtilsAirbyte is a clone of io.fabric8.kubernetes.client.utils.HttpClientUtils except with the inclusion of the following line:

httpClientBuilder.connectionPool(new ConnectionPool(0, 30, TimeUnit.SECONDS));

Since it specifies that we can't keep idle connections around it will incur a small performance hit on the kube api server, but it would fix this problem for now at least. We could also allow idle connections but move the keep alive down to 1s/500ms/similar.

I tried just using

OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
httpClientBuilder.connectionPool(new ConnectionPool(0, 30, TimeUnit.SECONDS));
httpClientBuilder.build();

but even in Docker for Desktop Kube it fails because it doesn't have all of that SSL configuration.

I bet there's an OkHttp client builder somewhere that is serviceable by default.

davinchia and others added 30 commits May 18, 2021 11:30
…It also waits for the pod to be ready before doing anything else. Sync worker will also remove the pod on termination.
* nearly working sources

* update

* stdin example
…t the airbyte-workers resource folder; place all the poc yamls together.
also clean up kubernetes deploys.
@jrhizor jrhizor requested a review from davinchia May 26, 2021 02:00
@auto-assign auto-assign bot requested review from cgardens and masonwheeler May 26, 2021 02:00
@@ -95,9 +99,10 @@ public static void main(String[] args) throws InterruptedException, IOException
// https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary
// Instead, the pod shuts down after 5 minutes as the pool reaps the remaining idle connection after
// 5 minutes of inactivity, as per the default configuration.
KUBE_CLIENT.close();
OK_HTTP_CLIENT.dispatcher().cancelAll();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this had no impact

@@ -95,9 +99,10 @@ public static void main(String[] args) throws InterruptedException, IOException
// https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary
// Instead, the pod shuts down after 5 minutes as the pool reaps the remaining idle connection after
// 5 minutes of inactivity, as per the default configuration.
KUBE_CLIENT.close();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reordering had no impact

// Explicitly create the underlying HTTP client since the Kube client has issues with closing the
// client. It is not clear in which library the fault
// lies. See https://github.com/fabric8io/kubernetes-client/issues/2403.
final Config CONFIG = new ConfigBuilder().build();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

making it non-static had no impact

// client. It is not clear in which library the fault
// lies. See https://github.com/fabric8io/kubernetes-client/issues/2403.
final Config CONFIG = new ConfigBuilder().build();
final OkHttpClient OK_HTTP_CLIENT = HttpClientUtilsAirbyte.createHttpClient(CONFIG);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only piece that had impact

@davinchia
Copy link
Contributor

nice! was thinking this is the 'best' way to do so.

I'm thinking we use system.exit for now, and open a PR against fabric to make their constructor configurable so we have less code to maintain. wdyt?

@jrhizor
Copy link
Contributor Author

jrhizor commented May 26, 2021

I'd actually prefer to clean this up slightly merge this in with a big comment linking to an issue and a fabric8 change. It looks like if it were accepted it'd take up to a month to get in place. We're going to need proper termination in a week.

Either that or I think we'd need to wrap everything in our main loop with a try catch that finally calls system.exit?

Either way I'll make the PR for fabric8 in the morning in hopes to get that into their next release ASAP.

@davinchia
Copy link
Contributor

davinchia commented May 26, 2021

Makes sense. I'll create an issue for us and Fabric and use the system.exit version in the mean time.

I'm going to start using the cloud tag.

Base automatically changed from davinchia/kube-api-cleanup to davinchia/kube-queueing-poc May 26, 2021 04:30
Base automatically changed from davinchia/kube-queueing-poc to master June 10, 2021 01:12
@jrhizor jrhizor closed this Jul 13, 2021
@jrhizor jrhizor deleted the jrhizor/fix-terminating-thread-kube branch July 13, 2021 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants