Savonitar commented on code in PR #28639:
URL: https://github.com/apache/flink/pull/28639#discussion_r4106670485


##########
flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/ResourceManagerJobMasterTest.java:
##########
@@ -152,6 +161,39 @@ void testRegisterJobMaster() {
                 .isInstanceOf(JobMasterRegistrationSuccess.class);
     }
 
+    /**
+     * FLIP-588: if the delegation token manager rejects the job (its {@code 
registerJob} throws),
+     * the ResourceManager must reject the JobMaster registration so the job 
does not start without
+     * the tokens it requires. This also exercises the widened (6-arg) {@code 
registerJobMaster} RPC
+     * that carries the job {@link Configuration}.
+     */
+    @Test
+    void testRegisterJobMasterRejectedWhenDelegationTokenRegistrationFails() 
throws Exception {
+        // Rebuild the RM service with a delegation token manager that rejects 
registerJob.
+        resourceManagerService.rethrowFatalErrorIfAny();
+        resourceManagerService.cleanUp();
+        final FlinkRuntimeException failure =
+                new FlinkRuntimeException("registerJob rejected by provider");
+        createAndStartResourceManagerService(new 
RejectingDelegationTokenManager(failure));
+
+        final CompletableFuture<RegistrationResponse> registrationFuture =
+                resourceManagerGateway.registerJobMaster(
+                        jobMasterGateway.getFencingToken(),
+                        jobMasterResourceId,
+                        jobMasterGateway.getAddress(),
+                        jobId,
+                        new Configuration(),
+                        TIMEOUT);
+
+        final RegistrationResponse response =
+                registrationFuture.get(TIMEOUT.toMillis(), 
TimeUnit.MILLISECONDS);
+        assertThat(response).isInstanceOf(RegistrationResponse.Failure.class);
+        final Throwable reason = ((RegistrationResponse.Failure) 
response).getReason();
+        assertThat(reason.getMessage()).contains(jobId.toString());
+        assertThat(reason.getMessage()).contains("delegation token manager");
+        assertThat(reason.getCause().getMessage()).contains("registerJob 
rejected by provider");

Review Comment:
   Added coverage in 39bf3667d73 and 8b25efa085e. 
   The ResourceManager test now verifies that the failed attempt leaves no 
usable JobMaster registration, then checks that a subsequent attempt succeeds.
   A separate test runs a **real** JobMaster against a ResourceManager and lets 
the JobMaster retry **automatically** after token registration fails once. It 
verifies that the retry preserves the job ID and configuration, establishes the 
connection, and allows resource declarations.
   I intentionally didnt squash them in case we want to keep only one of those 
tests.



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