[KYUUBI #3888] [HA] Add more info to log when zk auth keytab not found
### _Why are the changes needed?_ Add more info to log, when zookeeper auth keytab not fount. ### _How was this patch tested?_ - [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #3888 from zwangsheng/improve/zk_keytab_not_found. Closes #3888 e12f4cf1 [zwangsheng] add more info in log Authored-by: zwangsheng <2213335496@qq.com> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
4b74129372
commit
9bbccb25d0
@ -22,6 +22,7 @@ import javax.security.auth.login.Configuration
|
||||
|
||||
import scala.util.Random
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting
|
||||
import org.apache.curator.framework.{CuratorFramework, CuratorFrameworkFactory}
|
||||
import org.apache.curator.retry._
|
||||
import org.apache.hadoop.security.UserGroupInformation
|
||||
@ -30,8 +31,7 @@ import org.apache.hadoop.security.token.delegation.ZKDelegationTokenSecretManage
|
||||
import org.apache.kyuubi.Logging
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.ha.HighAvailabilityConf._
|
||||
import org.apache.kyuubi.ha.client.AuthTypes
|
||||
import org.apache.kyuubi.ha.client.RetryPolicies
|
||||
import org.apache.kyuubi.ha.client.{AuthTypes, RetryPolicies}
|
||||
import org.apache.kyuubi.ha.client.RetryPolicies._
|
||||
import org.apache.kyuubi.util.KyuubiHadoopUtils
|
||||
|
||||
@ -109,7 +109,7 @@ object ZookeeperClientProvider extends Logging {
|
||||
val kerberized = maybePrincipal.isDefined && keyTabFile.isDefined
|
||||
if (UserGroupInformation.isSecurityEnabled && kerberized) {
|
||||
if (!new File(keyTabFile.get).exists()) {
|
||||
throw new IOException(s"${HA_ZK_AUTH_KEYTAB.key} does not exists")
|
||||
throw new IOException(s"${HA_ZK_AUTH_KEYTAB.key}: $keyTabFile does not exists")
|
||||
}
|
||||
System.setProperty("zookeeper.sasl.clientconfig", "KyuubiZooKeeperClient")
|
||||
var principal = maybePrincipal.get
|
||||
@ -129,7 +129,8 @@ object ZookeeperClientProvider extends Logging {
|
||||
|
||||
}
|
||||
|
||||
private def getKeyTabFile(conf: KyuubiConf): Option[String] = {
|
||||
@VisibleForTesting
|
||||
def getKeyTabFile(conf: KyuubiConf): Option[String] = {
|
||||
val zkAuthKeytab = conf.get(HA_ZK_AUTH_KEYTAB)
|
||||
if (zkAuthKeytab.isDefined) {
|
||||
val zkAuthKeytabPath = zkAuthKeytab.get
|
||||
|
||||
@ -130,7 +130,8 @@ abstract class ZookeeperDiscoveryClientSuite extends DiscoveryClientTests
|
||||
|
||||
conf.set(HA_ZK_AUTH_KEYTAB.key, s"${keytab.getName}")
|
||||
val e = intercept[IOException](ZookeeperClientProvider.setUpZooKeeperAuth(conf))
|
||||
assert(e.getMessage === s"${HA_ZK_AUTH_KEYTAB.key} does not exists")
|
||||
assert(e.getMessage ===
|
||||
s"${HA_ZK_AUTH_KEYTAB.key}: ${ZookeeperClientProvider.getKeyTabFile(conf)} does not exists")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user