[NETCONF-1174] Leaf-list creation fails on min-element violation Created: 02/Oct/23 Updated: 05/Oct/23 |
|
| Status: | Open |
| Project: | netconf |
| Component/s: | None |
| Affects Version/s: | 7.0.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Medium |
| Reporter: | Peter Suna | Assignee: | Ivan Hrasko |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
Leaf-list resource creation fails due to min-element condition violation, even when the number of leaf-list elements is correct. Steps to reproduce:
module test-container-childs {
namespace "http://example.com/test/container/child";
prefix "tcc";
revision 2023-09-28;
container root-leaf-list-container {
container nested-leaf-list-container {
leaf-list leaf-list-with-min-elements {
min-elements 1;
max-elements 3;
type string;
}
}
}
}
2) Send a request to populate "leaf-list-with-min-elements"
POST URI:
rests/data/network-topology:network-topology/topology=topology-netconf/node=36001-sim-device/yang-ext:mount/test-container-childs:root-leaf-list-container/nested-leaf-list-container
Payload:
{
"leaf-list-with-min-elements": [
"data1",
"data2"
]
}
3) Response from device:
{
"errors": {
"error": [
{
"error-tag": "operation-failed",
"error-info": "TransactionCommitFailedException{message=Netconf transaction commit failed, errorList=[RpcError [message=Netconf transaction commit failed, severity=ERROR, errorType=APPLICATION, tag=operation-failed, applicationTag=null, info=null, cause=NetconfDocumentedException{error-type=APPLICATION, error-tag=operation-failed, error-severity=ERROR, error-info={}, message=RPC during tx failed. Transaction commit failed on TransactionCommitFailedException{message=preCommit execution failed, errorList=[RpcError [message=preCommit execution failed, severity=ERROR, errorType=APPLICATION, tag=operation-failed, applicationTag=null, info=null, cause=org.opendaylight.yangtools.yang.data.tree.impl.MinMaxElementsValidationFailedException: (http://example.com/test/container/child?revision=2023-09-28)leaf-list-with-min-elements does not have enough elements (0), needs at least 1]]} 1 Cause: preCommit execution failed }]]}",
"error-message": "Transaction(POST) not committed correctly",
"error-type": "application"
}
]
}
}
|
| Comments |
| Comment by Peter Suna [ 03/Oct/23 ] |
|
The request for MapNode and LeafSetNode is split into separate RPCs, which are sent one by one to the device. for (var child : ((NormalizedNodeContainer<?>) data).body()) { final var childPath = path.node(child.name()); enqueueOperation(() -> netconfService.create(CONFIGURATION, childPath, child, Optional.empty())); }
Device receive RPC for creating resource for first child: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-23"> <edit-config> <target> <candidate/> </target> <config> <root-leaf-list-container xmlns="http://example.com/test/container/child"> <nested-leaf-list-container> <leaf-list-with-min-elements xmlns:op="urn:ietf:params:xml:ns:netconf:base:1.0" op:operation="create">data2</leaf-list-with-min-elements> </nested-leaf-list-container> </root-leaf-list-container> </config> </edit-config> </rpc> this RPC will fails due to check if data already exist on YangInstanceIdentifier path:
if (rwtx.exists(LogicalDatastoreType.CONFIGURATION, path).get()) {
->
|
| Comment by Ivan Hrasko [ 05/Oct/23 ] |
|
The error can be that, in fact, with POST we are creating nested-leaf-list-container resource. It can be its created "empty" or what by default regardless of payload. Can you try with PUT? PeterSuna |
| Comment by Ivan Hrasko [ 05/Oct/23 ] |
|
The error condition probably happens because the logic tries to ensure all parents exist, so first node created is empty root-leaf-list-container which fails to validate:
|
| Comment by Peter Suna [ 05/Oct/23 ] |
|
PUT creates a 'REPLACE' operation that does not include a check to verify if the data exists. Creating empty "nested-leaf-list-container" container with RPC is also successful because validation check is made after "commit" RPC. |