fix v2.8.1 monitor for new version of cache file#1792
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: peachest The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request refactors the NVIDIA monitor to use a factory pattern for handling different versions of shared region cache files, decoupling the main monitor logic from specific version implementations. However, several issues were identified: changing ownerPid to uint64 in the base sharedRegionT struct breaks backward compatibility for v1.0 and v1.1 files; multiple methods in v1/spec.go lack bounds checking when slicing the procs array or iterating over device limits, which could lead to runtime panics; and the version matching logic for v1-sem should be updated to support future minor versions.
544d7ab to
7319892
Compare
7319892 to
f89e197
Compare
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
f65b052 to
deff485
Compare
|
I found an initialization issue in this PR: the v0/v1 cache factories are not being registered correctly at startup, so findFactory(...) can return nil for valid cache files. Because of that, the vgpu-monitor fails to parse the shared cache and crashes in the loadCache path.
Could you update the initialization flow to ensure v0 and v1 are always registered before cache loading begins, and add a test that verifies factory registration/routing on startup? When I patch it in the test env. The vgpu-monitor finally works.
Here is my test branch: https://github.com/spencercjh/HAMi/tree/fix/multiple-version-monitor |
The reason v0 and v1 were not registered correctly is likely because the relevant packages were originally imported, so the init function was used for registration at the outset. However, after switching to the factory pattern, the v0 and v1 packages were no longer imported, meaning that the initialisation via the init function did not take effect. I greatly appreciate your code implementation and hope it will be adopted; I am currently working on merging your latest commit. I found that you have added a new file |
|
@peachest You can cherry-pick commits from https://github.com/spencercjh/HAMi/tree/fix/multiple-version-monitor. Thanks for you time. |
c180ef8 to
fc80b46
Compare
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
…ize_t` on amd64/arm64 platform Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: spencercjh <jiahao.cai@dynamia.ai> (cherry picked from commit 9886ec0)
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
fc80b46 to
bf9db66
Compare
|
nr1. C layout: nr2. |






What type of PR is this?
/kind bug
What this PR does / why we need it:
v2.8.1 tag HAMi bump HAMi-core version which has added new fields for struct type
shared_region_t. This make vgpu-monitor error on newly created workload with new libvgpu.so提交 1988c5dadd3e0dd49dc7c6f97c8014401b9f0f55
提交 e200da2c2ace17207accf106030715c787ce8e54
These newly added fields do not use the space reserved by
unusedbut inserted before other fields. This cause the vgpu-monitor failed to parse new format cache file and read out wrong data. But if I change the v1 spec directly, the old cache file will failed parsing too.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Also modify the field
ownerPidfrom typeuint32touint64to match the declarationsize_t owner_pidof structshared_region_tin HAMi-coresrc/multiprocess/multiprocess_memory_limit.h.Since we generally build HAMi and hami-core on platform amd64/arm64, the
size_tshould be 64-bit width. Previously, HAMi vgpu-monitor useduint32as the type for theownerPidfield, but it was still able to parse container cache files correctly to retrieve metrics because thenum uint64field has an alignment guarantee of 8. (Refer to document: https://golang.google.cn/ref/spec#Size_and_alignment_guarantees), This compensates for the misalignment in the memory layout caused by usinguint32rather thanuint64forownerPid. In fact, the values read from the fields betweenownerPidandnumare also incorrect, but this has no impact on the metric. All the fields required to parse the metric are located afternum, so the metric appears to be perfectly normal.The memory layout for
SharedRegionTin packageHAMi/pkg/monitor/nvidia/v1is shown in the table below. Notice that theOffsetOf(sem)+SizeOf(sem)=52, butOffsetOf(num)is 56. Becausenumhas typeuint64, which has an alignment of 8.Does this PR introduce a user-facing change?: No