Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F06D6200C44 for ; Mon, 27 Mar 2017 13:16:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF058160B85; Mon, 27 Mar 2017 11:16:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1A188160B5D for ; Mon, 27 Mar 2017 13:16:53 +0200 (CEST) Received: (qmail 57389 invoked by uid 500); 27 Mar 2017 11:16:53 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 57378 invoked by uid 99); 27 Mar 2017 11:16:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Mar 2017 11:16:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id B95B81A0072 for ; Mon, 27 Mar 2017 11:16:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id GUwO6UanErPj for ; Mon, 27 Mar 2017 11:16:51 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 1296A5FB30 for ; Mon, 27 Mar 2017 11:16:51 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 676D1E0901 for ; Mon, 27 Mar 2017 11:16:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id B67302406A for ; Mon, 27 Mar 2017 11:16:41 +0000 (UTC) Date: Mon, 27 Mar 2017 11:16:41 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HADOOP-14237) S3A Support Shared Instance Profile Credentials Across All Hadoop Nodes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 27 Mar 2017 11:16:55 -0000 [ https://issues.apache.org/jira/browse/HADOOP-14237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15943066#comment-15943066 ] ASF GitHub Bot commented on HADOOP-14237: ----------------------------------------- Github user steveloughran commented on a diff in the pull request: https://github.com/apache/hadoop/pull/207#discussion_r108144389 --- Diff: hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/SharedInstanceProfileCredentialsProvider.java --- @@ -58,6 +71,84 @@ public static SharedInstanceProfileCredentialsProvider getInstance() { return INSTANCE; } + private AWSCredentials readCredentialsFromHDFS() { + try { + FileSystem fs = FileSystem.get(new Configuration()); + BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(s3crednetialPath))); + String accessKey = br.readLine(); + String secretKey = br.readLine(); + String token = br.readLine(); + AWSCredentials credentials; + if (StringUtils.isEmpty(accessKey) || StringUtils.isEmpty(secretKey)) { + // if there are no accessKey nor secretKey return null + return null; + } else if (StringUtils.isNotEmpty(token)) { + credentials = new BasicSessionCredentials(accessKey, secretKey, token); + } else { + credentials = new BasicAWSCredentials(accessKey, secretKey); + } + return credentials; + } catch (Exception e) { + return null; // ignore the read errors + // throw new AmazonServiceException("Failed reading S3 credentials from HDFS " + e.getStackTrace()); + } + } + + private void writeCredentialsToHDFS(AWSCredentials credentials) { + try { + // Simulate atomic write by creating a new s3credential file with random string suffix and rename to s3crednetialPath + Path newS3crednetialPath = new Path(s3crednetialPath.toUri() + RandomStringUtils.randomAlphanumeric(8)); + FileSystem fs = FileSystem.get(new Configuration()); + BufferedWriter br = new BufferedWriter(new OutputStreamWriter(fs.create(newS3crednetialPath, true))); + String accessKey = credentials.getAWSAccessKeyId(); + String secretKey = credentials.getAWSSecretKey(); + String token = ""; + if (credentials instanceof BasicSessionCredentials) { + token = ((BasicSessionCredentials) credentials).getSessionToken(); + } + br.write(accessKey); + br.newLine(); + br.write(secretKey); + br.newLine(); + br.write(token); + br.newLine(); + br.close(); + fs.delete(s3crednetialPath, false); + fs.rename(newS3crednetialPath, s3crednetialPath); + } catch (Exception e) { + // ignore write errors + // throw new AmazonServiceException("Failed writing S3 credentials from HDFS " + e.getStackTrace()); + } + } + + @Override + public AWSCredentials getCredentials() { + for (int retry = 0; retry < maxRetries; retry++) { + try { + AWSCredentials newCredentials = super.getCredentials(); + // if this new credentials is different from HDFS write back + if (credentials == null || (!newCredentials.getAWSSecretKey().equals(credentials.getAWSSecretKey()))) { + credentials = newCredentials; + writeCredentialsToHDFS(credentials); + } + break; + } catch (Exception e) { --- End diff -- I't use our normal Retry logic here, consider some sleep + jitter if it really is caused by throttling > S3A Support Shared Instance Profile Credentials Across All Hadoop Nodes > ----------------------------------------------------------------------- > > Key: HADOOP-14237 > URL: https://issues.apache.org/jira/browse/HADOOP-14237 > Project: Hadoop Common > Issue Type: Bug > Components: fs/s3 > Affects Versions: 2.8.0, 3.0.0-alpha1, 3.0.0-alpha2, 2.8.1 > Environment: EC2, AWS > Reporter: Kazuyuki Tanimura > > When I run a large Hadoop cluster on EC2 instances with IAM Role, it fails getting the instance profile credentials, eventually all jobs on the cluster fail. Since a number of S3A clients (all mappers and reducers) try to get the credentials, the AWS credential endpoint starts responding 5xx and 4xx error codes. > SharedInstanceProfileCredentialsProvider.java is sort of trying to solve it, but it still does not share the credentials with other EC2 nodes / JVM processes. > This issue prevents users from creating Hadoop clusters on EC2 -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org