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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user