diff options
author | Lukas Vogel <vogel@anapaya.net> | 2022-07-28 16:50:34 +0200 |
---|---|---|
committer | Nathan Skrzypczak <nathan.skrzypczak@gmail.com> | 2022-07-29 07:40:44 +0000 |
commit | 0f05d2a3730dbe1659d5a310db6039e9c1373989 (patch) | |
tree | 483e38256a682a4a0587ebd26920f67d0f8b7df4 | |
parent | 4223b112aec2f4a1c8577b239932a1de38703bed (diff) |
Fix stats API for vpp 22.06
VPP changed the error counters to be simple counters in
https://gerrit.fd.io/r/c/vpp/+/35640, that broke goVPP stats extraction.
This was partially fixed by https://gerrit.fd.io/r/c/govpp/+/36085,
however this fix didn't make it work completely.
There were some leftover conversions from dirType (== int) to StatType
(== string). Unfortunately the Go compiler does not flag those, they
would however be catched by go vet.
The fixes that are done here makes the stats extraction work for us
partially: We noticed that error counters are now of type symlink and
unfortunately updating a stat dir that contains symlink counters doesn't
work correctly. CopyEntryData, that is called when initializing the dir,
correctly handles the symlink counters. But updateStatOnIndex simply
ignores symlink counters because `dirType != entry.Type` will hold. We
didn't really figure out how to correctly handle this so this would need
to be picked up by someone who is more familiar with the code. For now
we work around this limitation by not using the GetErrorStats API and
instead manually read the dir everytime we want to access error
counters.
Co-authored-by: Sergio Gonzalez Monroy <monroy@anapaya.net>
Change-Id: I322133f362e782fea3e8a2be70967a796ba87b75
Signed-off-by: Lukas Vogel <vogel@anapaya.net>
-rw-r--r-- | adapter/statsclient/stat_segment_api.go | 5 | ||||
-rw-r--r-- | adapter/statsclient/statsclient.go | 4 | ||||
-rw-r--r-- | adapter/statsclient/statseg_v1.go | 4 | ||||
-rw-r--r-- | adapter/statsclient/statseg_v2.go | 4 |
4 files changed, 9 insertions, 8 deletions
diff --git a/adapter/statsclient/stat_segment_api.go b/adapter/statsclient/stat_segment_api.go index fd7ef36..cb8b105 100644 --- a/adapter/statsclient/stat_segment_api.go +++ b/adapter/statsclient/stat_segment_api.go @@ -16,10 +16,11 @@ package statsclient import ( "fmt" - "git.fd.io/govpp.git/adapter" "sync/atomic" "time" "unsafe" + + "git.fd.io/govpp.git/adapter" ) var ( @@ -77,7 +78,7 @@ type statSegment interface { // // Note that if the index is equal to 0, the result pointer points to // the same memory address as the argument. - GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, dirType) + GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) // GetEpoch re-loads stats header and returns current epoch //and 'inProgress' value diff --git a/adapter/statsclient/statsclient.go b/adapter/statsclient/statsclient.go index 6231f69..18c1266 100644 --- a/adapter/statsclient/statsclient.go +++ b/adapter/statsclient/statsclient.go @@ -518,7 +518,7 @@ func (sc *StatsClient) getStatEntriesOnIndex(vector dirVector, indexes ...uint32 }, Type: t, Data: d, - Symlink: adapter.StatType(dirType) == adapter.Symlink, + Symlink: dirType == adapter.Symlink, }) } return entries, nil @@ -602,7 +602,7 @@ func (sc *StatsClient) updateStatOnIndex(entry *adapter.StatEntry, vector dirVec dirPtr, dirName, dirType := sc.GetStatDirOnIndex(vector, entry.Index) if len(dirName) == 0 || !bytes.Equal(dirName, entry.Name) || - adapter.StatType(dirType) != entry.Type || + dirType != entry.Type || entry.Data == nil { return nil } diff --git a/adapter/statsclient/statseg_v1.go b/adapter/statsclient/statseg_v1.go index 3f15ce2..202a1b0 100644 --- a/adapter/statsclient/statseg_v1.go +++ b/adapter/statsclient/statseg_v1.go @@ -75,7 +75,7 @@ func (ss *statSegmentV1) getErrorVector() (unsafe.Pointer, error) { return nil, fmt.Errorf("error vector is not defined for stats API v1") } -func (ss *statSegmentV1) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, dirType) { +func (ss *statSegmentV1) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) { statSegDir := dirSegment(uintptr(v) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntryV1{})) dir := (*statSegDirectoryEntryV1)(statSegDir) var name []byte @@ -85,7 +85,7 @@ func (ss *statSegmentV1) GetStatDirOnIndex(v dirVector, index uint32) (dirSegmen break } } - return statSegDir, name, dir.directoryType + return statSegDir, name, getStatType(dir.directoryType, true) } func (ss *statSegmentV1) GetEpoch() (int64, bool) { diff --git a/adapter/statsclient/statseg_v2.go b/adapter/statsclient/statseg_v2.go index 11a3679..aa65a3d 100644 --- a/adapter/statsclient/statseg_v2.go +++ b/adapter/statsclient/statseg_v2.go @@ -72,7 +72,7 @@ func (ss *statSegmentV2) GetDirectoryVector() dirVector { return ss.adjust(dirVector(&header.dirVector)) } -func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, dirType) { +func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegment, dirName, adapter.StatType) { statSegDir := dirSegment(uintptr(v) + uintptr(index)*unsafe.Sizeof(statSegDirectoryEntryV2{})) dir := (*statSegDirectoryEntryV2)(statSegDir) var name []byte @@ -82,7 +82,7 @@ func (ss *statSegmentV2) GetStatDirOnIndex(v dirVector, index uint32) (dirSegmen break } } - return statSegDir, name, dir.directoryType + return statSegDir, name, getStatType(dir.directoryType, ss.getErrorVector() != nil) } func (ss *statSegmentV2) GetEpoch() (int64, bool) { |