Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Issues and Decisions 

now we are able to add more than one root nodes. can we update data fragments of more than one root nodes.  
#IssuesNotesDecision
1do we need separate operation for list or can we support all variations using same solution without interface changes

Toine Siebelink Prefer single solution that address all scenarios (multiple containers or list entries) correctly without interface changes. 

2Should all patch operations be part of single transactionfor now treat individual
3what to do with failures
  1. stop and rollback (depends on issue #2)
  2. silently ignore
  3. stop processing with rollback 

4

What if a new data node(list item/container)is sent in the patch?

  1. Add the new item
  2. stop and throw error

Lukasz Rajewskibrought up the point where if a new item is sent in the update request then what will be the expected behavior of CPS.

5How will we match the data nodes?

For example there are 10 data nodes and update is done on data nodes at position 1,5 and 9. How will the data nodes be matched? Because the payload will have only the 1st 5th and 9th data node with updated values

Arne Chrestin raised the following concern. Need to figure out how the matching of data nodes will take place in this scenario

Exposing endpoint to clients might be vulnerable. we can add a flag to enable/disable this feature in docker compose file.2

Initial findings

When trying to perform Patch operation on a list data node, wherein multiple list items are updated in one request. It is seen that only the top most item in the list gets updated where as the remaining list items remain as it is.

...

Assuming the following data is in the database


Code Block

...

titleData Example
collapsetrue
{
  "int:interface-A": {

...


    "interface": [

...


      {

...


        "name": "Interface-A",

...


        "address": "10.10.10.200",

...


        "enabled": true,

...


        "subnet-mask": "255.255.255.0"

...


      },

...



      {

...


        "name": "Interface-B",

...


        "address": "10.10.10.200",

...


        "enabled": true,

...


        "subnet-mask": "255.255.255.0"

...


      }

...


    ]

...


  }

...


}

When performing update operation with xPath set as root

...

on the list data node

Code Block
titlePatch operation
collapsetrue
curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-A' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node01ejoiyh1brii5zx8z9mk2r39l1.node0' \

...


--data '{

...


  "int:interface-A": {

...


    "interface": [

...


      {

...


        "name": "Interface-A",

...


        "address": "10.10.10.0",        //value to be updated

...


        "enabled": false,               //value to be updated

...


        "subnet-mask": "255.255.255.0"

...


      },              

...



      {

...


        "name": "Interface-B",

...


        "address": "1.1.1.1",          //value to be updated

...


        "enabled": false,              //value to be updated

...


        "subnet-mask": "255.255.255.0"

...


      }

...



    ]

...


  }

...


}'

Status 200 OK is returned, but on performing the Get operation it is noticed only the leaf nodes get first item in the list node gets updated and list node second one remains as it is.

Code Block
titleData After Update
collapsetrue
{

...


  "int:interface-A": {

...


    "interface": [

...


      {

...


        "name": "Interface-A",

...


        "address": "10.10.10.0",        //changed value

...


        "enabled": false,                  //changed value

...


        "subnet-mask": "255.255.255.0"

...


      },              

...



      {

...


        "name": "Interface-B",

...


        "address": "10.10.10.200",       //unchanged value

...


        "enabled": true,                //unchanged value

...


        "subnet-mask": "255.255.255.0"

...


      }

...



    ]

...


  }

...


}

Impact of CPS-1526 on this issue

...

So, if there is a list data node with multiple list items, and the user tries to update multiple list items at once as in the example above, the system now returns a 400 Bad Request, with the error message that the operation is unsupported because the user is basically updating multiple data nodes under a list, earlier this response was a 200 OK with a partial Patch operation taking place in the background.

Assuming the following data is in the DB

...

.

...

Updating multiple items in a list data node

Code Block
curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/MultipleDataTree/nodes?xpath=%2Finterface-A&observed-timestamp=2021-03-21T00%3A10%3A34.030-0100' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' \
--header 'Cookie: JSESSIONID=node01oja2kuolgg6dtfvnzzqf4bwk0.node0' \
--data '{
        
            "interface": [
                
                {
                    "name": "Interface-A-2",
                    "address": "1.1.1.1",		//value to be updated
                    "enabled": true,			//value to be updated
                    "subnet-mask": "0.0.0.0"
                },
                {
                    "name": "Interface-A",
                    "address": "10.10.10.10",	//value to be updated
                    "enabled": true,			//value to be updated
                    "subnet-mask": "0.0.0.0"
                }
            ]
        
    }'

Response received after CPS 1526

Code Block
titleResponse
{
    "status": "400 BAD_REQUEST",
    "message": "Operation is not supported for multiple data nodes",
    "details": "Number of data nodes present: 2"
}


Possible Solutions to Updating multiple items

...

.

  • Iterate over top-level element in patch.
  • match each top element element to target data 
  • execute each patch
  • Transactional ?!
  • test & demo for each scenario
    • top level containers
    • top level list elements
    • list elements under same container

By having a new sub end point for Patch operation that specifically performs update on list data nodes

New sub endpoint: PATCH http://{IP}:{PORT}/cps/api/v1/dataspaces/{dataspace-name}/anchor/{anchor-name}/list-nodes?xpath

...