浏览代码

YARN-8346. Upgrading to 3.1 kills running containers with error 'Opportunistic container queue is full'. Contributed by Jason Lowe.

(cherry picked from commit 4cc0c9b0baa93f5a1c0623eee353874e858a7caa)
Rohith Sharma K S 7 年之前
父节点
当前提交
4711980d77

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/security/ContainerTokenIdentifier.java

@@ -216,7 +216,7 @@ public class ContainerTokenIdentifier extends TokenIdentifier {
    */
    */
   public ContainerType getContainerType(){
   public ContainerType getContainerType(){
     if (!proto.hasContainerType()) {
     if (!proto.hasContainerType()) {
-      return null;
+      return ContainerType.TASK;
     }
     }
     return convertFromProtoFormat(proto.getContainerType());
     return convertFromProtoFormat(proto.getContainerType());
   }
   }
@@ -227,7 +227,7 @@ public class ContainerTokenIdentifier extends TokenIdentifier {
    */
    */
   public ExecutionType getExecutionType(){
   public ExecutionType getExecutionType(){
     if (!proto.hasExecutionType()) {
     if (!proto.hasExecutionType()) {
-      return null;
+      return ExecutionType.GUARANTEED;
     }
     }
     return convertFromProtoFormat(proto.getExecutionType());
     return convertFromProtoFormat(proto.getExecutionType());
   }
   }

+ 25 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java

@@ -35,6 +35,7 @@ import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
+import org.apache.hadoop.yarn.proto.YarnSecurityTokenProtos.ContainerTokenIdentifierProto;
 import org.apache.hadoop.yarn.proto.YarnSecurityTokenProtos.YARNDelegationTokenIdentifierProto;
 import org.apache.hadoop.yarn.proto.YarnSecurityTokenProtos.YARNDelegationTokenIdentifierProto;
 import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
@@ -138,6 +139,30 @@ public class TestYARNTokenIdentifier {
         anotherToken.getClientName(), clientName);
         anotherToken.getClientName(), clientName);
   }
   }
   
   
+  @Test
+  public void testContainerTokenIdentifierProtoMissingFields()
+      throws IOException {
+    ContainerTokenIdentifierProto.Builder builder =
+        ContainerTokenIdentifierProto.newBuilder();
+    ContainerTokenIdentifierProto proto = builder.build();
+    Assert.assertFalse(proto.hasContainerType());
+    Assert.assertFalse(proto.hasExecutionType());
+    Assert.assertFalse(proto.hasNodeLabelExpression());
+
+    byte[] tokenData = proto.toByteArray();
+    DataInputBuffer dib = new DataInputBuffer();
+    dib.reset(tokenData, tokenData.length);
+    ContainerTokenIdentifier tid = new ContainerTokenIdentifier();
+    tid.readFields(dib);
+
+    Assert.assertEquals("container type",
+        ContainerType.TASK, tid.getContainerType());
+    Assert.assertEquals("execution type",
+        ExecutionType.GUARANTEED, tid.getExecutionType());
+    Assert.assertEquals("node label expression",
+        CommonNodeLabelsManager.NO_LABEL, tid.getNodeLabelExpression());
+  }
+
   @Test
   @Test
   public void testContainerTokenIdentifier() throws IOException {
   public void testContainerTokenIdentifier() throws IOException {
     ContainerId containerID = ContainerId.newContainerId(
     ContainerId containerID = ContainerId.newContainerId(