Merge pull request #32169 from thaJeztah/fix-non-swarm-prune

Fix docker system prune failing with Swarm mode disabled
Upstream-commit: c7c7f36da7fbdaaee97b21c9174872e32fa4e037
Component: engine
This commit is contained in:
Brian Goff
2017-03-28 14:07:25 -04:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,18 @@ import (
// Cluster is the interface for github.com/docker/docker/daemon/cluster.(*Cluster).
type Cluster interface {
ClusterStatus
NetworkManager
}
// ClusterStatus interface provides information about the Swarm status of the Cluster
type ClusterStatus interface {
IsAgent() bool
IsManager() bool
}
// NetworkManager provides methods to manage networks
type NetworkManager interface {
GetNetwork(input string) (apitypes.NetworkResource, error)
GetNetworks() ([]apitypes.NetworkResource, error)
RemoveNetwork(input string) error

View File

@ -225,6 +225,11 @@ func (daemon *Daemon) clusterNetworksPrune(pruneFilters filters.Args) (*types.Ne
until, _ := getUntilFromPruneFilters(pruneFilters)
cluster := daemon.GetCluster()
if !cluster.IsManager() {
return rep, nil
}
networks, err := cluster.GetNetworks()
if err != nil {
return rep, err