Versions Compared

Key

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

Initial Findings

It is found that the current Patch operation in CPS core can only update value of one data tree leaf nodes under a container node at a time. So if there are multiple data trees under an anchor and a Patch is performed on all the data trees using root node xPath "/" then only the first data tree gets updated and the remaining data trees remain as it is,

Based on the above outcome, another test to update individual data trees was preformed, and it was found that when a specific data tree is being updated using its specific xPath none of the data trees get updated and a 400 BAD REQUEST is received.

Decisions

To be added

JSON Data Stored in CPS DB using POST operation

The following JSON data was first stored in CPS DB, then to test the GET operation:

Code Block
{
  "multiple-data-tree:interface-A": {
    "host-name": "host",
    "interface": [
      {
        "name": "Interface-A",
        "address": "10.10.10.1",
        "subnet-mask": "255.255.255.0",
        "enabled": false
      }
    ],
    "domain": "false"
  },
  "multiple-data-tree:interface-B": {
    "interface": [
      {
        "name": "Interface-B",
        "address": "10.10.10.1",
        "subnet-mask": "255.255.255.0"
      }
    ]
  }
}

Analysis of Patch operation (Update node leaves)

Currently after multiple data trees are stored in CPS DB. On performing the Patch operation on the same data, with xpath set as root "/", the first data tree is only updated by the Patch operation. To test this following scenarios were performed:

Updating all data trees under an anchor with root node xPath "/"

CURL request to update all data trees

...

Issues & Decisions:

NotesDecisions

 

As per discussion with stakeholder (DT), the following decisions were made:

  • Support for update operation across data trees is not of high priority.
  • But the error code returned when trying to update. multiple data trees should be made specific.
  • Team decision is to be taken regarding the new/updated error response.

 

After discussion in the CPS-sub team, following conclusions were made:

  • Use correct Error Code and Response Message, when updating multiple data nodes
  • As per CPS Exceptions and REST APIs HTTP Response Codes, the response code was set to 400 with appropriate message.
  • Update for single data node with root node xpath remains as it is.

After the investigation it was found that the reason behind the inconsistencies discovered was lack of support for Patch operation for multiple data nodes.

As per discussion in CPS sub team daily call it was decided to bring in support for Patch operation for multiple data nodes. As it would address all the inconsistencies discovered.

JSON Data Stored in CPS DB using POST operation.

The following JSON data was first stored in CPS DB:

Code Block
collapsetrue
{
  "multiple-data-tree:interface-A": {
    "host-name": "host",

...


    "interface": [
      {
        "name": "Interface-

...

A",
        "address": "10.10.10.

...

1",
 

...

 

...

   

...

 

...

 

...

 

...

"subnet-mask": "255.255.255.0",
        "enabled": 

...

false
    

...

  }

...

Response: 500 Server Error

...

    ],
    "

...

domain": "

...

false"
  },
  "

...

multiple-data-tree:interface-B": 

...

{
 

...

 

...

 

...

 "interface": [
      {
        "

...

name": "

...

Interface-B",
    

...

    

...

"address": 

...

"10.10.10.1",
        "

...

subnet-mask": "

...

255.255.255.0"
      }
    ]
  }
}

Analysis of Patch operation (Update node leaves)

Currently after multiple data trees are stored in CPS DB. On performing the Patch operation, with root node xpath "/", the first data tree is only updated by the Patch operation. To test this following scenarios were performed:

  1. Updating all data trees under an anchor with root node xPath "/"

    Code Block
    titleCURL request to update multiple leaves across multiple data trees
    collapsetrue
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
      "multiple-data-tree:interface-A": {
        "host-name": "host-A",				   //value to be updated
        "interface": [						   
          {
    "host-name": "host",
                "interface": [
                    {
                        "name": "Interface-A",
                        "address": "10.10.10.1",
                        "enabledname": false"Interface-A",
            "address": "10.10.10.100",         
            "subnet-mask": "255.255.255.0"
                    }
                ]25",   
            "enabled": false
            }
        },
        {
     ],
           "int:interface-B"domain": {"true"
      },
              "interface": [
       "multiple-data-tree:interface-B": {
        "interface": [						  
          {
                        "name": "Interface-B",
                        "address": "10.10.10.1100",
           //value to             be updated
            "subnet-mask": "255.255.255.0"
       //value to be updated
           }
         ]
      }
    }'


    Code Block
    titleResponse: 500 Server Error
    collapsetrue
    {
        "status": "500 INTERNAL_SERVER_ERROR",
          ]
            }
        }
    ]

    Updating the first data tree
    CURL request to update first data tree

    "message": "could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement",
        "details": "Check logs for details."
    }

    Reason: The following scenario would fail because CPS Patch operation only supports updating multiple leaves under one container node at a time. And here when we try to update multiple leaves present in two different containers the operations fails. 

    Code Block
    titleOn performing Get operation we get the following JSON data, here none of the leaves are updated
    collapsetrue
    [
        
    Code Block
    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=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
            "int:interface-A": {
                "namedomain": "Interface-Afalse",
                "addresshost-name": "10.10.10.200host",
                "enabledinterface": true,[
                    {
                "subnet-mask": "255.255.255.0"
            "name": "Interface-A",
              }
        }'

    Response 200 OK
    Updated data after making get request

    Code Block
    [
      {
        "int:interface-Aaddress": {"10.10.10.1",
          "domain": "false",
          "host-name": "host",
          "interfaceenabled": [false,
              {
              "namesubnet-mask": "Interface-A",
    255.255.255.0"
                "address": "10.10.10.200",
        }
            "enabled": true,
       ]
           "subnet-mask": "255.255.255.0" }
        },
        }{
          ]  "int:interface-B": {
        }
      }
    ]

    Updating the second data tree
    CURL request to update second data tree

    Code Block
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-B' \
    --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '        "interface": [
                    {
            "int:interface": {
                "name": "Interface-B",
                        "address": "10.10.10.2001",
                        "subnet-mask": "255.255.255.100"
            }
        }'

    Response 200 OK
    Updated data after making get request

    Code Block
    [
      {
        "int:interface-B": {}
          "interface": [
            {
       ]
           "name": "Interface-B", }
        }
    ]


  2. Updating the data trees individually, leads to successful updation
    When updating multiple leaves present under individual data nodes the operation successfully executes.

    Code Block
    titleCURL request to update leaves under container data node
    collapsetrue
    curl --location --request    "address": "10.10.10.200",
              "subnet-mask": "255.255.255.10"
            }
          ]
        }
      }
    ]

Inconsistencies with Patch Operation

When updating multiple data trees with only leaf nodes

Assuming the following data is in the data base, having one leaf node in each data tree

...

  1. PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' \
    --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
        "int:interface-A": {
          "domain": 

...

  1. "true",			//value to be updated
          "host-name": "

...

  1. Host-A"	    //value to be updated
       
        

...

  1. }
      }

...

An update operation is performed on both data trees as follows:

Code Block
curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/multipleDataTree/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0kglnliqz1tzc1g0x6opgrphei0.node0' \
--data '{
  "first-container": {
    "a-leaf": "a-new-value"
  },
  "last-container": {
    "x-leaf": "x-new-value"
  }
}'

On performing a get operation, it is noticed that only first data tree gets updated

...

  1. '

    Response 200 OK

    Code Block
    titleUpdated data after making get request
    collapsetrue
    [
      {
        "int:interface-A": {
          "domain": "true",			//updated
          "host-name": "Host-A",	//updated
          "interface": [
            {
              "name": "Interface-A",
              "address": "10.10.10.200",		
              "enabled": true,					
              "

...

  1. subnet-

...

  1. mask": "

...

  1. 255.255.255.0"
            }
      

...

  1.     ]
        }
      

...

  1. }
    ]


    Code Block
    titleCURL request to update leaves of one list item in a list data node
    collapsetrue
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-B' \
    --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '

When updating list node with xpath set as root node xpath "/", returns Status 200 but data is not updated

Assuming the following data is in the databse

...

  1. {
        

...

  1.  

...

  1.    "

...

  1. int:interface": 

...

  1. {
          

...

  1.       "name": "Interface-

...

  1. B",
                "address": "10.10.10.200",

...

  1. 			//value to be updated
       

...

  1.          "subnet-mask": "255.255.255.

...

  1. 10"		//value to be updated
            }
    

...

  1.   

...

  1.   }

...

  1. '

    Response 200 OK

    Code Block
    titleUpdated data after making get request
    collapsetrue
    [
      {
        "int:interface-B": {
          "interface": [
            {
              "name": "Interface-B",
              "address": "10.10.10.200",		//updated
              "subnet-mask": "255.255.255.10"	//updated
            }
          ]
        }
      }
    ]


Inconsistencies with Patch Operation

When updating multiple data trees with only leaf nodes

Assuming the following data is in the data base, having one leaf in each data tree

Code Block
{
  "first-container": {
    "a-leaf": "a-value"
  },
  "last-container": {
    "x-leaf": "x-value"
  }
}

An update operation is performed on both data trees as follows:

Code Block
collapsetrue
curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/multipleDataTree/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0kglnliqz1tzc1g0x6opgrphei0.node0' \
--data '{
  "first-container

When performing update operation with xPath set as root

Code Block
curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node01ejoiyh1brii5zx8z9mk2r39l1.node0' \
--data '{
  "int:interface-A": {
    "domain": "false",
    "host-name": "New-Host",      		//updated value 
    "interface": [
      {
        "name": "Interface-A",
        "address": "10.10.10.0",   	    //updated value
        "enabled": false,			    //updated value
        "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 updated and list node remains as it is.

Code Block
{
  "int:interface-A": {
    "domaina-leaf": "falsea-new-value",
  },
  "hostlast-namecontainer": "New-Host",               //Updated{
    "interface"x-leaf": ["x-new-value"
      }
}'

On performing a get operation, it is noticed that only first data tree gets updated

Code Block
collapsetrue
[
  {
        "name": "Interface-A",
  "multiple-data-tree:last-container": {
      "addressx-leaf": "10.10.10.200",x-new-value"
    }
  },
  //Unchanged
    {
    "enabledmultiple-data-tree:first-container": true,{
           "a-leaf": "a-value"
    }
   //Unchanged
        "subnet-mask": "255.255.255.0"
      }
    ]
  }
}}
]

When updating multiple list items under a list node, returns Status 200 but list data is not updated

(Note: This following finding was identified as an issue with list-nodes and not multiple data nodes. It is documented separately CPS-1383: Investigate CPS-Path for modifications of multiple fragments under an anchor.)