-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixes various problems usage of OpenShift client #7629
Conversation
@@ -103,7 +103,8 @@ protected void doBootstrapAsync(String installerWebsocketEndpoint, String output | |||
+ Integer.toString(installerTimeoutSeconds) | |||
+ " -file " | |||
+ BOOTSTRAPPER_DIR | |||
+ CONFIG_FILE); | |||
+ CONFIG_FILE | |||
+ " &>/dev/null &"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why you've added this. It is not obvious that it is a way to make process detached.
@@ -107,8 +107,9 @@ protected void internalStart(Map<String, String> startOptions) throws Infrastruc | |||
for (Route route : osEnv.getRoutes().values()) { | |||
createdRoutes.add(project.routes().create(route)); | |||
} | |||
project.pods().watch(new AbnormalStopHandler()); | |||
project.pods().watchContainers(new MachineLogsPublisher()); | |||
// TODO link with issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the corresponding issue.
@@ -52,7 +59,7 @@ public OpenShiftClientFactory( | |||
if (doTrustCerts != null) { | |||
configBuilder.withTrustCerts(doTrustCerts); | |||
} | |||
config = configBuilder.build(); | |||
this.client = new DefaultOpenShiftClient(configBuilder.build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a decorator that would eliminate the risk of calling close on the client.
@@ -65,6 +64,9 @@ | |||
private static final Pattern CONTAINER_FIELD_PATH_PATTERN = | |||
Pattern.compile("spec.containers\\{(?<" + CONTAINER_NAME_GROUP + ">.*)}"); | |||
|
|||
// TODO make it configurable | |||
public static final int POD_REMOVAL_TIMEOUT_MIN = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an issue for this todo or remove it
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
throw new InfrastructureException( | ||
"Interrupted while waiting for pod removal. " + e.getMessage()); | ||
} catch (ExecutionException e) { | ||
throw new InfrastructureException( | ||
"Error occurred while waiting for pod removing. " + e.getMessage()); | ||
} catch (TimeoutException ex) { | ||
throw new InfrastructureException("Pods removal timeout reached " + ex.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on what will happen in this situation with cleanup of other resources and with the possible following start of the same workspace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is similar to other exception that is possible on cleanup, I would say that we should revise cleanup in general. Because if any step of cleanup is failed then, other resources won't be cleaned. I'll create an issue for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return deleteFuture | ||
.thenAccept((v) -> watch.close()) | ||
.exceptionally( | ||
e -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also log the exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added exception logging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The investigation is cool!
return deleteFuture; | ||
|
||
return deleteFuture | ||
.thenAccept((v) -> watch.close()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's the same as
return deleteFuture
.handle((v, e) -> {
watch.close();
return null;
});
But it will supress rethrowing of exception from original delete future. Is it OK?
/** Decorates the {@link DefaultOpenShiftClient} so that it can not be closed from the outside. */ | ||
private static class UnclosableOpenShiftClient extends DefaultOpenShiftClient { | ||
|
||
public UnclosableOpenShiftClient(OpenShiftConfig build) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename it to config =)
|
||
/** @author Sergii Leshchenko */ | ||
@Singleton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't be shy to add yourself as an author 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
What does this PR do?
Replaces the usage of one
OpenShiftClient
per action to one client per che-server. The reason why we do that is theOpenShiftClient
holds an instance ofOkHttpClient
inside and each time when we create newOpenShiftClient
we create newOkHttpClient
with all the components inside, on close, theOpenShiftClient
prevent cancel all calls currently that are executed byOkHttpClient
, close all the connections and stop the dispatcher executor service (that undoubtedly is overhead).Adds closing of watcher on pod removing.
Disables abnormal stop and container events watching.
Launches bootstrapper as a detached process.
What issues does this PR fix or reference?
#7418
This problem is not reproduced in case of using one OpenShift client per che server: #5902