Skip to content

Commit dd572ca

Browse files
committed
reconnect because of "resource version too old"
1 parent 4961697 commit dd572ca

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

operator-framework/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEventSource.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.slf4j.LoggerFactory;
1313

1414
import static io.javaoperatorsdk.operator.processing.ProcessingUtils.*;
15+
import static java.net.HttpURLConnection.HTTP_GONE;
1516

1617
/**
1718
* This is a special case since is not bound to a single custom resource
@@ -78,12 +79,14 @@ public void eventReceived(Watcher.Action action, CustomResource customResource)
7879

7980
@Override
8081
public void onClose(KubernetesClientException e) {
81-
// todo handle the fabric8 issue
82-
log.error("Error: ", e);
83-
// we will exit the application if there was a watching exception, because of the bug in fabric8 client
84-
// see https://github.com/fabric8io/kubernetes-client/issues/1318
85-
// Note that this should not happen normally, since fabric8 client handles reconnect.
86-
// In case it tries to reconnect this method is not called.
87-
System.exit(1);
82+
if (e.getCode() == HTTP_GONE) {
83+
log.warn("Received error for watch, will try to reconnect.", e);
84+
registerWatch();
85+
} else {
86+
// Note that this should not happen normally, since fabric8 client handles reconnect.
87+
// In case it tries to reconnect this method is not called.
88+
log.error("Unexpected error happened with watch. Will exit.", e);
89+
System.exit(1);
90+
}
8891
}
8992
}

0 commit comments

Comments
 (0)