Fix secrets encryption rotation timeout causing false failures

Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
(cherry picked from commit f7f546a23e)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
bo.jiang
2025-05-26 15:48:40 +08:00
committed by Brad Davidson
parent e77f78ee94
commit 63a55bc5f0

View File

@@ -257,7 +257,7 @@ func WaitForEncryptionConfigReload(runtime *config.ControlRuntime, reloadSuccess
var lastFailure string
ctx := context.Background()
err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 120*time.Second, true, func(ctx context.Context) (bool, error) {
newReloadTime, newReloadSuccess, err := GetEncryptionConfigMetrics(runtime, false)
if err != nil {
return true, err
@@ -265,6 +265,7 @@ func WaitForEncryptionConfigReload(runtime *config.ControlRuntime, reloadSuccess
if newReloadSuccess <= reloadSuccesses || newReloadTime <= reloadTime {
lastFailure = fmt.Sprintf("apiserver has not reloaded encryption configuration (reload success: %d/%d, reload timestamp %d/%d)", newReloadSuccess, reloadSuccesses, newReloadTime, reloadTime)
logrus.Debugf("waiting for apiserver to reload encryption config: %s", lastFailure)
return false, nil
}
logrus.Infof("encryption config reloaded successfully %d times", newReloadSuccess)
@@ -297,7 +298,7 @@ func GetEncryptionConfigMetrics(runtime *config.ControlRuntime, initialMetrics b
// This is wrapped in a poller because on startup no metrics exist. Its only after the encryption config
// is modified and the first reload occurs that the metrics are available.
ctx := context.Background()
err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 120*time.Second, true, func(ctx context.Context) (bool, error) {
data, err := restClient.Get().AbsPath("/metrics").DoRaw(ctx)
if err != nil {
return true, err