Skip to content

Commit 1b1a26f

Browse files
committed
addressing code smells and adding more changelog
1 parent 70206c1 commit 1b1a26f

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
##### DSL Changes:
5656
- #3127 `StatusUpdatable.updateStatus` deprecated, please use patchStatus, editStatus, or replaceStatus
5757
- #3239 deprecated methods on SharedInformerFactory directly dealing with the OperationContext, withName, and withNamespace - the Informable interface should be used instead.
58-
- #3271 waitUntilReady and waitUntilCondition with throw a KubernetesClientTimeoutException instead of an IllegalArgumentException on timeout
58+
- #3271 `Waitable.waitUntilReady` and `Waitable.waitUntilCondition` with throw a KubernetesClientTimeoutException instead of an IllegalArgumentException on timeout.
59+
`Waitable.withWaitRetryBackoff` and the associated constants are now deprecated.
5960

6061
##### Util Changes:
6162
- #3197 `Utils.waitUntilReady` now accepts a Future, rather than a BlockingQueue

kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/Waitable.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020

2121
public interface Waitable<T, P> {
2222

23+
/**
24+
* @deprecated no longer used
25+
*/
2326
@Deprecated
2427
long DEFAULT_INITIAL_BACKOFF_MILLIS = 5L;
28+
/**
29+
* @deprecated no longer used
30+
*/
2531
@Deprecated
2632
double DEFAULT_BACKOFF_MULTIPLIER = 2d;
2733

kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,9 @@ public void onDelete(T obj, boolean deletedFinalStateUnknown) {
11611161
} catch (ExecutionException e) {
11621162
throw KubernetesClientException.launderThrowable(e.getCause());
11631163
} catch (TimeoutException e) {
1164-
T item = getItem();
1165-
if (item != null) {
1166-
throw new KubernetesClientTimeoutException(item, amount, timeUnit);
1164+
T i = getItem();
1165+
if (i != null) {
1166+
throw new KubernetesClientTimeoutException(i, amount, timeUnit);
11671167
}
11681168
throw new KubernetesClientTimeoutException(getKind(), getName(), getNamespace(), amount, timeUnit);
11691169
}
@@ -1196,13 +1196,15 @@ public Informable<T> withIndexers(Map<String, Function<T, List<String>>> indexer
11961196
@Override
11971197
public SharedIndexInformer<T> inform(ResourceEventHandler<T> handler, long resync) {
11981198
DefaultSharedIndexInformer<T, L> result = createInformer(resync, null, handler);
1199+
// synchronous start list/watch must succeed in the calling thread
1200+
// initial add events will be processed in the calling thread as well
11991201
result.run();
12001202
return result;
12011203
}
12021204

12031205
private DefaultSharedIndexInformer<T, L> createInformer(long resync, Consumer<L> onList, ResourceEventHandler<T> handler) {
1204-
T item = getItem();
1205-
String name = (Utils.isNotNullOrEmpty(getName()) || item != null) ? checkName(item) : null;
1206+
T i = getItem();
1207+
String name = (Utils.isNotNullOrEmpty(getName()) || i != null) ? checkName(i) : null;
12061208

12071209
// use the local context / namespace
12081210
DefaultSharedIndexInformer<T, L> informer = new DefaultSharedIndexInformer<>(getType(), new ListerWatcher<T, L>() {

kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceListTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ void testSuccessfulWaitUntilCondition() throws InterruptedException {
185185
.anyMatch(c -> "True".equals(c.getStatus()));
186186

187187
// The pods are never ready if you request them directly.
188-
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&watch=false").andReturn(HTTP_OK, noReady1).once();
189-
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod2&watch=false").andReturn(HTTP_OK, noReady2).once();
188+
ResourceTest.list(server, noReady1);
189+
ResourceTest.list(server, noReady2);
190190

191191
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&resourceVersion=1&watch=true").andUpgradeToWebSocket()
192192
.open()
@@ -226,8 +226,8 @@ void testPartialSuccessfulWaitUntilCondition() {
226226
.anyMatch(c -> "True".equals(c.getStatus()));
227227

228228
// The pods are never ready if you request them directly.
229-
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod1&watch=false").andReturn(HTTP_OK, noReady1).once();
230-
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?fieldSelector=metadata.name%3Dpod2&watch=false").andReturn(HTTP_OK, noReady2).once();
229+
ResourceTest.list(server, noReady1);
230+
ResourceTest.list(server, noReady2);
231231

232232
Status gone = new StatusBuilder()
233233
.withCode(HTTP_GONE)

kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,13 @@ void testWaitUntilReady() throws InterruptedException {
237237
}
238238

239239
private void list(Pod pod) {
240+
list(server, pod);
241+
}
242+
243+
static void list(KubernetesMockServer server, Pod pod) {
240244
server.expect()
241245
.get()
242-
.withPath("/api/v1/namespaces/test/pods?fieldSelector=metadata.name%3D"+pod.getMetadata().getName()+"&watch=false")
246+
.withPath("/api/v1/namespaces/"+pod.getMetadata().getNamespace()+"/pods?fieldSelector=metadata.name%3D"+pod.getMetadata().getName()+"&watch=false")
243247
.andReturn(200,
244248
new PodListBuilder().withItems(pod).withNewMetadata().withResourceVersion("1").endMetadata().build())
245249
.once();

0 commit comments

Comments
 (0)