[NETCONF-568] NetconfMessageTransformer action/rpc empty reply Created: 18/Sep/18 Updated: 03/Mar/20 Resolved: 03/Mar/20 |
|
| Status: | Resolved |
| Project: | netconf |
| Component/s: | None |
| Affects Version/s: | Fluorine |
| Fix Version/s: | Magnesium, Aluminium, Sodium SR3 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Anna Bencúrová | Assignee: | Sanjana Babu |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
If the action has output which has not mandatory fields and none of them is present, the NetconfMessageTransformer reports error. I found this problem to be present also for both the RPCs and actions. Example: Let's say we have two RPCs. One with output defined, but with non mandatory field and the second without output:
rpc rpc-with-output {
output {
leaf not-mandatory-message {
type string;
}
}
}
rpc rpc-without-output {
}
Regarding the Yang 1.1 RFC https://tools.ietf.org/html/rfc7950#section-7.14.4 there should be a possibility to return only "ok" message, when no output parameters are returned:
So for both should be fine to get response:
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>
But for the RPC with output defined "rpc-with-output" the NetconfMessageTransformer fails with error. |
| Comments |
| Comment by Jakub Morvay [ 01/Oct/18 ] |
|
apuchyova although the description is really kind of self-explanatory it would be better to actually see the the error. Also it seems like you played around with action support in netconf SB, so I believe you have some models and data connected to this issue. It would be really cool if you can attach them here so the reproduction will be easier. |
| Comment by Robert Varga [ 08/Jan/20 ] |
|
Based on the proposed unit test: [ERROR] Tests run: 27, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.387 s <<< FAILURE! - in org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformerTest
[ERROR] testRpcEmptyBodyWithOutputDefinedSchemaResult(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformerTest) Time elapsed: 0.011 s <<< ERROR!
java.lang.IllegalArgumentException: Failed to parse RPC response [rpc-reply: null]
at org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer.parseResult(NetconfMessageTransformer.java:329)
at org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer.toRpcResult(NetconfMessageTransformer.java:294)
at org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformerTest.testRpcEmptyBodyWithOutputDefinedSchemaResult(NetconfMessageTransformerTest.java:240)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[...]
Caused by: javax.xml.stream.XMLStreamException: Schema for node with name ok and namespace urn:ietf:params:xml:ns:netconf:base:1.0 does not exist at AbsoluteSchemaPath{path=[(urn:example:rpcs-actions-outputs)rpc-with-output, (urn:example:rpcs-actions-outputs)output]}
at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.read(XmlParserStream.java:522)
at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.parse(XmlParserStream.java:270)
at org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream.traverse(XmlParserStream.java:297)
at org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer.parseResult(NetconfMessageTransformer.java:326)
... 30 more
|
| Comment by Robert Varga [ 08/Jan/20 ] |
|
Which means XML parser was asked to parse </ok> as a child, which means we are parsing a NETCONF concept in Yangtools – which is wrong. From the parser perspective, we an option of injecting proper parsing here, given that we have mechanics for dealing with RFC8258 mounts. From yang-data-codec-xml perspective whether it is a mount point node or NETCONF XML node are completely indiscernible: both are something that occurs under a DataNodeContainer and it has a QName. Hence the correct fix is make pretend that module netconf-internal {
// Conflicts with ietf-netconf
namespace "urn:ietf:params:xml:ns:netconf:base:1.0"
container ok {
presence "Indicates a no-response explicit acknowledgement";
}
}
is implicitly schema-mounted into the <rpc-reply> SchemaNode. So the mechanics goes:
|
| Comment by Robert Varga [ 08/Jan/20 ] |
|
... or this actually is a bug <rpc-reply> contains either <data> or <ok>, hence that part should be handled by NETCONF, not by yang-data-codec-xml – unless I am missing something. |
| Comment by Sanjana Babu [ 27/Jan/20 ] |
|
NetconfMessageTransformer.java throws error when it is trying to parse the <ok/> as a child in schema node. This is because when the rpc has output parameters i.e, child nodes, xmlparser tries to parse them. So, I'm planning the fix is if dont send the <ok/> of the <rpc-reply> to xmlparser, it wont parse the <ok/> as a child node. Xmlparser will try to find the output parameters else it treat the non mandatory nodes as transient nodes. I have validated this fix and it works fine. |