diff --git a/libnetwork/sandbox_test.go b/libnetwork/sandbox_test.go index 2c8bcf86a5..6ce245d767 100644 --- a/libnetwork/sandbox_test.go +++ b/libnetwork/sandbox_test.go @@ -10,11 +10,7 @@ import ( "github.com/docker/libnetwork/testutils" ) -func createEmptyCtrlr() *controller { - return &controller{sandboxes: sandboxTable{}} -} - -func getTestEnv(t *testing.T) (NetworkController, Network, Network) { +func getTestEnv(t *testing.T, empty bool) (NetworkController, Network, Network) { netType := "bridge" option := options.Generic{ @@ -32,6 +28,10 @@ func getTestEnv(t *testing.T) (NetworkController, Network, Network) { t.Fatal(err) } + if empty { + return c, nil, nil + } + name1 := "test_nw_1" netOption1 := options.Generic{ netlabel.GenericData: options.Generic{ @@ -58,7 +58,8 @@ func getTestEnv(t *testing.T) (NetworkController, Network, Network) { } func TestSandboxAddEmpty(t *testing.T) { - ctrlr := createEmptyCtrlr() + c, _, _ := getTestEnv(t, true) + ctrlr := c.(*controller) sbx, err := ctrlr.NewSandbox("sandbox0") if err != nil { @@ -81,7 +82,7 @@ func TestSandboxAddMultiPrio(t *testing.T) { defer testutils.SetupTestOSContext(t)() } - c, nw, _ := getTestEnv(t) + c, nw, _ := getTestEnv(t, false) ctrlr := c.(*controller) sbx, err := ctrlr.NewSandbox("sandbox1") @@ -162,7 +163,7 @@ func TestSandboxAddSamePrio(t *testing.T) { defer testutils.SetupTestOSContext(t)() } - c, nw1, nw2 := getTestEnv(t) + c, nw1, nw2 := getTestEnv(t, false) ctrlr := c.(*controller) diff --git a/libnetwork/store.go b/libnetwork/store.go index 4a40272a3e..714d56bd5a 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -221,8 +221,7 @@ func (n *network) getEndpointsFromStore() ([]*endpoint, error) { func (c *controller) updateToStore(kvObject datastore.KVObject) error { cs := c.getStore(kvObject.DataScope()) if cs == nil { - log.Warnf("datastore for scope %s not initialized. kv object %s is not added to the store", kvObject.DataScope(), datastore.Key(kvObject.Key()...)) - return nil + return fmt.Errorf("datastore for scope %q is not initialized ", kvObject.DataScope()) } if err := cs.PutObjectAtomic(kvObject); err != nil { @@ -238,8 +237,7 @@ func (c *controller) updateToStore(kvObject datastore.KVObject) error { func (c *controller) deleteFromStore(kvObject datastore.KVObject) error { cs := c.getStore(kvObject.DataScope()) if cs == nil { - log.Debugf("datastore for scope %s not initialized. kv object %s is not deleted from datastore", kvObject.DataScope(), datastore.Key(kvObject.Key()...)) - return nil + return fmt.Errorf("datastore for scope %q is not initialized ", kvObject.DataScope()) } retry: