mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #3510 from briandowns/backport_issue-3414_release_1.21
[Backport 1.21] - fix possible race where bootstrap data might not save
This commit is contained in:
commit
34d767d40e
@ -3,6 +3,7 @@ package cluster
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/k3s-io/kine/pkg/endpoint"
|
||||
@ -102,15 +103,22 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
|
||||
// snapshots will be empty.
|
||||
if c.managedDB != nil {
|
||||
go func() {
|
||||
for range ready {
|
||||
for {
|
||||
select {
|
||||
case <-ready:
|
||||
if err := c.save(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.managedDB.StoreSnapshotData(ctx); err != nil {
|
||||
logrus.Errorf("Failed to record snapshots for cluster: %v", err)
|
||||
}
|
||||
|
||||
return
|
||||
default:
|
||||
runtime.Gosched()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user