openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
286 stars 107 forks source link

How to set LeafrefOptions IgnoreMissingData for UnmarshalSetRequest #975

Closed dliu2223 closed 4 months ago

dliu2223 commented 5 months ago

During schema initialization using gnmi.SetRequest, leafref validation failed because only partial data was initialized. But UnmarshalSetRequest does not support LeafrefOptions, please advise. Thanks

David

robshakir commented 5 months ago

Hi David,

Just to understand what happened here -- can you provide an example?

Today, I don't think that any unmarshalling calls Validate which would be what checks leafref options -- so understanding what validation error occurred would be useful.

Thanks, r.

dliu2223 commented 4 months ago

Hi Rob,

The error from ytypes.UnmarshalSetRequest() was Noncompliance errors: setNode: rpc error: code = Unknown desc = failed to update struct *schema.OpenconfigOperatorNetwork_OperatorNetworks_OperatorNetwork_Networks_Network_Nodes_Node_Openconfig_Lldp with value json_ietf_val:"{......}"; schema node interfaces is nil for leafref schema name with path /oc-if:interfaces/oc-if:interface/oc-if:name

we figured out the issue was due to schema generation option exclude_modules included openconfig-interfaces, which we copied from the exclude_modules from our proto_generator script to reduce the top level message interfaces, (i.e., the message Interfaces is already generated under the root OperatorNetworks).

Our use case is building a network level schema by adapting ietf modules (e.g., network, network-slice,...) to openconfig YANG 1.0 and uses the openconfig modules as the network node schema. So that we can take advantage of the openconfig ygot, ytypes... tool chains. Node supports mixed schema from openconfig, ietf, and legacy TL1 to support various network elements, the schema is getting large and that was the reason we were trying to use the exclude_modules to reduce the size. Right now, we only exclude modules when generator.go complains about overlapping root children.

If you have suggestion on the use of exclude_modules, please advise. Thanks

David