YARN-11616. Fast fail for NodeConstraintParser when having multi attribute kvs (#6282)
This commit is contained in:
parent
f1e4376626
commit
88e760bfc8
@ -406,6 +406,10 @@ public AbstractConstraint parse()
|
||||
// multiple values are present for same attribute, it will also be
|
||||
// coming as next token. for example, java=1.8,1.9 or python!=2.
|
||||
if (attributeKV.countTokens() > 1) {
|
||||
if (!constraintEntities.isEmpty()) {
|
||||
throw new PlacementConstraintParseException(
|
||||
"expecting valid expression like k=v or k!=v or k=v1,v2");
|
||||
}
|
||||
opCode = getAttributeOpCode(currentTag);
|
||||
attributeName = attributeKV.nextToken();
|
||||
currentTag = attributeKV.nextToken();
|
||||
|
@ -570,6 +570,18 @@ void testParseNodeAttributeSpec()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseIllegalExprShouldThrowException() {
|
||||
// A single node attribute constraint w/o source tags, it should fail when multiple
|
||||
// attribute kvs are specified.
|
||||
try {
|
||||
PlacementConstraintParser.parseExpression("rm.yarn.io/foo=true,rm.yarn.io/bar=true");
|
||||
fail("Expected a failure!");
|
||||
} catch (PlacementConstraintParseException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParseAllocationTagNameSpace()
|
||||
throws PlacementConstraintParseException {
|
||||
|
Loading…
Reference in New Issue
Block a user