[NETCONF-1158] RestconfSchemaService returns 500 for device model Created: 19/Sep/23  Updated: 12/Oct/23

Status: Open
Project: netconf
Component/s: restconf-nb
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: pick-next, pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

When sending a GET request to the test-tool device with, for example, the 'toaster2' model, it responds with a 500 error when asked for the 'Accept: application/yang' header.

http://192.168.56.100:8181/rests/modules/network-topology:network-topology/topology=topology-netconf/node=36001-sim-device/yang-ext:mount/toaster2/2009-11-20

The same request but with "Accept: application/yin+xml" header is working.

  • Sending application/yang headers is working for controller models.
  • In Karaf logs, there are no errors.
  • Creating SchemaExportContext is successful for the device model. The exception is thrown in YangSchemaExportBodyWriter with the message:  "Unable to retrieve source from SourceProvider."
0 = {StackTraceElement@25842} "org.opendaylight.restconf.nb.rfc8040.jersey.providers.YangSchemaExportBodyWriter.writeTo(YangSchemaExportBodyWriter.java:42)"
1 = {StackTraceElement@25843} "org.opendaylight.restconf.nb.rfc8040.jersey.providers.YangSchemaExportBodyWriter.writeTo(YangSchemaExportBodyWriter.java:28)"
2 = {StackTraceElement@25844} "org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:242)"
3 = {StackTraceElement@25845} "org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)"
4 = {StackTraceElement@25846} "org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)"
5 = {StackTraceElement@25847} "org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)"

The issue arises from the invocation of context.sourceProvider() within the YangSchemaExportBodyWriter class. This DOMYangTextSourceProvider contains controller models. Probably it will be required to explore alternative methods for generating the YangTextSchemaSource. For example, as it is done in 
YinSchemaExportBodyWriter.



 Comments   
Comment by Peter Suna [ 11/Oct/23 ]

The issue here is that we are using `DOMYangTextSourceProvider` from the controller instead of from the device in ParseIdentifier#toSchemaExportContextFromIdentifier()

To obtain the `DOMYangTextSourceProvider` for the device, we need to retrieve it from the device service, which is currently empty due to missing SchemaSourceProvider in the DOMSchemaService.

final Optional<DOMSchemaService> service = point.getMountPoint().getService(DOMSchemaService.class);
service.get().getExtensions().getInstance(DOMYangTextSourceProvider.class); 

When the DOMMountPoint is prepared, DOMSchemaService is created without SchemaSourceProvider.

mountBuilder.addService(DOMSchemaService.class, FixedDOMSchemaService.of(() -> initialCtx)); 

Device SchemaSourceProvider can be obtained from DeviceSources created here.

 

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