-
Notifications
You must be signed in to change notification settings - Fork 292
CP-53314: Read and watch <domain>/data/service in xenstore to DB #6317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP-53314: Read and watch <domain>/data/service in xenstore to DB #6317
Conversation
1. xenopsd backend read and watch /local/domain/%d/data/service 2. xapi_guest_agent convert the data to (string, string) list to store in VM_guest_metrics.services Signed-off-by: Changlei Li <changlei.li@cloud.com>
3d45f0a
to
634db51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a new module that seems security-related, but its usage is not obvious to me, it lacks dopcumentation, and is missing unit-tests. Please at least add documentation and intended usage so we can change the module to make usre there aren't any footguns lurking around. After that, unit-test will better document how touse it and highlight edge-cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs documentation. I'm approving this but expect this to be updated.
Read and convert to [(<service_name>/<key>, <value>)] pair list. | ||
The list is intended to store in VM_guest_metrics.services at last *) | ||
let get_guest_services (lookup : string -> string option) | ||
(list : string -> string list) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the list
function doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list
is defined in xapi_xenops.ml
update_vm
. It lists all subdirs and keys in one depth under the given dir. In its definition, the data source is a big string string map like [("a", ""); ("a/b", ""); ("a/b/k1", "v1"); ("a/b/k2", "v2"); ("a/c/k1", "v1"); ("a/c/k2", "v2")]
. Then function list "a"
will give all subdirs ["b", "c"]
. It needs to be noticed that the data source is not exposed to the caller in xapi_guest_agent.ml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utop # list_subkeys ["aaa/bbb/c", "x"] "aaa/bb";;
- : string list = ["b"]
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's incorrect. I believe the real implementation of list in xapi_xenops.ml update_vm has this problem, too. Normally, it's a internal function and the caller only pass the parameter as a intact dir, so the problem is not exposed. It deserves to rasie a ticket to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ls assoc path =
let split = String.split_on_char '/' in
let prefix = split path in
let paths = List.map (fun (path, _) -> split path) assoc in
let rec entry prefix path =
match prefix, path with
| [], x::_ -> Some x
| x::xs, y::ys when x = y -> entry xs ys
| _ -> None
in
List.filter_map (entry prefix) paths
xenstore is already a bottlekneck. Xapi watching these keys really means xenopsd watching it and more traffic over message switch, which has proved to be an amplification vector in the past. How many new watches does this create? |
I would not expect these values to be updated frequently over the lifetime of a VM - so would not expect an impact from watches. @last-genius |
Yes. Only single digit number of service-install data are written in data/service by guest agent. So, the path will be only written once after VM starting and expected not changed later. |
bb2816f
to
1de3160
Compare
I am a bit puzzled by introducing a Limit module but only using it for part of the keys that a VM is using. If there is no unified mechanism this is easy to circumvent by using different keys that don't maintain a quota. |
1de3160
to
17a5a1a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
17a5a1a
to
a09380e
Compare
a09380e
to
d2c0b51
Compare
Xenopsd already has a quota limit mechanism for guest_agent when reading xenstore. Remove the amout, key_len, value_len limit in this PR. It's better to use the general quota limit mechanism to keep it simple. |
Signed-off-by: Changlei Li <changlei.li@cloud.com>
d2c0b51
to
a6b5b7c
Compare
b15e765
into
xapi-project:feature/guest-vm-service-aware
The field
VM_guest_metrics.services
added previously (#6309) is used to store VM service information reported by guest tools.Xapi does not use this data but just holds it for outside consumers.
This PR reads the xenstore path
data/service
and converts to[("service_name/key", "value")]
pair list and then store to VM_guest_metrics.services.The path to read is like:
/local/domain/<id>/data/service/<service_name>/<key> = <value>