mirror of https://github.com/k3s-io/k3s
improve pleg error msg when it has never been successful
parent
170dcc2ea0
commit
5eab76934b
|
@ -132,6 +132,9 @@ func (g *GenericPLEG) Start() {
|
|||
|
||||
func (g *GenericPLEG) Healthy() (bool, error) {
|
||||
relistTime := g.getRelistTime()
|
||||
if relistTime.IsZero() {
|
||||
return false, fmt.Errorf("pleg has yet to be successful")
|
||||
}
|
||||
elapsed := g.clock.Since(relistTime)
|
||||
if 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) {
|
||||
testPleg := newTestGenericPLEG()
|
||||
|
||||
// pleg should initially be unhealthy
|
||||
pleg, _, clock := testPleg.pleg, testPleg.runtime, testPleg.clock
|
||||
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.
|
||||
clock.Step(time.Minute * 10)
|
||||
|
@ -361,6 +363,12 @@ func TestHealthy(t *testing.T) {
|
|||
clock.Step(time.Minute * 1)
|
||||
ok, _ = pleg.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) {
|
||||
|
|
Loading…
Reference in New Issue