You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/27 16:34:15 UTC

[GitHub] [flink] tillrohrmann commented on a change in pull request #13263: [FLINK-17273][runtime] ActiveResourceManager closes task manager connection on worker terminated.

tillrohrmann commented on a change in pull request #13263:
URL: https://github.com/apache/flink/pull/13263#discussion_r478544665



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/active/ActiveResourceManagerTest.java
##########
@@ -307,6 +308,33 @@ public void testWorkerTerminatedNoLongerRequired() throws Exception {
 		}};
 	}
 
+	@Test
+	public void testCloseTaskManagerConnectionOnWorkerTerminated() throws Exception {
+		new Context() {{
+			final ResourceID tmResourceId = ResourceID.generate();
+			final CompletableFuture<TaskExecutorProcessSpec> requestWorkerFromDriverFuture = new CompletableFuture<>();
+			final CompletableFuture<Void> disconnectResourceManagerFuture = new CompletableFuture<>();
+
+			final TestingTaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder()
+				.setDisconnectResourceManagerConsumer((ignore) -> disconnectResourceManagerFuture.complete(null))
+				.createTestingTaskExecutorGateway();
+
+			driverBuilder.setRequestResourceFunction(taskExecutorProcessSpec -> {
+				requestWorkerFromDriverFuture.complete(taskExecutorProcessSpec);
+				return CompletableFuture.completedFuture(tmResourceId);
+			});
+
+			runTest(() -> {
+				// request a new worker, terminate it after registered
+				runInMainThread(() -> getResourceManager().startNewWorker(WORKER_RESOURCE_SPEC))
+					.thenCompose((ignrore) -> registerTaskExecutor(tmResourceId, taskExecutorGateway))

Review comment:
       ```suggestion
   					.thenCompose((ignore) -> registerTaskExecutor(tmResourceId, taskExecutorGateway))
   ```

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/active/ActiveResourceManager.java
##########
@@ -197,11 +197,12 @@ public void onPreviousAttemptWorkersRecovered(Collection<WorkerType> recoveredWo
 	}
 
 	@Override
-	public void onWorkerTerminated(ResourceID resourceId) {
-		log.info("Worker {} is terminated.", resourceId.getStringWithMetadata());
+	public void onWorkerTerminated(ResourceID resourceId, Exception cause) {

Review comment:
       If we don't really use `Exception cause` here, then I would suggest to simply change it into a `String diagnostics` parameter. We can later still change it if we need an `Exception` to be reported.

##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/active/ActiveResourceManagerTest.java
##########
@@ -307,6 +308,33 @@ public void testWorkerTerminatedNoLongerRequired() throws Exception {
 		}};
 	}
 
+	@Test
+	public void testCloseTaskManagerConnectionOnWorkerTerminated() throws Exception {
+		new Context() {{
+			final ResourceID tmResourceId = ResourceID.generate();
+			final CompletableFuture<TaskExecutorProcessSpec> requestWorkerFromDriverFuture = new CompletableFuture<>();
+			final CompletableFuture<Void> disconnectResourceManagerFuture = new CompletableFuture<>();
+
+			final TestingTaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder()
+				.setDisconnectResourceManagerConsumer((ignore) -> disconnectResourceManagerFuture.complete(null))
+				.createTestingTaskExecutorGateway();
+
+			driverBuilder.setRequestResourceFunction(taskExecutorProcessSpec -> {
+				requestWorkerFromDriverFuture.complete(taskExecutorProcessSpec);
+				return CompletableFuture.completedFuture(tmResourceId);
+			});
+
+			runTest(() -> {
+				// request a new worker, terminate it after registered
+				runInMainThread(() -> getResourceManager().startNewWorker(WORKER_RESOURCE_SPEC))
+					.thenCompose((ignrore) -> registerTaskExecutor(tmResourceId, taskExecutorGateway))
+					.thenRun(() -> runInMainThread(() -> getResourceManager().onWorkerTerminated(tmResourceId, new Exception())));
+				// verify task manager connection is closed
+				disconnectResourceManagerFuture.get(TIMEOUT_SEC, TimeUnit.SECONDS);
+			});

Review comment:
       I really like this test setup. It is very elegant :-)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org