fix: handle 'delayed' state in sync_completed parsing - #786
Conversation
- Add TestMdraidDelayedSyncCompleted to verify delayed state handling - Include complete test data with delayed sync_completed value - Test verifies SyncCompleted=0, SyncAction='resync', and all component states Fixes prometheus#786
SuperQ
left a comment
There was a problem hiding this comment.
This needs a DCO sign-off. You can use git commit -s --amend to add it.
| } | ||
|
|
||
| if val, err := util.SysReadFile(filepath.Join(path, "sync_completed")); err == nil { | ||
| if val != "none" { |
There was a problem hiding this comment.
Even though "none" and "delayed" are currently the only two special cases (as of kernel v6.19.10), I wonder if this would be more robust if we performed a regex match, or flipped the logic around the fmt.Sscanf so that it would handle future special cases that don't match the %d / %d format.
427ead0 to
b53b9c2
Compare
- Add TestMdraidDelayedSyncCompleted to verify delayed state handling - Include complete test data with delayed sync_completed value - Test verifies SyncCompleted=0, SyncAction='resync', and all component states Fixes prometheus#786 Signed-off-by: Mehrdad Biukian Naeini <mehrdad.biu@mtnirancell.ir>
Add 'delayed' to the special values in sync_completed parsing (similar to 'none'). When multiple MD RAID arrays share physical devices and a check/resync is triggered for more than one, the kernel delays the action on all but one device, so sync_completed contains 'delayed' instead of 'none' or 'N / M', which previously caused 'error parsing mdraids: expected integer'. Fixes prometheus#786 Signed-off-by: Mehrdad Biukian Naeini <mehrdad.biu@mtnirancell.ir>
Add 'delayed' to the special values in sync_completed parsing (similar to 'none'). When multiple MD RAID arrays share physical devices and a check/resync is triggered for more than one, the kernel delays the action on all but one device, so sync_completed contains 'delayed' instead of 'none' or 'N / M', which previously caused 'error parsing mdraids: expected integer'. Adds a regression fixture (testdata/fixtures/sys/issue770) and TestMdraidDelayedSyncCompleted covering the delayed state. Fixes prometheus#786 Signed-off-by: Mehrdad Biukian Naeini <mehrdad.biu@mtnirancell.ir>
b53b9c2 to
68b0e29
Compare
|
@SuperQ DCO sign-off added (single squashed commit, While reworking this I also found and fixed a real defect in the PR itself: the regression test referenced Force-pushed |
Summary
delayedas a special value in sync_completed parsing (similar tonone)sync_completedcontainsdelayedinstead ofnoneorN / MProblem
The current code fails when
sync_completedcontainsdelayed:Solution
Add
delayedto the list of special values that should not be parsed as integers.Testing
none,delayed,123 / 456,invalidFixes #770
Related: prometheus/node_exporter#3500