[NETCONF-31] Improve error reporting when controller-config mount operation fails Created: 19/Jun/15  Updated: 15/Mar/19  Resolved: 24/Nov/15

Status: Resolved
Project: netconf
Component/s: netconf
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tom Pantelis Assignee: Tom Pantelis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 3822
Priority: High

 Description   

After a new netconf connector config is POSTED, you can't update it via restconf (nor DELETE or GET). With POST you get "data already exists", which makes sense since POST is create-if-not-exists (although this erroneously worked in Helium).

PUT with, eg, the following URL:

http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/new-netconf-device

should work but fails with error:

"odl-sal-netconf-connector-cfg:sal-netconf-connector from URI can't be resolved. For key which is of type identityref it should be in format module_name:identity_name."

Clearly "odl-sal-netconf-connector-cfg:sal-netconf-connector" is in the correct format.

The problem is in RestCodec.ObjectCodec#deserialize:

if (type instanceof IdentityrefTypeDefinition) {
if (input instanceof IdentityValuesDTO)

{ return identityrefCodec.deserialize(maybeIdentityref); }

logger.debug("Value is not instance of IdentityrefTypeDefinition but is {}. Therefore NULL is used as translation of - {}",
input == null ? "null" : input.getClass(), String.valueOf(input));
return null;
}

It expects the 'input' value to be of type IdentityValuesDTO but it's a String. In fact the calling code in ControllerContext#addKeyValue specifically treats the value as a String. So there's a disconnect between ControllerContext and RestCodec.ObjectCodec. I'm not sure what the intent is here, ie who is supposed to parse the identityref string into an IdentityValuesDTO instance.

I locally changed ObjectCodec#deserialize to check for instanceof String and parse into an IdentityValuesDTO. This fixed the problem.

Note: with this bug no config module can be updated via restconf, including OOB ones.



 Comments   
Comment by Tom Pantelis [ 19/Jun/15 ]

This might be a Lithium blocker.

Comment by Tom Pantelis [ 19/Jun/15 ]

OK - now I'm confused. I realized there's another code path in ControllerContext#addKeyValue to handle identityrefs:

Object decoded = codec.deserialize(urlDecoded);
String additionalInfo = "";
if (decoded == null) {
if ((baseType instanceof IdentityrefTypeDefinition))

{ decoded = toQName(urlDecoded); additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name."; }

}

So it simply parses the QName from the colon-separated string which is basically what I did in my changes.

I removed my changes and now this code path works. I don't know why I was getting the error before.

However, if you do a PUT with partial payload as outlined in https://wiki.opendaylight.org/view/OpenDaylight_Controller:Config:Examples:Netconf, it fails with 500 code but no error output or exception.

Comment by Tom Pantelis [ 19/Jun/15 ]

Actually there is an error:

2015-06-19 07:11:40,424 | WARN | entLoopGroup-2-2 | ConfigTransactionControllerImpl | 333 | 189 - org.opendaylight.controller.config-manager - 0.3.0.SNAPSHOT | | Validation exception in ConfigTransaction-44-67
org.opendaylight.controller.config.api.JmxAttributeValidationException: DomRegistry is null, expected dependency implementing interface org.opendaylight.controller.config.yang.md.sal.dom.BrokerServiceInterface
at org.opendaylight.controller.config.api.JmxAttributeValidationException.checkNotNull(JmxAttributeValidationException.java:65)
at org.opendaylight.controller.config.manager.impl.dependencyresolver.DependencyResolverImpl.validateDependency(DependencyResolverImpl.java:91)
at org.opendaylight.controller.config.yang.md.sal.connector.netconf.AbstractNetconfConnectorModule.validate(AbstractNetconfConnectorModule.java:87)
at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_45]
at org.opendaylight.controller.config.manager.impl.dependencyresolver.DependencyResolverManager$ModuleInvocationHandler.handleInvocation(DependencyResolverManager.java:150)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
at com.sun.proxy.$Proxy74.validate(Unknown Source)
at org.opendaylight.controller.config.manager.impl.ConfigTransactionControllerImpl.validateNoLocks(ConfigTransactionControllerImpl.java:331)
at org.opendaylight.controller.config.manager.impl.ConfigTransactionControllerImpl.validateConfig(ConfigTransactionControllerImpl.java:315)

Since PUT is a replace, you need to specify the entire config.

Comment by Tom Pantelis [ 20/Jun/15 ]

I'm going to use this bug improve the error reporting to the user. We should emit error info with the 500 response.

Comment by Robert Varga [ 13/Nov/15 ]

Move to NETCONF project

Comment by Tomas Cere [ 24/Nov/15 ]

https://git.opendaylight.org/gerrit/#/c/27050/

https://git.opendaylight.org/gerrit/#/c/23043/

Generated at Wed Feb 07 20:13:59 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.