exceptionfactory commented on code in PR #11796:
URL: https://github.com/apache/nifi/pull/11796#discussion_r4425206591
##########
nifi-framework-bundle/nifi-framework-extensions/nifi-framework-kubernetes-bundle/nifi-framework-kubernetes-leader-election/src/main/java/org/apache/nifi/kubernetes/leader/election/KubernetesLeaderElectionManager.java:
##########
@@ -224,13 +224,18 @@ public boolean isLeader(final String roleName) {
logger.debug("Role [{}] not participating in Leader election",
roleName);
leader = false;
} else {
- final Optional<String> leaderAddress = getLeader(roleName);
- final String leaderId = leaderAddress.orElse(null);
- leader = participantId.equals(leaderId);
- if (leader) {
- logger.debug("Role [{}] Participant ID [{}] is Leader",
roleName, participantId);
- } else {
- logger.debug("Role [{}] Participant ID [{}] not Leader",
roleName, leaderId);
+ try {
+ final Optional<String> leaderAddress = getLeader(roleName);
+ final String leaderId = leaderAddress.orElse(null);
+ leader = participantId.equals(leaderId);
+ if (leader) {
+ logger.debug("Role [{}] Participant ID [{}] is Leader",
roleName, participantId);
+ } else {
+ logger.debug("Role [{}] Participant ID [{}] not Leader,
Leader is [{}]", roleName, participantId, leaderId);
+ }
+ } catch (final Exception e) {
+ logger.warn("Failed to determine whether current node is
leader for Role [{}] with Participant ID [{}]. Assuming that it is not.",
roleName, participantId, e);
Review Comment:
```suggestion
logger.warn("Failed to determine leader for Role [{}] with
Participant ID [{}]", roleName, participantId, e);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]