Browse Source

Removing boltdb timeout

Now that libkv supports concurrent access to boltdb, there is no point
in depending on timeout mechanism

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Madhu Venugopal 9 years ago
parent
commit
9c2541b774
2 changed files with 7 additions and 13 deletions
  1. 1 3
      libnetwork/datastore/datastore.go
  2. 6 10
      libnetwork/store_test.go

+ 1 - 3
libnetwork/datastore/datastore.go

@@ -6,7 +6,6 @@ import (
 	"reflect"
 	"strings"
 	"sync"
-	"time"
 
 	"github.com/docker/libkv"
 	"github.com/docker/libkv/store"
@@ -141,8 +140,7 @@ func makeDefaultScopes() map[string]*ScopeCfg {
 			Provider: "boltdb",
 			Address:  defaultPrefix + "/boltdb.db",
 			Config: &store.Config{
-				Bucket:            "libnetwork",
-				ConnectionTimeout: 3 * time.Second,
+				Bucket: "libnetwork",
 			},
 		},
 	}

+ 6 - 10
libnetwork/store_test.go

@@ -5,7 +5,6 @@ import (
 	"io/ioutil"
 	"os"
 	"testing"
-	"time"
 
 	"github.com/docker/libkv/store"
 	"github.com/docker/libnetwork/config"
@@ -36,7 +35,7 @@ func TestBoltdbBackend(t *testing.T) {
 	defer os.Remove(datastore.DefaultScopes("")[datastore.LocalScope].Client.Address)
 	testLocalBackend(t, "", "", nil)
 	defer os.Remove("/tmp/boltdb.db")
-	config := &store.Config{Bucket: "testBackend", ConnectionTimeout: 3 * time.Second}
+	config := &store.Config{Bucket: "testBackend"}
 	testLocalBackend(t, "boltdb", "/tmp/boltdb.db", config)
 
 }
@@ -130,12 +129,12 @@ func OptionBoltdbWithRandomDBFile() ([]config.Option, error) {
 	cfgOptions := []config.Option{}
 	cfgOptions = append(cfgOptions, config.OptionLocalKVProvider("boltdb"))
 	cfgOptions = append(cfgOptions, config.OptionLocalKVProviderURL(tmp.Name()))
-	sCfg := &store.Config{Bucket: "testBackend", ConnectionTimeout: 3 * time.Second}
+	sCfg := &store.Config{Bucket: "testBackend"}
 	cfgOptions = append(cfgOptions, config.OptionLocalKVProviderConfig(sCfg))
 	return cfgOptions, nil
 }
 
-func TestLocalStoreLockTimeout(t *testing.T) {
+func TestMultipleControllersWithSameStore(t *testing.T) {
 	cfgOptions, err := OptionBoltdbWithRandomDBFile()
 	if err != nil {
 		t.Fatalf("Error getting random boltdb configs %v", err)
@@ -146,11 +145,8 @@ func TestLocalStoreLockTimeout(t *testing.T) {
 	}
 	defer ctrl1.Stop()
 	// Use the same boltdb file without closing the previous controller
-	// with a slightly altered configuration
-	sCfg := &store.Config{Bucket: "testBackend", ConnectionTimeout: 1 * time.Second}
-	_, err = New(append(cfgOptions[:len(cfgOptions)-1],
-		config.OptionLocalKVProviderConfig(sCfg))...)
-	if err == nil {
-		t.Fatalf("Expected to fail but succeeded")
+	_, err = New(cfgOptions...)
+	if err != nil {
+		t.Fatalf("Local store must support concurrent controllers")
 	}
 }