diff --git a/client-java-contrib/Dockerfile b/client-java-contrib/Dockerfile index 9bc86f0284..d3496d155b 100644 --- a/client-java-contrib/Dockerfile +++ b/client-java-contrib/Dockerfile @@ -2,11 +2,15 @@ FROM docker:stable # install git, bash, kind, kubectl and clone the kubernetes-client/gen code base RUN apk add --no-cache git bash && \ - wget -O /usr/bin/kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-linux-amd64 && \ + wget -O /usr/bin/kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 && \ chmod +x /usr/bin/kind && \ - wget -O /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl && \ + wget -O /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.20.2/bin/linux/amd64/kubectl && \ chmod +x /usr/bin/kubectl && \ - git clone https://github.com/kubernetes-client/gen.git + git clone https://github.com/kubernetes-client/gen.git && \ + cd gen && \ + git checkout 729332ad08f0f4d98983b7beb027e2f657236ef9 + # 729332ad08f0f4d98983b7beb027e2f657236ef9 is the last commit using python2 interpreter + COPY Dockerfile.gen gen/openapi/openapi-generator/Dockerfile COPY generate.sh generate.sh diff --git a/client-java-contrib/admissionreview/generate.sh b/client-java-contrib/admissionreview/generate.sh index 2906335ea2..eec826b83e 100644 --- a/client-java-contrib/admissionreview/generate.sh +++ b/client-java-contrib/admissionreview/generate.sh @@ -5,5 +5,5 @@ docker run --rm \ -v $LOCAL_MANIFEST_FILE:$LOCAL_MANIFEST_FILE \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $PWD:$PWD \ - -it ghcr.io/yue9944882/crd-model-gen:v1.0.3 \ + -it ghcr.io/yue9944882/crd-model-gen:v1.0.6 \ sh -c "source /gen/openapi/java-crd-cmd.sh -n v1 -p io.kubernetes.client.admissionreview -l 2 -o $PWD/gen < $LOCAL_MANIFEST_FILE" diff --git a/client-java-contrib/cert-manager/update.sh b/client-java-contrib/cert-manager/update.sh index 215e8f9ee6..1edc3b5fbe 100755 --- a/client-java-contrib/cert-manager/update.sh +++ b/client-java-contrib/cert-manager/update.sh @@ -17,7 +17,7 @@ # under src/main/java/io/cert/manager/models. DEFAULT_IMAGE_NAME=docker.pkg.github.com/kubernetes-client/java/crd-model-gen -DEFAULT_IMAGE_TAG=v1.0.3 +DEFAULT_IMAGE_TAG=v1.0.6 IMAGE_NAME=${IMAGE_NAME:=$DEFAULT_IMAGE_NAME} IMAGE_TAG=${IMAGE_TAG:=$DEFAULT_IMAGE_TAG} diff --git a/client-java-contrib/prometheus-operator/update.sh b/client-java-contrib/prometheus-operator/update.sh index e100c49142..15d96e68d5 100755 --- a/client-java-contrib/prometheus-operator/update.sh +++ b/client-java-contrib/prometheus-operator/update.sh @@ -17,7 +17,7 @@ # under src/main/java/io/cert/manager/models. DEFAULT_IMAGE_NAME=docker.pkg.github.com/kubernetes-client/java/crd-model-gen -DEFAULT_IMAGE_TAG=v1.0.3 +DEFAULT_IMAGE_TAG=v1.0.6 IMAGE_NAME=${IMAGE_NAME:=$DEFAULT_IMAGE_NAME} IMAGE_TAG=${IMAGE_TAG:=$DEFAULT_IMAGE_TAG} diff --git a/util/src/main/java/io/kubernetes/client/informer/cache/ReflectorRunnable.java b/util/src/main/java/io/kubernetes/client/informer/cache/ReflectorRunnable.java index 7676733320..6c902c2a88 100644 --- a/util/src/main/java/io/kubernetes/client/informer/cache/ReflectorRunnable.java +++ b/util/src/main/java/io/kubernetes/client/informer/cache/ReflectorRunnable.java @@ -241,7 +241,11 @@ private void watchHandler(Watchable watch) { } if (eventType.get() == EventType.ERROR) { if (item.status != null && item.status.getCode() == HttpURLConnection.HTTP_GONE) { - log.info("Watch connection expired: {}", item.status.getMessage()); + log.info( + "ResourceVersion {} and Watch connection expired: {} , will retry w/o resourceVersion next time", + getRelistResourceVersion(), + item.status.getMessage()); + isLastSyncResourceVersionUnavailable = true; throw new WatchExpiredException(); } else { String errorMessage = diff --git a/util/src/test/java/io/kubernetes/client/informer/cache/ReflectorRunnableTest.java b/util/src/test/java/io/kubernetes/client/informer/cache/ReflectorRunnableTest.java index bb25b61095..b3f492e705 100644 --- a/util/src/test/java/io/kubernetes/client/informer/cache/ReflectorRunnableTest.java +++ b/util/src/test/java/io/kubernetes/client/informer/cache/ReflectorRunnableTest.java @@ -13,6 +13,7 @@ package io.kubernetes.client.informer.cache; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -312,4 +313,34 @@ public void testReflectorWatchShouldRelistUponExpiredWatchItem() throws ApiExcep .until(() -> future.isDone()); assertFalse(future.isCompletedExceptionally()); } + + @Test + public void testReflectorListShouldHandleExpiredResourceVersionFromWatchHandler() + throws ApiException { + String expectedResourceVersion = "100"; + when(listerWatcher.list(any())) + .thenReturn( + new V1PodList().metadata(new V1ListMeta().resourceVersion(expectedResourceVersion))); + + V1Status v1Status = new V1Status(); + v1Status.setMessage("dummy-error-message"); + v1Status.setCode(410); + when(listerWatcher.watch(any())) + .thenReturn(new MockWatch<>(new Watch.Response("Error", v1Status))); + ReflectorRunnable reflectorRunnable = + new ReflectorRunnable<>(V1Pod.class, listerWatcher, deltaFIFO); + try { + Thread thread = new Thread(reflectorRunnable::run); + thread.setDaemon(true); + thread.start(); + Awaitility.await() + .atMost(Duration.ofSeconds(1)) + .pollInterval(Duration.ofMillis(100)) + .until( + () -> expectedResourceVersion.equals(reflectorRunnable.getLastSyncResourceVersion())); + assertTrue(reflectorRunnable.isLastSyncResourceVersionUnavailable()); + } finally { + reflectorRunnable.stop(); + } + } }