oopt-goldstone / goldstone-mgmt

TIP Goldstone management layer implementation
Apache License 2.0
7 stars 9 forks source link

system-operational-cache: system daemon that provides cache of operational information #65

Open ishidawataru opened 1 year ago

ishidawataru commented 1 year ago

Moved the discussion from https://github.com/oopt-goldstone/goldstone-mgmt/pull/63#issuecomment-1317007453

Considering adding system-operational-cache to serve the following YANG model. system-operational-cache provides an operational info-caching mechanism for all internal components.

// goldstone-operational-cache.yang

rpc get-operational-cache {
  input {
    leaf xpath {
      type string;
    }
    leaf acceptable-cache-age {
      ...
    }
  }
  output {
    anydata data {
      ...
    }
    leaf cache-hit {
      type boolean;
    }
    leaf cache-age {
      ...
    }
  }
}

intended use:

Consideration points: (copied from https://github.com/oopt-goldstone/goldstone-mgmt/pull/63#issuecomment-1317902532)

ishidawataru commented 1 year ago

Should it get operational states for a cache miss?

Only allow caching operational info of Goldstone native models?


Another idea is to add rpc get-operational-cache to all Goldstone native YANG models and let south (and xlate) daemons handle it.

We could improve lib/core.py to have a generic caching mechanism to avoid ad-hoc caching implementation in each daemon.

Then we could also improve lib/connector/sysrepo.py to provide user-friendly caching support.

# check if the model of the XPATH has `rpc get-operational-cache`,
# if it has, use it with the given acceptable-cache-age. if it doesn't have, just query operational datastore
conn.get_operational("/goldstone-interfaces:interfaces", acceptable_cache_age=60)

Should it return subtree data specified by xpath?

Handling this might become easier because now the cache query will be handled inside the daemon that handles the actual operational information.

@noguchiko WDYT?

noguchiko commented 1 year ago

Should it get operational states for a cache miss?

Only allow caching operational info of Goldstone native models?

It sounds good for now. system-operational-cache can reject an RPC for a non-supported model.

Should it return subtree data specified by xpath?

Handling this might become easier because now the cache query will be handled inside the daemon that handles the actual operational information.

We should handle XPath::Abbreviated Syntax to do it. I think it's the main reason for the difficulty.

Then we could also improve lib/connector/sysrepo.py to provide user-friendly caching support.

# check if the model of the XPATH has `rpc get-operational-cache`,
# if it has, use it with the given acceptable-cache-age. if it doesn't have, just query operational datastore
conn.get_operational("/goldstone-interfaces:interfaces", acceptable_cache_age=60)

It's useful even if we choose which option.

We have three options:

I believe ad-hoc implementations should be avoided.

Two remains:

We need further consideration.

ishidawataru commented 1 year ago

We should handle XPath::Abbreviated Syntax to do it.

What is the expected usage of this? Does system-telemetry need to use it? I think north-snmp doesn't need to use any abbreviated syntax.

noguchiko commented 1 year ago

What is the expected usage of this? Does system-telemetry need to use it? I think north-snmp doesn't need to use any abbreviated syntax.

system-telemetry will accept an xpath with abbreviated syntax as /goldstone-telemetry:subscribe-requests/subscribe-request/subscription/subscription/config/path if its user requests so.

Even if we don't supprt the syntax for now, I think we should design the architecture to be able to support it. So, I think the implementation of the subtree data retrieval should be highly cohesive. (lib or system-operational-cache)