Skip to content

Commit 6b5f6ce

Browse files
authored
Merge pull request #659 from wu8685/master
show exception message when failing to acquire or renew election lock
2 parents f0ba3f2 + f736005 commit 6b5f6ce

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

examples/src/main/java/io/kubernetes/client/examples/LeaderElectionExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void main(String[] args) throws Exception {
2424
EndpointsLock lock = new EndpointsLock("kube-system", "leader-election", "foo");
2525

2626
LeaderElectionConfig leaderElectionConfig =
27-
new LeaderElectionConfig(lock, Duration.ofMillis(10000), null, Duration.ofMillis(5000));
27+
new LeaderElectionConfig(lock, Duration.ofMillis(10000), null, Duration.ofMillis(2000));
2828
LeaderElector leaderElector = new LeaderElector(leaderElectionConfig);
2929

3030
leaderElector.run(

extended/src/main/java/io/kubernetes/client/extended/leaderelection/LeaderElector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private boolean acquire() {
6969
} catch (CancellationException e) {
7070
log.info("Processing tryAcquireOrRenew successfully canceled");
7171
} catch (Throwable t) {
72+
log.error("Error processing tryAcquireOrRenew as {}", t.getMessage());
7273
future.cancel(true);
7374
}
7475
},

extended/src/main/java/io/kubernetes/client/extended/leaderelection/resourcelock/ConfigMapLock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public boolean update(LeaderElectionRecord record) {
9696
.putAnnotationsItem(
9797
LeaderElectionRecordAnnotationKey,
9898
coreV1Client.getApiClient().getJSON().serialize(record));
99+
// TODO consider to retry if receiving a 409 code
99100
V1ConfigMap replacedConfigMap =
100101
coreV1Client.replaceNamespacedConfigMap(name, namespace, configMap, null, null, null);
101102
configMapRefer.set(replacedConfigMap);

extended/src/main/java/io/kubernetes/client/extended/leaderelection/resourcelock/EndpointsLock.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public boolean update(LeaderElectionRecord record) {
9696
.putAnnotationsItem(
9797
LeaderElectionRecordAnnotationKey,
9898
coreV1Client.getApiClient().getJSON().serialize(record));
99+
// TODO consider to retry if receiving a 409 code
99100
V1Endpoints replacedEndpoints =
100101
coreV1Client.replaceNamespacedEndpoints(name, namespace, endpoints, null, null, null);
101102
endpointsRefer.set(replacedEndpoints);

0 commit comments

Comments
 (0)