diff --git a/CHANGELOG.md b/CHANGELOG.md index f4a89006799..9a2f0f97dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,8 @@ ##### DSL Changes: - #3127 `StatusUpdatable.updateStatus` deprecated, please use patchStatus, editStatus, or replaceStatus - #3239 deprecated methods on SharedInformerFactory directly dealing with the OperationContext, withName, and withNamespace - the Informable interface should be used instead. -- #3271 waitUntilReady and waitUntilCondition with throw a KubernetesClientTimeoutException instead of an IllegalArgumentException on timeout +- #3271 `Waitable.waitUntilReady` and `Waitable.waitUntilCondition` with throw a KubernetesClientTimeoutException instead of an IllegalArgumentException on timeout. + `Waitable.withWaitRetryBackoff` and the associated constants are now deprecated. ##### Util Changes: - #3197 `Utils.waitUntilReady` now accepts a Future, rather than a BlockingQueue diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java index 7e29931653e..4c7544ee7c7 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java @@ -20,8 +20,14 @@ public interface Waitable { + /** + * @deprecated no longer used + */ @Deprecated long DEFAULT_INITIAL_BACKOFF_MILLIS = 5L; + /** + * @deprecated no longer used + */ @Deprecated double DEFAULT_BACKOFF_MULTIPLIER = 2d; diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java index 0c2d42bd80c..2a0159c1468 100755 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java @@ -1161,9 +1161,9 @@ public void onDelete(T obj, boolean deletedFinalStateUnknown) { } catch (ExecutionException e) { throw KubernetesClientException.launderThrowable(e.getCause()); } catch (TimeoutException e) { - T item = getItem(); - if (item != null) { - throw new KubernetesClientTimeoutException(item, amount, timeUnit); + T i = getItem(); + if (i != null) { + throw new KubernetesClientTimeoutException(i, amount, timeUnit); } throw new KubernetesClientTimeoutException(getKind(), getName(), getNamespace(), amount, timeUnit); } @@ -1196,13 +1196,15 @@ public Informable withIndexers(Map>> indexer @Override public SharedIndexInformer inform(ResourceEventHandler handler, long resync) { DefaultSharedIndexInformer result = createInformer(resync, null, handler); + // synchronous start list/watch must succeed in the calling thread + // initial add events will be processed in the calling thread as well result.run(); return result; } private DefaultSharedIndexInformer createInformer(long resync, Consumer onList, ResourceEventHandler handler) { - T item = getItem(); - String name = (Utils.isNotNullOrEmpty(getName()) || item != null) ? checkName(item) : null; + T i = getItem(); + String name = (Utils.isNotNullOrEmpty(getName()) || i != null) ? checkName(i) : null; // use the local context / namespace DefaultSharedIndexInformer informer = new DefaultSharedIndexInformer<>(getType(), new ListerWatcher() { diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceListTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceListTest.java index f12f28260f2..76845069877 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceListTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceListTest.java @@ -185,8 +185,8 @@ void testSuccessfulWaitUntilCondition() throws InterruptedException { .anyMatch(c -> "True".equals(c.getStatus())); // The pods are never ready if you request them directly. - server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&watch=false").andReturn(HTTP_OK, noReady1).once(); - server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod2&watch=false").andReturn(HTTP_OK, noReady2).once(); + ResourceTest.list(server, noReady1); + ResourceTest.list(server, noReady2); server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket() .open() @@ -226,8 +226,8 @@ void testPartialSuccessfulWaitUntilCondition() { .anyMatch(c -> "True".equals(c.getStatus())); // The pods are never ready if you request them directly. - server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&watch=false").andReturn(HTTP_OK, noReady1).once(); - server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod2&watch=false").andReturn(HTTP_OK, noReady2).once(); + ResourceTest.list(server, noReady1); + ResourceTest.list(server, noReady2); Status gone = new StatusBuilder() .withCode(HTTP_GONE) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java index 7cdd065edef..6a6acf1862a 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java @@ -237,9 +237,13 @@ void testWaitUntilReady() throws InterruptedException { } private void list(Pod pod) { + list(server, pod); + } + + static void list(KubernetesMockServer server, Pod pod) { server.expect() .get() - .withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3D"+pod.getMetadata().getName()+"&watch=false") + .withPath("/api/v1/namespaces/"+pod.getMetadata().getNamespace()+"/pods?fieldSelector=metadata.name%3D"+pod.getMetadata().getName()+"&watch=false") .andReturn(200, new PodListBuilder().withItems(pod).withNewMetadata().withResourceVersion("1").endMetadata().build()) .once();