You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/01/05 13:57:00 UTC

[jira] [Commented] (NIFI-4741) ReportLineageToAtlas stops working after expiration of DelegationToken

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

ASF GitHub Bot commented on NIFI-4741:
--------------------------------------

GitHub user ijokarumawak opened a pull request:

    https://github.com/apache/nifi/pull/2377

    NIFI-4741: Avoid DelegationToken expiration at ReportLineageToAtlas

    The reporting task used to hold a single AtlasClientV2 instance
    throughout its runtime starting from being started until being stopped.
    If it is configured to use Kerberos authentication for Atlas REST API, after
    a published DelegationToken expires (10 hours by default), the reporting
    task will not be able to recover from 401 Unauthorized state.
    
    In order to avoid stucking in such situation, this commit changes the
    way ReportLineageToAtlas uses AtlasClientV2 instance to create an
    instance per onTrigger execution. It also addresses Kerberos ticket
    expiration.
    
    This approach incurs some overheads by initiating the client each time,
    however, it should be insignificant from an overall processing time
    perspective including analyzing NiFi flow and Provenance records.
    
    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [x] Have you written or updated unit tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ijokarumawak/nifi nifi-4741

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2377.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2377
    
----
commit 8776904697adf714a2dbc1db0fb8788afa112fb9
Author: Koji Kawamura <ij...@...>
Date:   2018-01-05T10:23:28Z

    NIFI-4741: Avoid DelegationToken expiration at ReportLineageToAtlas
    
    The reporting task used to hold a single AtlasClientV2 instance
    throughout its runtime starting from being started until being stopped.
    If it is configured to use Kerberos authentication for Atlas REST API, after
    a published DelegationToken expires (10 hours by default), the reporting
    task will not be able to recover from 401 Unauthorized state.
    
    In order to avoid stucking in such situation, this commit changes the
    way ReportLineageToAtlas uses AtlasClientV2 instance to create an
    instance per onTrigger execution. It also addresses Kerberos ticket
    expiration.
    
    This approach incurs some overheads by initiating the client each time,
    however, it should be insignificant from an overall processing time
    perspective including analyzing NiFi flow and Provenance records.

----


> ReportLineageToAtlas stops working after expiration of DelegationToken
> ----------------------------------------------------------------------
>
>                 Key: NIFI-4741
>                 URL: https://issues.apache.org/jira/browse/NIFI-4741
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Koji Kawamura
>            Assignee: Koji Kawamura
>
> While I was testing if NiFi Atlas integration implementation regarding to Kerberos authentication has to be updated based on the findings with NIFI-4323, I encountered different type of issue with Atlas REST API and Kerberos authentication.
> If my understanding is correct, Atlas REST API Kerberos authentication works as follows:
> # Atlas Client application logs in locally by using specified user principal and its keytab, (or this can be done with ticket cache)
> # Atlas Client sends a HTTP request with a DelegationToken. At the 1st request, this token is null.
> # Atlas Server receives a HTTP request, if token is not set, it will respond with 401, and ask the client to negotiate.
> # Atlas Client serializes current UserGroupInformation credential in base64 encoding then send it to Atlas Server.
> # Atlas Server verifies the base64 representation of the user credential, if it's valid, publish a DelegationToken. Returns it as set cookie.
> # Atlas Client uses the returned DelegationToken with subsequent requests.
> At point 5 above, the newly created DelegationToken has 10h expiration by default. DelegationToken expiration is different from Kerberos login lifetime. So a use-case using Atlas client with Kerberos has to handle two expiration cases.
> Currently, it seems Atlas client does not handle DelegationToken expiration automatically. After passing the DeligationToken validity period, Atlas server returns [401 Unauthorized response|https://github.com/apache/atlas/blob/master/webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java#L606], and Atlas client used by NiFi reporting task keeps showing following error:
> {code}
> Metadata service API org.apache.atlas.AtlasBaseClient$APIInfo@6604f000 failed with status 401 (Unauthorized) Response Body (<html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 401 AuthenticationToken expired</title>
> </head>
> <body><h2>HTTP ERROR 401</h2>
> <p>Problem accessing /api/atlas/v2/entity/uniqueAttribute/type/nifi_flow. Reason:
> <pre>    AuthenticationToken expired</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                                
> <br/>
> {code}
> NiFi ReportLineageToAtlas reporting task should handle the DelegationToken expiration situation correctly. And also it needs to renew Kerberos ticket.
> A simple solution to address both expirations is initializing AtlasClientV2 instance at every onTrigger execution. Current implementation keeps using the same AtlasClientV2 instance.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)