1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 19:25:44 +00:00

lock to avoid concurrent map writes

This commit is contained in:
kinarashah 2020-02-28 14:11:09 -08:00
parent 02bab32a40
commit 18f42726b0

View File

@ -7,6 +7,7 @@ import (
"net/http"
"os"
"strings"
"sync"
"time"
"github.com/sirupsen/logrus"
@ -36,9 +37,12 @@ var (
c = http.Client{
Timeout: time.Second * 30,
}
kdmMutex = sync.Mutex{}
)
func InitMetadata(ctx context.Context) error {
kdmMutex.Lock()
defer kdmMutex.Unlock()
data, err := loadData()
if err != nil {
return fmt.Errorf("failed to load data.json, error: %v", err)