Merge pull request #69008 from sjenning/better-pleg-msg

improve pleg error msg when it has never been successful
pull/58/head
k8s-ci-robot 2018-10-30 16:15:43 -07:00 committed by GitHub
commit 45f6845a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -135,6 +135,9 @@ func (g *GenericPLEG) Start() {
// relistThreshold is the maximum interval between two relist.
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)

View File

@ -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) {