Przeglądaj źródła

libnetwork/datastore: drop (KVObject).DataScope()

It wasn't being used for anything meaningful.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 1 rok temu
rodzic
commit
4039b9c9c4

+ 0 - 2
libnetwork/datastore/datastore.go

@@ -41,8 +41,6 @@ type KVObject interface {
 	// Exists returns true if the object exists in the datastore, false if it hasn't been stored yet.
 	// When SetIndex() is called, the object has been stored.
 	Exists() bool
-	// DataScope indicates the storage scope of the KV object
-	DataScope() string
 	// Skip provides a way for a KV Object to avoid persisting it in the KV Store
 	Skip() bool
 	// New returns a new object which is created based on the

+ 0 - 5
libnetwork/datastore/datastore_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/docker/docker/libnetwork/options"
-	"github.com/docker/docker/libnetwork/scope"
 	"gotest.tools/v3/assert"
 	is "gotest.tools/v3/assert/cmp"
 )
@@ -133,10 +132,6 @@ func (n *dummyObject) Skip() bool {
 	return n.SkipSave
 }
 
-func (n *dummyObject) DataScope() string {
-	return scope.Local
-}
-
 func (n *dummyObject) MarshalJSON() ([]byte, error) {
 	return json.Marshal(map[string]interface{}{
 		"name":        n.Name,

+ 0 - 9
libnetwork/drivers/bridge/bridge_store.go

@@ -12,7 +12,6 @@ import (
 	"github.com/docker/docker/libnetwork/datastore"
 	"github.com/docker/docker/libnetwork/discoverapi"
 	"github.com/docker/docker/libnetwork/netlabel"
-	"github.com/docker/docker/libnetwork/scope"
 	"github.com/docker/docker/libnetwork/types"
 )
 
@@ -267,10 +266,6 @@ func (ncfg *networkConfiguration) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (ncfg *networkConfiguration) DataScope() string {
-	return scope.Local
-}
-
 func (ep *bridgeEndpoint) MarshalJSON() ([]byte, error) {
 	epMap := make(map[string]interface{})
 	epMap["id"] = ep.id
@@ -384,10 +379,6 @@ func (ep *bridgeEndpoint) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (ep *bridgeEndpoint) DataScope() string {
-	return scope.Local
-}
-
 func (n *bridgeNetwork) restorePortAllocations(ep *bridgeEndpoint) {
 	if ep.extConnConfig == nil ||
 		ep.extConnConfig.ExposedPorts == nil ||

+ 0 - 9
libnetwork/drivers/ipvlan/ipvlan_store.go

@@ -12,7 +12,6 @@ import (
 	"github.com/docker/docker/libnetwork/datastore"
 	"github.com/docker/docker/libnetwork/discoverapi"
 	"github.com/docker/docker/libnetwork/netlabel"
-	"github.com/docker/docker/libnetwork/scope"
 	"github.com/docker/docker/libnetwork/types"
 )
 
@@ -258,10 +257,6 @@ func (config *configuration) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (config *configuration) DataScope() string {
-	return scope.Local
-}
-
 func (ep *endpoint) MarshalJSON() ([]byte, error) {
 	epMap := make(map[string]interface{})
 	epMap["id"] = ep.id
@@ -357,7 +352,3 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error {
 	*dstEp = *ep
 	return nil
 }
-
-func (ep *endpoint) DataScope() string {
-	return scope.Local
-}

+ 0 - 9
libnetwork/drivers/macvlan/macvlan_store.go

@@ -12,7 +12,6 @@ import (
 	"github.com/docker/docker/libnetwork/datastore"
 	"github.com/docker/docker/libnetwork/discoverapi"
 	"github.com/docker/docker/libnetwork/netlabel"
-	"github.com/docker/docker/libnetwork/scope"
 	"github.com/docker/docker/libnetwork/types"
 )
 
@@ -252,10 +251,6 @@ func (config *configuration) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (config *configuration) DataScope() string {
-	return scope.Local
-}
-
 func (ep *endpoint) MarshalJSON() ([]byte, error) {
 	epMap := make(map[string]interface{})
 	epMap["id"] = ep.id
@@ -351,7 +346,3 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error {
 	*dstEp = *ep
 	return nil
 }
-
-func (ep *endpoint) DataScope() string {
-	return scope.Local
-}

+ 0 - 9
libnetwork/drivers/windows/windows_store.go

@@ -12,7 +12,6 @@ import (
 	"github.com/docker/docker/libnetwork/datastore"
 	"github.com/docker/docker/libnetwork/discoverapi"
 	"github.com/docker/docker/libnetwork/netlabel"
-	"github.com/docker/docker/libnetwork/scope"
 	"github.com/docker/docker/libnetwork/types"
 )
 
@@ -221,10 +220,6 @@ func (ncfg *networkConfiguration) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (ncfg *networkConfiguration) DataScope() string {
-	return scope.Local
-}
-
 func (ep *hnsEndpoint) MarshalJSON() ([]byte, error) {
 	epMap := make(map[string]interface{})
 	epMap["id"] = ep.id
@@ -333,7 +328,3 @@ func (ep *hnsEndpoint) CopyTo(o datastore.KVObject) error {
 	*dstEp = *ep
 	return nil
 }
-
-func (ep *hnsEndpoint) DataScope() string {
-	return scope.Local
-}

+ 0 - 4
libnetwork/endpoint.go

@@ -1031,10 +1031,6 @@ func JoinOptionPriority(prio int) EndpointOption {
 	}
 }
 
-func (ep *Endpoint) DataScope() string {
-	return ep.getNetwork().DataScope()
-}
-
 func (ep *Endpoint) assignAddress(ipam ipamapi.Ipam, assignIPv4, assignIPv6 bool) error {
 	var err error
 

+ 2 - 6
libnetwork/endpoint_cnt.go

@@ -97,10 +97,6 @@ func (ec *endpointCnt) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (ec *endpointCnt) DataScope() string {
-	return ec.n.DataScope()
-}
-
 func (ec *endpointCnt) EndpointCnt() uint64 {
 	ec.Lock()
 	defer ec.Unlock()
@@ -111,7 +107,7 @@ func (ec *endpointCnt) EndpointCnt() uint64 {
 func (ec *endpointCnt) updateStore() error {
 	store := ec.n.getController().getStore()
 	if store == nil {
-		return fmt.Errorf("store not found for scope %s on endpoint count update", ec.DataScope())
+		return fmt.Errorf("store not found on endpoint count update")
 	}
 	// make a copy of count and n to avoid being overwritten by store.GetObject
 	count := ec.EndpointCnt()
@@ -140,7 +136,7 @@ func (ec *endpointCnt) setCnt(cnt uint64) error {
 func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
 	store := ec.n.getController().getStore()
 	if store == nil {
-		return fmt.Errorf("store not found for scope %s", ec.DataScope())
+		return fmt.Errorf("store not found on endpoint count atomic inc/dec")
 	}
 
 	tmp := &endpointCnt{n: ec.n}

+ 1 - 10
libnetwork/network.go

@@ -510,15 +510,6 @@ func (n *Network) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (n *Network) DataScope() string {
-	s := n.Scope()
-	// All swarm scope networks have local datascope
-	if s == scope.Swarm {
-		s = scope.Local
-	}
-	return s
-}
-
 func (n *Network) getEpCnt() *endpointCnt {
 	n.mu.Lock()
 	defer n.mu.Unlock()
@@ -1768,7 +1759,7 @@ func (n *Network) deriveAddressSpace() (string, error) {
 	if err != nil {
 		return "", types.NotFoundErrorf("failed to get default address space: %v", err)
 	}
-	if n.DataScope() == scope.Global {
+	if n.Scope() == scope.Global {
 		return global, nil
 	}
 	return local, nil

+ 0 - 5
libnetwork/sandbox_store.go

@@ -9,7 +9,6 @@ import (
 	"github.com/containerd/log"
 	"github.com/docker/docker/libnetwork/datastore"
 	"github.com/docker/docker/libnetwork/osl"
-	"github.com/docker/docker/libnetwork/scope"
 )
 
 const (
@@ -122,10 +121,6 @@ func (sbs *sbState) CopyTo(o datastore.KVObject) error {
 	return nil
 }
 
-func (sbs *sbState) DataScope() string {
-	return scope.Local
-}
-
 func (sb *Sandbox) storeUpdate() error {
 	sbs := &sbState{
 		c:          sb.controller,