onosproject / onos-config

Configuration subsystem for ONOS (µONOS Architecture)
44 stars 55 forks source link

gNMI Get does not include data from Network Changes #1038

Closed SeanCondon closed 4 years ago

SeanCondon commented 4 years ago

Describe the bug When a NetworkChange is made through gNMI Set the change is stored properly, but it is not shown in a subsequent gNMI Get

To Reproduce 1) Create a cluster using onit:

onit create cluster --set onos-cli.enabled=true

2) add a device simulator

onit -c onos add simulator -n devicesim-1

3) make a configuration change through the gNMI NBI

gnmi_cli -address onos-config:5150 -set \
     -proto "update: <path: <target: 'devicesim-1', elem: <name: 'system'> elem: <name: 'clock' > elem: <name: 'config'> elem: <name: 'timezone-name'>> val: <string_val: 'Europe/Edinburgh'>>" \
     -timeout 5s -en PROTO -alsologtostderr \
     -client_crt /etc/ssl/certs/client1.crt -client_key /etc/ssl/certs/client1.key -ca_crt /etc/ssl/certs/onfca.crt

4) call gNI Get to see that this value is NOT in the result set:

gnmi_cli -get -address onos-config:5150 \
    -proto "path: <target: 'devicesim-1', elem: <name: 'system'> elem: <name: 'clock' > elem: <name: 'config'> elem: <name: 'timezone-name'>>" \
    -timeout 5s -en PROTO -alsologtostderr \
    -client_crt /etc/ssl/certs/client1.crt -client_key /etc/ssl/certs/client1.key -ca_crt /etc/ssl/certs/onfca.crt

gives

notification: <
  timestamp: 1579165109
  update: <
    path: <
      elem: <
        name: "system"
      >
      elem: <
        name: "clock"
      >
      elem: <
        name: "config"
      >
      elem: <
        name: "timezone-name"
      >
      target: "devicesim-1"
    >
  >
>

Note: the value Europe/Edinburgh is missing

5) Verify that the Network Change exists and is COMPLETE

~ $ onos config get network-changes -v
CHANGE                          INDEX  REVISION  PHASE    STATE     REASON   MESSAGE
admiring_shaw                   1       62       CHANGE   COMPLETE  NONE     
    Device: devicesim-1 (1.0.0)
    |/system/clock/config/timezone-name                |(STRING) Europe/Edinburgh               |false  |

6) Verify that the DeviceChange is present and COMPLETE

~ $ onos config get device-changes devicesim-1
CHANGE                          INDEX  REVISION  PHASE    STATE     REASON   MESSAGE
admiring_shaw:devicesim-1:1.0.0 1       61       CHANGE   COMPLETE  NONE     
    admiring_shaw   1   devicesim-1 1.0.0
    |/system/clock/config/timezone-name                |(STRING) Europe/Edinburgh               |false  |

7) Doing a gNMI Get on all attributes of devicesim-1 does not get it

~ $ gnmi_cli -get -address onos-config:5150 \
     -proto "path: <target: 'devicesim-1'>" \
     -timeout 5s -en PROTO -alsologtostderr \
     -client_crt /etc/ssl/certs/client1.crt -client_key /etc/ssl/certs/client1.key -ca_crt /etc/ssl/certs/onfca.crt

gives

notification: <
  timestamp: 1579166134
  update: <
    path: <
      target: "devicesim-1"
    >
    val: <
      json_val: "{\"system\":{\"openflow\":{\"controllers\":{\"controller\":[{\"connections\":{\"connection\":[{\"aux-id\":0,\"state\":{\"address\":\"192.168.1.237\",\"aux-id\":\"0\",\"port\":\"6633\",\"priority\":1,\"source-interface\":\"admin\",\"transport\":\"TLS\"}},{\"aux-id\":1,\"state\":{\"address\":\"192.0.2.11\",\"aux-id\":\"1\",\"port\":\"6653\",\"priority\":2,\"source-interface\":\"admin\",\"transport\":\"TLS\"}}]},\"name\":\"main\"},{\"connections\":{\"connection\":[{\"aux-id\":1,\"state\":{\"address\":\"192.0.3.11\",\"aux-id\":\"1\",\"port\":\"6653\",\"priority\":2,\"source-interface\":\"admin\",\"transport\":\"TLS\"}},{\"aux-id\":0,\"state\":{\"address\":\"192.0.3.10\",\"aux-id\":\"0\",\"port\":\"6633\",\"priority\":1,\"source-interface\":\"admin\",\"transport\":\"TLS\"}}]},\"name\":\"second\"}]}},\"state\":{\"boot-time\":\"1575415411\",\"current-datetime\":\"2020-01-16T09:15:33Z+00:00\",\"domain-name\":\"opennetworking.org\",\"hostname\":\"devicesim-1\",\"login-banner\":\"This device is for authorized use only\",\"motd-banner\":\"Welcome to gNMI service on devicesim-1:10161\"}}}"
    >
  >
>

The output is in JSON, and when formatted looks like following (which are all Opstate attributes, and does not include the configured timezone-name):

{
"system": {
"openflow": {
"controllers": {
"controller": [
{
"connections": {
"connection": [
{
"aux-id": 0,
"state": {
"address": "192.168.1.237",
"aux-id": "0",
"port": "6633",
"priority": 1,
"source-interface": "admin",
"transport": "TLS"
}
},
{
"aux-id": 1,
"state": {
"address": "192.0.2.11",
"aux-id": "1",
"port": "6653",
"priority": 2,
"source-interface": "admin",
"transport": "TLS"
}
}
]
},
"name": "main"
},
{
"connections": {
"connection": [
{
"aux-id": 1,
"state": {
"address": "192.0.3.11",
"aux-id": "1",
"port": "6653",
"priority": 2,
"source-interface": "admin",
"transport": "TLS"
}
},
{
"aux-id": 0,
"state": {
"address": "192.0.3.10",
"aux-id": "0",
"port": "6633",
"priority": 1,
"source-interface": "admin",
"transport": "TLS"
}
}
]
},
"name": "second"
}
]
}
},
"state": {
"boot-time": "1575415411",
"current-datetime": "2020-01-16T09:15:33Z+00:00",
"domain-name": "opennetworking.org",
"hostname": "devicesim-1",
"login-banner": "This device is for authorized use only",
"motd-banner": "Welcome to gNMI service on devicesim-1:10161"
}
}
}

Expected behavior When a value is in a NetworkChange or a Snapshot it should be visible in the gNMI Get

Logs, text or screenshots

{"level":"info","ts":1579166166.1227894,"logger":"manager","caller":"manager/manager.go:258","msg":"Handling target devicesim-1 as :"}
{"level":"info","ts":1579166166.1228735,"logger":"manager","caller":"manager/manager.go:260","msg":"Ignoring device type  and version  from extension for devicesim-1. Using Devicesim and 1.0.0"}
{"level":"info","ts":1579166166.1229029,"logger":"manager","caller":"manager/getstate.go:25","msg":"Getting State for devicesim-1/system/clock/config/timezone-name"}
{"level":"warn","ts":1579166166.1230278,"logger":"manager","caller":"manager/getstate.go:38","msg":"Path /system/clock/config/timezone-name is not in the operational state cache of device devicesim-1"}

Additional context This is one of the foundations of the system, and is a high priority to fix

SeanCondon commented 4 years ago

This might only be on the first NetworkChange made after the cluster is started

SeanCondon commented 4 years ago

Also I'm finding that if I make a few changes (e.g. /interfaces/interface[name=eth1]/config/name and description and enabled ), and then do a compact-changes then the result I'm getting is the result of the complete snapshot - not just the attribute that was requested:

~ $ gnmi_cli -get -address onos-config:5150 \
>     -proto "path: <target: 'devicesim-1', elem: <name: 'system'> elem: <name: 'clock' > elem: <name: 'config'> elem: <name: 'timezone-name'>>" \
>     -timeout 5s -en PROTO -alsologtostderr \
>     -client_crt /etc/ssl/certs/client1.crt -client_key /etc/ssl/certs/client1.key -ca_crt /etc/ssl/certs/onfca.crt

gives

notification: <
  timestamp: 1579178113
  update: <
    path: <
      elem: <
        name: "system"
      >
      elem: <
        name: "clock"
      >
      elem: <
        name: "config"
      >
      elem: <
        name: "timezone-name"
      >
      target: "devicesim-1"
    >
    val: <
      json_val: "{\"interfaces\":{\"interface\":[{\"config\":{\"description\":\"First device\",\"enabled\":true,\"name\":\"eth1\"},\"name\":\"eth1\"}]},\"system\":{\"clock\":{\"config\":{\"timezone-name\":\"Europe/Edinburgh\"}}}}"
    >
  >
>
~ $ 
SeanCondon commented 4 years ago

Fixed by #1044