[YANGTOOLS-276] SFc Project broken due to recent controller/yangtools commit Created: 22/Aug/14  Updated: 10/Apr/22  Resolved: 25/Aug/14

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

Type: Bug
Reporter: Reinaldo Penno Assignee: Tony Tkacik
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: PC


External issue ID: 1604
Priority: Highest

 Description   

The scenario is a complete overwrite of a datastore element. During OndataChanged() I spawn an executor to overwrite the data that triggered onDataChanged() itself.

Meaning, an element with a certain key already exists and I'm overwriting it with new values.

This has always worked until 24hrs ago.

On 8/22/14 9:54 AM, Reinaldo Penno wrote:
> Hi,
>
> I think a controller/Yangtools commit broke SFC project in the last 24 hrs.
>
> Something that always worked until the last 24 hrs, stopped working. Basically this operation
>
> writeTx.put(LogicalDatastoreType.CONFIGURATION,
> sfpIID, newServiceFunctionPath, true);
>
>
> Now gives me:
>
> at com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
> at org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter.startOrderedMapNode(ImmutableNormalizedNodeStreamWriter.java:188)
> at org.opendaylight.yangtools.binding.data.codec.impl.BindingToNormalizedStreamWriter.startOrderedMapNode(BindingToNormalizedStreamWriter.java:173)
> at org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath$StreamWriter.serialize(DataObjectSerializerPrototype.java)
> at org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry$DataObjectSerializerProxy.serialize(BindingNormalizedNodeCodecRegistry.java:180)
> at org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry.toNormalizedNode(BindingNormalizedNodeCodecRegistry.java:91)
> at org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec.toNormalizedNode(BindingToNormalizedNodeCodec.java:54)
> at org.opendaylight.controller.md.sal.binding.impl.AbstractWriteTransaction.put(AbstractWriteTransaction.java:46)
> at org.opendaylight.sfc.provider.SfcProviderServicePathAPI.createServiceFunctionPathEntry(SfcProviderServicePathAPI.java:317)
> ... 8 more
>
>

What I noticed is that in OnDataChanged() instead of getting an actual object (as I used to) I'm getting a LazyDataObject and the data is Immutable.

h =

{org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject@12331}

cachedData =

{java.util.concurrent.ConcurrentHashMap@12332}

size = 5
data =

{org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder$ImmutableMapEntryNode@12333}

"ImmutableMapEntryNode{nodeIdentifier=(urn:cisco:params:xml:ns:yang:sfc-sfp?revision=2014-07-01)service-function-path[

{(urn:cisco:params:xml:ns:yang:sfc-sfp?revision=2014-07-01)name=Path-2-SFC1}

], value=[ImmutableLeafNode{nodeIdentifier=(urn:cisco:params:...
context =

{org.opendaylight.yangtools.binding.data.codec.impl.ListNodeCodecContext@11961}

"ListNodeCodecContext [interface org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath]"
cachedAugmentations =

{com.google.common.collect.EmptyImmutableBiMap@11962}

size = 0
cachedHashcode = null

> The scenario is a complete overwrite of a datastore element. Meaning, an element with a certain key already exists and I'm overwriting it with new values.
>
> Anybody knows what this could be?



 Comments   
Comment by Reinaldo Penno [ 22/Aug/14 ]

WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION,
sfpIID, newServiceFunctionPath, true);

Comment by Reinaldo Penno [ 23/Aug/14 ]

The test below is against "ImmutableOrderedMapNodeBuilder" but getcurrent returns "ImmutableMapEntryNodeBuilder".

The corresponding Yang model uses ordered-by user.

@Override
public void startOrderedMapNode(final NodeIdentifier name,final int childSizeHint) throws IllegalArgumentException {
if(!(getCurrent() instanceof NormalizedNodeResultBuilder))

{ Preconditions.checkArgument(getCurrent() instanceof ImmutableOrderedMapNodeBuilder); }

enter(Builders.mapBuilder().withNodeIdentifier(name));
}

Comment by Reinaldo Penno [ 23/Aug/14 ]

Tested some more and can say that the issue is the Yang statement

ordered-by user;

This was handled properly until very recently and now is broken.

Comment by Reinaldo Penno [ 24/Aug/14 ]

My scenario is

1 - RESTconf PUTs new data
2 - OnDataChanged() gets called
3 - I look at this new data and create a completely new data (only key is the same)
4 - I writeTx.put this new data.

Also, please allow me to be very clear:

If I remove "ordered-by user" from my Yang list, everything works. Same code, same everything.

Comment by Tony Tkacik [ 25/Aug/14 ]

The precondition was wrong, this was caused by refactor
of internals of this class.

FIx is in:
https://git.opendaylight.org/gerrit/10235

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