hadoop - Determining the current Kerberos user in an Apache Spark job -
i'm running spark jobs on kerberos-enabled cluster (cloudera), , able log kerberos identity of user, given run of job.
(note not identity of local linux user launches job, because use keytab files, jaas.conf files, , call kinit in launch script. can log identity in launch script, since know principal passed kinit along keytab, nice able log within actual spark job itself, if job launched manually, reliably know identity ran under).
some answers suggest following:
import java.security.{accesscontroller,principal} import javax.security.auth.subject val acc = accesscontroller.getcontext val sub = subject.getsubject(acc) val principals = sub.getprincipals but returned sub null, not work.
you need @ usergroupinformation class.
to logged-in user, can use:
import org.apache.hadoop.security.usergroupinformation val user = usergroupinformation.getloginuser res6: org.apache.hadoop.security.usergroupinformation = user@realm (auth:kerberos) wiki
Comments
Post a Comment