mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #32169 from thaJeztah/fix-non-swarm-prune
Fix docker system prune failing with Swarm mode disabled
This commit is contained in:
commit
c7c7f36da7
2 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue