gaborgsomogyi commented on code in PR #19372: URL: https://github.com/apache/flink/pull/19372#discussion_r848157811
########## flink-runtime/src/main/java/org/apache/flink/runtime/security/token/KerberosDelegationTokenManager.java: ########## @@ -110,13 +126,84 @@ public void obtainDelegationTokens(Credentials credentials) { * task managers. */ @Override - public void start() { - LOG.info("Starting renewal task"); + public void start() throws Exception { + checkState(renewalExecutor == null, "Manager is already started"); + + if (!isRenewalPossible()) { + LOG.info("Renewal is NOT possible, skipping to start renewal task"); + return; + } + + ThreadFactory threadFactory = + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("Credential Renewal Thread") + .build(); + renewalExecutor = new ScheduledThreadPoolExecutor(1, threadFactory); Review Comment: After I've had a deep look I've found the following obstacles which blocks us to use the mentioned executors: * If you mean `ResourceManager.getMainThreadExecutor` to use in the first bullet point then that's a `MainThreadExecutor` instance which doesn't support `scheduleAtFixedRate`, please see [here](https://github.com/apache/flink/blob/4034d3cd6d13e88e2e5ca101510bf333e94a53fa/flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcEndpoint.java#L537). We can implement that from scratch but touching core threading can be super dangerous, though I'm not against it to add such functionality. * If we would rely on `ResourceManager.getMainThreadExecutor` then we must modify the interface (`start` function) and we need to put implementation details into the interface (the 2 executors) which would frustrate me a bit. I think if we want to do dependency injection then the proper place would be the constructor which is not touching the interface. Here if we decide to modify the interface I can accept that but I would think the implementation would be less clean. * If we would add the new `scheduleAtFixedRate` functionality then `ResourceManager` usage is covered but in [MiniCluster](https://github.com/apache/flink/blob/f089a99ce73ad15531a4d1b72899d8367fab662a/flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java#L431) we must provide something too but there no such executor exists (at least I've not found anything) so we need to come up w/ a new executor anyway. All in all I've left the original code there for now until we make an agreement. I understand the direction not to pollute w/ threads but in this case the return of investment is low because in some cases new executor is needed but the code would be more complex. Would like to hear your voice on this. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org