kevdoran commented on code in PR #11796:
URL: https://github.com/apache/nifi/pull/11796#discussion_r4417710538


##########
nifi-framework-bundle/nifi-framework-extensions/nifi-framework-kubernetes-bundle/nifi-framework-kubernetes-leader-election/src/test/java/org/apache/nifi/kubernetes/leader/election/KubernetesLeaderElectionManagerTest.java:
##########
@@ -148,6 +149,24 @@ void testIsLeaderNotRegistered() {
         assertFalse(leader);
     }
 
+    @Test
+    void testRegisterParticipatingStartLeadingFailToDetermineLeader() {
+        manager.register(ROLE, changeListener, PARTICIPANT_ID);
+
+        setSubmitStartLeading();
+
+        manager.start();
+
+        captureRunCommand();
+        assertActiveParticipantLeader();
+
+        leaderElectionCommandProvider.failOnFindLeader = true;
+
+        assertActiveParticipantFailToDetermineLeader();

Review Comment:
   [openai-gpt-6.1-sol] Minor, non-blocking: consider covering recovery here as 
well. After the failure assertions, set failOnFindLeader = false and assert 
that manager.isLeader(ROLE) returns true again. That would pin down recovery 
from the transient lookup failure without restarting the manager.



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java:
##########
@@ -3285,11 +3285,21 @@ public LeaderElectionManager getLeaderElectionManager() 
{
      */
     @Override
     public boolean isPrimary() {
-        return isClustered() && leaderElectionManager != null && 
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+        try {
+            return isClustered() && leaderElectionManager != null && 
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+        } catch (final Exception e) {

Review Comment:
   [openai-gpt-6.1-sol] Minor, non-blocking: these new FlowController guards 
are not exercised by the Kubernetes manager test, since that manager now 
catches the exception itself. Could FlowControllerTest stub its 
LeaderElectionManager mock to throw and assert that isPrimary() and 
isClusterCoordinator() return false? That would directly cover both 
framework-level catch branches.



-- 
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]

Reply via email to