mirror of https://github.com/k3s-io/k3s
Retry startup snapshot reconcile
The reconcile may run before the kubelet has created the node object; retry until it succeeds Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/9395/head
parent
4005600d4e
commit
82e3c32c9f
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/k3s-io/k3s/pkg/clientaccess"
|
"github.com/k3s-io/k3s/pkg/clientaccess"
|
||||||
"github.com/k3s-io/k3s/pkg/cluster/managed"
|
"github.com/k3s-io/k3s/pkg/cluster/managed"
|
||||||
|
@ -13,6 +14,7 @@ import (
|
||||||
"github.com/k3s-io/kine/pkg/endpoint"
|
"github.com/k3s-io/kine/pkg/endpoint"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilsnet "k8s.io/utils/net"
|
utilsnet "k8s.io/utils/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -107,11 +109,14 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.config.EtcdDisableSnapshots {
|
if !c.config.EtcdDisableSnapshots {
|
||||||
if err := c.managedDB.ReconcileSnapshotData(ctx); err != nil {
|
wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) {
|
||||||
logrus.Errorf("Failed to record snapshots for cluster: %v", err)
|
err := c.managedDB.ReconcileSnapshotData(ctx)
|
||||||
}
|
if err != nil {
|
||||||
|
logrus.Errorf("Failed to record snapshots for cluster: %v", err)
|
||||||
|
}
|
||||||
|
return err == nil, nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
runtime.Gosched()
|
runtime.Gosched()
|
||||||
|
|
Loading…
Reference in New Issue