-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only register lost sectors alert if the percentage of sectors lost ex…
…ceeds a certain threshold. (#1187) I noticed a handful of "Host has lost sectors" alerts on my node and `arequipa`. Since we hint at blocking these hosts and since these alerts aren't really all that actionable I introduced a threshold, as Nate suggested in the last engineering sync. This is hardcoded to be 1% of the host's stored data.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package contractor | ||
|
||
import ( | ||
"testing" | ||
|
||
rhpv2 "go.sia.tech/core/rhp/v2" | ||
) | ||
|
||
func TestRegisterLostSectorsAlert(t *testing.T) { | ||
for _, tc := range []struct { | ||
dataLost uint64 | ||
dataStored uint64 | ||
expected bool | ||
}{ | ||
{0, 0, false}, | ||
{0, rhpv2.SectorSize, false}, | ||
{rhpv2.SectorSize, 0, true}, | ||
{rhpv2.SectorSize, 99 * rhpv2.SectorSize, true}, | ||
{rhpv2.SectorSize, 100 * rhpv2.SectorSize, true}, // exactly 1% | ||
{rhpv2.SectorSize, 101 * rhpv2.SectorSize, false}, // just short of 1% | ||
} { | ||
if result := registerLostSectorsAlert(tc.dataLost, tc.dataStored); result != tc.expected { | ||
t.Fatalf("unexpected result for dataLost=%d, dataStored=%d: %v", tc.dataLost, tc.dataStored, result) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters