mirror of https://github.com/k3s-io/k3s
Merge pull request #69008 from sjenning/better-pleg-msg
improve pleg error msg when it has never been successfulpull/58/head
commit
45f6845a59
|
@ -135,6 +135,9 @@ func (g *GenericPLEG) Start() {
|
||||||
// relistThreshold is the maximum interval between two relist.
|
// relistThreshold is the maximum interval between two relist.
|
||||||
func (g *GenericPLEG) Healthy() (bool, error) {
|
func (g *GenericPLEG) Healthy() (bool, error) {
|
||||||
relistTime := g.getRelistTime()
|
relistTime := g.getRelistTime()
|
||||||
|
if relistTime.IsZero() {
|
||||||
|
return false, fmt.Errorf("pleg has yet to be successful")
|
||||||
|
}
|
||||||
elapsed := g.clock.Since(relistTime)
|
elapsed := g.clock.Since(relistTime)
|
||||||
if elapsed > relistThreshold {
|
if elapsed > relistThreshold {
|
||||||
return false, fmt.Errorf("pleg was last seen active %v ago; threshold is %v", elapsed, relistThreshold)
|
return false, fmt.Errorf("pleg was last seen active %v ago; threshold is %v", elapsed, relistThreshold)
|
||||||
|
|
|
@ -346,9 +346,11 @@ func TestRemoveCacheEntry(t *testing.T) {
|
||||||
|
|
||||||
func TestHealthy(t *testing.T) {
|
func TestHealthy(t *testing.T) {
|
||||||
testPleg := newTestGenericPLEG()
|
testPleg := newTestGenericPLEG()
|
||||||
|
|
||||||
|
// pleg should initially be unhealthy
|
||||||
pleg, _, clock := testPleg.pleg, testPleg.runtime, testPleg.clock
|
pleg, _, clock := testPleg.pleg, testPleg.runtime, testPleg.clock
|
||||||
ok, _ := pleg.Healthy()
|
ok, _ := pleg.Healthy()
|
||||||
assert.True(t, ok, "pleg should be healthy")
|
assert.False(t, ok, "pleg should be unhealthy")
|
||||||
|
|
||||||
// Advance the clock without any relisting.
|
// Advance the clock without any relisting.
|
||||||
clock.Step(time.Minute * 10)
|
clock.Step(time.Minute * 10)
|
||||||
|
@ -361,6 +363,12 @@ func TestHealthy(t *testing.T) {
|
||||||
clock.Step(time.Minute * 1)
|
clock.Step(time.Minute * 1)
|
||||||
ok, _ = pleg.Healthy()
|
ok, _ = pleg.Healthy()
|
||||||
assert.True(t, ok, "pleg should be healthy")
|
assert.True(t, ok, "pleg should be healthy")
|
||||||
|
|
||||||
|
// Advance by relistThreshold without any relisting. pleg should be unhealthy
|
||||||
|
// because it has been longer than relistThreshold since a relist occurred.
|
||||||
|
clock.Step(relistThreshold)
|
||||||
|
ok, _ = pleg.Healthy()
|
||||||
|
assert.False(t, ok, "pleg should be unhealthy")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRelistWithReinspection(t *testing.T) {
|
func TestRelistWithReinspection(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue