SaketaChalamchala opened a new pull request, #5618:
URL: https://github.com/apache/ozone/pull/5618

   ## What changes were proposed in this pull request?
   Token verification fails for writeChunk operations with NPE when using 
`MiniOzoneClusterImpl#restartHddsDatanode` because secretKeyClient & 
certificate client.
   Used the same method to start the datanode in 
`MiniOzoneClusterImpl#restartHddsDatanode` as 
`MiniOzoneClusterImpl#startHddsDatanodes`
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-9693
   
   ## How was this patch tested?
   
   Tested this as part of the integration test written for 
[HDDS-9657](https://issues.apache.org/jira/browse/HDDS-9657)
   
   ```
   @Test
     public void testCreateRecoveryContainerAfterDNRestart() throws Exception {
      try (XceiverClientManager xceiverClientManager =
                new XceiverClientManager(config)) {
         ECReplicationConfig replicationConfig = new ECReplicationConfig(3, 2);
         Pipeline newPipeline =
             scm.getPipelineManager().createPipeline(replicationConfig);
         scm.getPipelineManager().activatePipeline(newPipeline.getId());
         final ContainerInfo container = scm.getContainerManager()
             .allocateContainer(replicationConfig, "test");
         Token<ContainerTokenIdentifier> cToken = containerTokenGenerator
             .generateToken(ANY_USER, container.containerID());
         scm.getContainerManager().getContainerStateManager()
             .addContainer(container.getProtobuf());
   
         DatanodeDetails targetDN = newPipeline.getNodes().get(0);
         XceiverClientSpi dnClient = xceiverClientManager.acquireClient(
             createSingleNodePipeline(newPipeline, targetDN,
                 2));
         try {
           // To create the actual situation, container would have been in 
closed
           // state at SCM.
           scm.getContainerManager().getContainerStateManager()
               .updateContainerState(container.containerID().getProtobuf(),
                   HddsProtos.LifeCycleEvent.FINALIZE);
           scm.getContainerManager().getContainerStateManager()
               .updateContainerState(container.containerID().getProtobuf(),
                   HddsProtos.LifeCycleEvent.CLOSE);
   
           //Create the recovering container in DN.
           String encodedToken = cToken.encodeToUrlString();
           ContainerProtocolCalls.createRecoveringContainer(dnClient,
               container.containerID().getProtobuf().getId(),
               encodedToken, 4);
   
           // Get containerData
           KeyValueContainerData containerData = (KeyValueContainerData)
               cluster.getHddsDatanode(targetDN)
               .getDatanodeStateMachine()
               .getContainer()
               .getContainerSet()
               .getContainer(container.getContainerID()).getContainerData();
   
           // Restart the DN.
           cluster.restartHddsDatanode(targetDN, true);
   
           // Verify that container state is UNHEALTHY
           
Assert.assertEquals(ContainerProtos.ContainerDataProto.State.UNHEALTHY,
               cluster.getHddsDatanode(targetDN)
                   .getDatanodeStateMachine()
                   .getContainer()
                   .getContainerSet()
                   .getContainer(container.getContainerID())
                   .getContainerState());
   
           // Attempt to write chunk
           BlockID blockID = ContainerTestHelper
               .getTestBlockID(container.containerID().getProtobuf().getId());
           Token<? extends TokenIdentifier> blockToken =
               blockTokenGenerator.generateToken(ANY_USER, blockID,
                   EnumSet.of(READ, WRITE), Long.MAX_VALUE);
           byte[] data = "TestData".getBytes(UTF_8);
           ContainerProtos.ContainerCommandRequestProto writeChunkRequest =
               newWriteChunkRequestBuilder(newPipeline, blockID,
                   ChunkBuffer.wrap(ByteBuffer.wrap(data)), 0)
                   .setEncodedToken(blockToken.encodeToUrlString())
                   .build();
          
           scm.getPipelineManager().activatePipeline(newPipeline.getId());
          
           try{
             dnClient.sendCommand(writeChunkRequest);
           } catch (StorageContainerException e) {
             Assert.assertEquals(CONTAINER_UNHEALTHY, e.getResult());
           }
   ...
   }
   ```
   The test fails with NPE without the suggested fix
   ```
   java.lang.NullPointerException
       at 
org.apache.hadoop.hdds.security.token.ShortLivedTokenVerifier.verifyTokenPassword(ShortLivedTokenVerifier.java:111)
       at 
org.apache.hadoop.hdds.security.token.ShortLivedTokenVerifier.verify(ShortLivedTokenVerifier.java:84)
       at 
org.apache.hadoop.hdds.security.token.CompositeTokenVerifier.verify(CompositeTokenVerifier.java:43)
       at 
org.apache.hadoop.hdds.security.token.TokenVerifier.verify(TokenVerifier.java:71)
       at 
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher.validateToken(HddsDispatcher.java:471)
       at 
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher.dispatchRequest(HddsDispatcher.java:218)
       at 
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher.lambda$dispatch$0(HddsDispatcher.java:179)
       at 
org.apache.hadoop.hdds.server.OzoneProtocolMessageDispatcher.processRequest(OzoneProtocolMessageDispatcher.java:89)
       at 
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher.dispatch(HddsDispatcher.java:178)
       at 
org.apache.hadoop.ozone.container.common.transport.server.GrpcXceiverService$1.onNext(GrpcXceiverService.java:57)
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to