mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:37:08 +00:00
Do not run tasks if required mounts are not present.
A configuration item `imports.mounts` is added to `etc/config.yaml`. This should be a list of paths which must be non-empty. If any of the paths in that list is empty, runner.sh will abort. Closes #200.
This commit is contained in:
27
bin/check_mounts_present.py
Executable file
27
bin/check_mounts_present.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
Check if any of the directories provided in the imports.mounts configuration
|
||||||
|
section are empty.
|
||||||
|
|
||||||
|
Returns 0 if all arguments are non-empty, 1 otherwise. It stops at the first
|
||||||
|
empty directory.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import configuration
|
||||||
|
|
||||||
|
cfg = configuration.read()
|
||||||
|
|
||||||
|
if cfg and "imports" in cfg and "mounts" in cfg["imports"]:
|
||||||
|
|
||||||
|
mounts = cfg["imports"]["mounts"]
|
||||||
|
for item in mounts:
|
||||||
|
with os.scandir(item) as contents:
|
||||||
|
if not any(contents):
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("No mounts in configuration")
|
||||||
|
|
||||||
|
exit(0)
|
||||||
@@ -107,6 +107,12 @@ echo "$$" > "$LOCKFILE" || {
|
|||||||
}
|
}
|
||||||
print_info "Start run"
|
print_info "Start run"
|
||||||
|
|
||||||
|
print_log "Check if data is accessible"
|
||||||
|
$BINDIR/check_mounts_present.py || {
|
||||||
|
print_warning "Import mounts not accessible. Inhibiting all tasks!"
|
||||||
|
exit 253
|
||||||
|
}
|
||||||
|
|
||||||
print_log "Purge deleted files"
|
print_log "Purge deleted files"
|
||||||
run $BINDIR/purge_deleted_files.py
|
run $BINDIR/purge_deleted_files.py
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ imports:
|
|||||||
# least this many seconds ago.
|
# least this many seconds ago.
|
||||||
file_min_age: 60
|
file_min_age: 60
|
||||||
|
|
||||||
|
# These paths refer to remote mounts which must be present in order
|
||||||
|
# for imports to work. If any of these paths are empty, import actions
|
||||||
|
# (including data deletion) will be inhibited. This is to cope with
|
||||||
|
# things like transient network failures.
|
||||||
|
mounts:
|
||||||
|
- /srv/mnt/Data
|
||||||
|
|
||||||
queues:
|
queues:
|
||||||
asaqc:
|
asaqc:
|
||||||
request:
|
request:
|
||||||
|
|||||||
Reference in New Issue
Block a user