mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-10-10 12:20:58 +00:00
Get swarm nodes + robust fallback
This commit is contained in:
@@ -37,6 +37,18 @@ def list_containers() -> List[dict]:
|
|||||||
return [c.attrs for c in all_containers]
|
return [c.attrs for c in all_containers]
|
||||||
|
|
||||||
|
|
||||||
|
def get_swarm_nodes():
|
||||||
|
client = docker_client()
|
||||||
|
# NOTE: If not a swarm node docker.errors.APIError is raised
|
||||||
|
# 503 Server Error: Service Unavailable
|
||||||
|
# ("This node is not a swarm manager. Use "docker swarm init" or
|
||||||
|
# "docker swarm join" to connect this node to swarm and try again.")
|
||||||
|
try:
|
||||||
|
return client.nodes.list()
|
||||||
|
except docker.errors.APIError:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def remove_containers(containers: List['Container']):
|
def remove_containers(containers: List['Container']):
|
||||||
client = docker_client()
|
client = docker_client()
|
||||||
logger.info('Attempting to delete stale backup process containers')
|
logger.info('Attempting to delete stale backup process containers')
|
||||||
|
Reference in New Issue
Block a user