Skip to content

Commit

Permalink
Fix fabric8io#1156 : Watcher does not have correct authentication inf…
Browse files Browse the repository at this point in the history
…ormation in Openshift environment.
  • Loading branch information
visavis2k authored and rohanKanojia committed Aug 28, 2018
1 parent 8f7e7c8 commit 2e3f927
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### 3.2.1 (To be released)
Bugs
* Fix #1144 : Get Request with OpenShift Mock Server Not Working
* Fix #1156 : Watcher does not have correct authentication information in Openshift environment.

New Feature

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.dsl.base.BaseOperation;
import io.fabric8.kubernetes.client.dsl.base.OperationSupport;
import io.fabric8.kubernetes.client.utils.HttpClientUtils;
import io.fabric8.kubernetes.client.utils.Utils;
import okhttp3.*;
import okio.ByteString;
Expand Down Expand Up @@ -70,7 +69,7 @@ public class WatchConnectionManager<T extends HasMetadata, L extends KubernetesR
private final URL requestUrl;

private WebSocket webSocket;
private OkHttpClient okhttpClient;
private OkHttpClient clonedClient;

public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T, L, ?, ?> baseOperation, final String version, final Watcher<T> watcher, final int reconnectInterval, final int reconnectLimit, long websocketTimeout, int maxIntervalExponent) throws MalformedURLException {
this.resourceVersion = new AtomicReference<>(version); // may be a reference to null
Expand All @@ -81,8 +80,7 @@ public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T,
this.websocketTimeout = websocketTimeout;
this.maxIntervalExponent = maxIntervalExponent;

Config requestConfig = new ConfigBuilder(baseOperation.getConfig()).withRequestTimeout((int)this.websocketTimeout).build();
this.okhttpClient = HttpClientUtils.createHttpClient(requestConfig);
this.clonedClient = client.newBuilder().readTimeout(this.websocketTimeout, TimeUnit.MILLISECONDS).build();

// The URL is created, validated and saved once, so that reconnect attempts don't have to deal with
// MalformedURLExceptions that would never occur
Expand Down Expand Up @@ -151,7 +149,7 @@ private final void runWatch() {
.addHeader("Origin", requestUrl.getProtocol() + "://" + requestUrl.getHost() + ":" + requestUrl.getPort())
.build();

webSocket = okhttpClient.newWebSocket(request, new WebSocketListener() {
webSocket = clonedClient.newWebSocket(request, new WebSocketListener() {
@Override
public void onOpen(final WebSocket webSocket, Response response) {
if (response != null && response.body() != null) {
Expand Down

0 comments on commit 2e3f927

Please sign in to comment.