Skip to content

Commit

Permalink
[FLINK-15789][kubernetes] Do not wrap the InterruptedException and th…
Browse files Browse the repository at this point in the history
…row a different one in ActionWatcher.await

This closes apache#10970.
  • Loading branch information
wangyang0918 authored and tillrohrmann committed Feb 3, 2020
1 parent aff098b commit bab25ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.flink.kubernetes.kubeclient.resources.KubernetesService;
import org.apache.flink.kubernetes.utils.Constants;
import org.apache.flink.util.TimeUtils;
import org.apache.flink.util.function.FunctionUtils;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.Pod;
Expand Down Expand Up @@ -314,12 +315,13 @@ private CompletableFuture<KubernetesService> createService(
final Duration timeout = TimeUtils.parseDuration(
flinkConfig.get(KubernetesConfigOptions.SERVICE_CREATE_TIMEOUT));

return CompletableFuture.supplyAsync(() -> {
final Service createdService = watcher.await(timeout.toMillis(), TimeUnit.MILLISECONDS);
watchConnectionManager.close();
return CompletableFuture.supplyAsync(
FunctionUtils.uncheckedSupplier(() -> {
final Service createdService = watcher.await(timeout.toMillis(), TimeUnit.MILLISECONDS);
watchConnectionManager.close();

return new KubernetesService(this.flinkConfig, createdService);
});
return new KubernetesService(this.flinkConfig, createdService);
}));
}

private KubernetesService getService(String serviceName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ public void eventReceived(Action action, T resource) {
public void onClose(KubernetesClientException e) {
}

public T await(long amount, TimeUnit timeUnit) {
try {
if (this.latch.await(amount, timeUnit)) {
return this.reference.get();
} else {
throw new KubernetesClientTimeoutException(this.resource, amount, timeUnit);
}
} catch (InterruptedException var5) {
public T await(long amount, TimeUnit timeUnit) throws InterruptedException {
if (this.latch.await(amount, timeUnit)) {
return this.reference.get();
} else {
throw new KubernetesClientTimeoutException(this.resource, amount, timeUnit);
}
}
Expand Down

0 comments on commit bab25ae

Please sign in to comment.