You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Gil Vernik (JIRA)" <ji...@apache.org> on 2015/08/22 17:15:46 UTC

[jira] [Commented] (HADOOP-10420) Add support to Swift-FS to support tempAuth

    [ https://issues.apache.org/jira/browse/HADOOP-10420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14708059#comment-14708059 ] 

Gil Vernik commented on HADOOP-10420:
-------------------------------------

Even this patch is stuck, i still want to share this one:

I just played with this patch again, used Hadoop 2.6.0 and Swift ( the latest version). While trying to access Swift i got 
java.io.EOFException: No content to map to Object due to end of input
        at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775)
        at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
        at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
        at org.apache.hadoop.fs.swift.util.JSONUtil.toObject(JSONUtil.java:85)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient$TempAuthGet.extractResult(SwiftRestClient.jav                     a:1329)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient$TempAuthGet.extractResult(SwiftRestClient.jav                     a:1264)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.perform(SwiftRestClient.java:1557)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.perform(SwiftRestClient.java:1493)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.authenticate(SwiftRestClient.java:1102)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.authIfNeeded(SwiftRestClient.java:1449)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.preRemoteCommand(SwiftRestClient.java:1465)
        at org.apache.hadoop.fs.swift.http.SwiftRestClient.headRequest(SwiftRestClient.java:1036)


The reason for this, is that method public AccessToken extractResult(GetMethod method) throws IOException is written wrong.
It tries to read JSON  body, which can be null or empty.  First thing it should check header and not body, otherwise it will cause an exception.
The "normal" behavior for authentication GET method is to read header, not a body. 

This is the correct code ( just changed order )

      URI finalEndpointURI = null;
      Header storageURL = method.getResponseHeader(HEADER_STORAGE_URL);
      if (storageURL != null) {
        try {
          finalEndpointURI = new URI(storageURL.getValue());
        } catch (URISyntaxException ex) {
          LOG.error("TempAuth received a bad url, " + storageURL.getValue() + ", in the authentication response header.");
          throw new SwiftAuthenticationFailedException(
              "Bad URL " + storageURL.getValue(), "GET", authUri, method);
        }
      }

      
      if (finalEndpointURI == null) {
          final TempAuthStorage storage =
                  JSONUtil.toObject(method.getResponseBodyAsString(),
                      TempAuthAuthenticationWrapper.class).getStorage();
              if (storage != null) {
                String url =
                    usePublicURL ? storage.getPublicURL() : storage.getPrivateURL();
                if (url != null) {
                  try {
                    if (!useEncryption) {
                      url = url.replaceFirst("https:", "http:");
                    }
                    finalEndpointURI = new URI(url);
                  } catch (URISyntaxException ex) {
                    LOG.error("TempAuth received a bad url, " + url + ", in the authentication response body.");
                    throw new SwiftAuthenticationFailedException(
                        "Bad URL " + url, "GET", authUri, method);
                  }
                }
              }
      }


> Add support to Swift-FS to support tempAuth
> -------------------------------------------
>
>                 Key: HADOOP-10420
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10420
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: fs, fs/swift, tools
>    Affects Versions: 2.3.0
>            Reporter: Jinghui Wang
>              Labels: BB2015-05-TBR
>         Attachments: HADOOP-10420-002.patch, HADOOP-10420-003.patch, HADOOP-10420-004.patch, HADOOP-10420-005.patch, HADOOP-10420-006.patch, HADOOP-10420-007.patch, HADOOP-10420-008.patch, HADOOP-10420.patch
>
>
> Currently, hadoop-openstack Swift FS supports keystone authentication. The attached patch adds support for tempAuth. Users will be able to configure which authentication to use.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)