mirror of https://github.com/k3s-io/k3s
Merge pull request #3413 from briandowns/possible_race_condition
fix possible race where bootstrap data might not savepull/3417/head
commit
bd84012061
|
@ -3,6 +3,7 @@ package cluster
|
|||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/k3s-io/kine/pkg/endpoint"
|
||||
|
@ -102,14 +103,21 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) {
|
|||
// snapshots will be empty.
|
||||
if c.managedDB != nil {
|
||||
go func() {
|
||||
for range ready {
|
||||
if err := c.save(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
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)
|
||||
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