Github user kishorvpatil commented on a diff in the pull request: https://github.com/apache/storm/pull/2531#discussion_r164154647 --- Diff: storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java --- @@ -2638,6 +2647,34 @@ private int getNumOfAckerExecs(Map<String, Object> totalConf, StormTopology topo } } + private void upsertWorkerTokensInCreds(Map<String, String> creds, String user, String topologyId) { + if (workerTokenManager != null) { + final long renewIfExpirationBefore = workerTokenManager.getMaxExpirationTimeForRenewal(); + for (WorkerTokenServiceType type : WorkerTokenServiceType.values()) { + boolean shouldAdd = true; + WorkerToken oldToken = AuthUtils.readWorkerToken(creds, type); + if (oldToken != null) { + try { + WorkerTokenInfo info = AuthUtils.getWorkerTokenInfo(oldToken); + if (info.is_set_expirationTimeMillis() || info.get_expirationTimeMillis() > renewIfExpirationBefore) { + //Found an existing token and it is not going to expire any time soon, so don't bother adding in a new + // token. + shouldAdd = false; + } + } catch (Exception e) { + //The old token could not be deserialized. This is bad, but we are going to replace it anyways so just keep going. + LOG.error("Could not deserialize token info", e); + } + } + if (shouldAdd) { + AuthUtils.setWorkerToken(creds, workerTokenManager.createOrUpdateTokenFor(type, user, topologyId)); --- End diff -- Not necessary, but some info level logs mentioning update to the worker tokens might help.
---