Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DC086DB33 for ; Wed, 26 Sep 2012 21:27:39 +0000 (UTC) Received: (qmail 44437 invoked by uid 500); 26 Sep 2012 21:27:39 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 44399 invoked by uid 500); 26 Sep 2012 21:27:39 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 44385 invoked by uid 99); 26 Sep 2012 21:27:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Sep 2012 21:27:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Sep 2012 21:27:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 91BC423889ED; Wed, 26 Sep 2012 21:26:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1390730 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Date: Wed, 26 Sep 2012 21:26:55 -0000 To: hdfs-commits@hadoop.apache.org From: eli@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120926212655.91BC423889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eli Date: Wed Sep 26 21:26:54 2012 New Revision: 1390730 URL: http://svn.apache.org/viewvc?rev=1390730&view=rev Log: HDFS-3972. Trash emptier fails in secure HA cluster. Contributed by Todd Lipcon Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1390730&r1=1390729&r2=1390730&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Wed Sep 26 21:26:54 2012 @@ -631,6 +631,8 @@ Release 2.0.2-alpha - 2012-09-07 HDFS-3938. remove current limitations from HttpFS docs. (tucu) HDFS-3944. Httpfs resolveAuthority() is not resolving host correctly. (tucu) + + HDFS-3972. Trash emptier fails in secure HA cluster. (todd via eli) BREAKDOWN OF HDFS-3042 SUBTASKS Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=1390730&r1=1390729&r2=1390730&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java Wed Sep 26 21:26:54 2012 @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.InetSocketAddress; import java.net.URI; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -512,7 +513,7 @@ public class NameNode { stopHttpServer(); } - private void startTrashEmptier(Configuration conf) throws IOException { + private void startTrashEmptier(final Configuration conf) throws IOException { long trashInterval = conf.getLong(FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT); if (trashInterval == 0) { @@ -521,7 +522,18 @@ public class NameNode { throw new IOException("Cannot start tresh emptier with negative interval." + " Set " + FS_TRASH_INTERVAL_KEY + " to a positive value."); } - this.emptier = new Thread(new Trash(conf).getEmptier(), "Trash Emptier"); + + // This may be called from the transitionToActive code path, in which + // case the current user is the administrator, not the NN. The trash + // emptier needs to run as the NN. See HDFS-3972. + FileSystem fs = SecurityUtil.doAsLoginUser( + new PrivilegedExceptionAction() { + @Override + public FileSystem run() throws IOException { + return FileSystem.get(conf); + } + }); + this.emptier = new Thread(new Trash(fs, conf).getEmptier(), "Trash Emptier"); this.emptier.setDaemon(true); this.emptier.start(); }