etcdmain: Honour ExperimentalWaitClusterReadyTimeout in startEtcd

When we can't reach quorum, we were waiting forever and never sending
the systemd notify message. As a result, systemd would eventually time out
and restart the etcd process which likely would make the unhealthy cluster
in an even worse state

Improves #13785

Signed-off-by: Nicolai Moore <niconorsk@gmail.com>
This commit is contained in:
Nicolai Moore
2022-08-26 10:05:33 +10:00
parent 96a2669839
commit e15bdd9df1
5 changed files with 66 additions and 15 deletions

View File

@@ -15,9 +15,12 @@
package e2e
import (
"context"
"fmt"
"net/url"
"os"
"testing"
"time"
"go.uber.org/zap"
@@ -48,7 +51,7 @@ type EtcdProcess interface {
}
type LogsExpect interface {
Expect(string) (string, error)
ExpectWithContext(context.Context, string) (string, error)
Lines() []string
LineCount() int
}
@@ -179,3 +182,14 @@ func (ep *EtcdServerProcess) Logs() LogsExpect {
}
return ep.proc
}
func AssertProcessLogs(t *testing.T, ep EtcdProcess, expectLog string) {
t.Helper()
var err error
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
_, err = ep.Logs().ExpectWithContext(ctx, expectLog)
if err != nil {
t.Fatal(err)
}
}