Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local archive mode (fixes #6) #88

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fbca19a
local/remote switch for rsync
jkbecker Apr 2, 2021
a39f39a
fix local rsync dest
jkbecker Apr 2, 2021
fc7ea41
add notes to config.yaml
jkbecker Apr 2, 2021
f3281d6
Merge branch 'development' of github.com:ericaltendorf/plotman into a…
jkbecker Apr 2, 2021
ad86f13
Merge branch 'setup' into archivelocal
jkbecker Apr 4, 2021
715267b
Merge branch 'setup' of github.com:jkbecker/plotman into archivelocal
jkbecker Apr 5, 2021
6882e10
Merge branch 'development' of github.com:jkbecker/plotman into archiv…
jkbecker Apr 7, 2021
829661c
Update config.yaml
jkbecker Apr 7, 2021
aae3654
Update src/plotman/archive.py
jkbecker Apr 7, 2021
9f205df
Merge branch 'development' of github.com:ericaltendorf/plotman into a…
jkbecker Apr 28, 2021
c570f7c
Merge branch 'archivelocal' of github.com:jkbecker/plotman into archi…
jkbecker Apr 28, 2021
c7d8ce2
adapt config template
jkbecker Apr 28, 2021
68b683f
adapt error message
jkbecker Apr 28, 2021
9d5ae8a
doc fix
jkbecker Apr 28, 2021
2d917fa
whitespace, defaults
jkbecker Apr 28, 2021
43ead3d
Update src/plotman/configuration.py
jkbecker Apr 28, 2021
4aee539
Merge branch 'development' into archivelocal
altendky Apr 28, 2021
194dc6d
Update src/plotman/configuration.py
jkbecker Apr 29, 2021
c5d5ad6
Update src/plotman/archive.py
jkbecker Apr 29, 2021
59de0c6
Update src/plotman/archive.py
altendky Apr 29, 2021
7f15c43
Merge branch 'development' of github.com:ericaltendorf/plotman into a…
jkbecker May 8, 2021
11d06a7
new config file format supporting local archive mode
jkbecker May 8, 2021
6df447e
prepare for legacy vs extendable new configs
jkbecker May 8, 2021
b97c385
merging
jkbecker May 8, 2021
4c92cb1
better example value for local mode
jkbecker May 8, 2021
57ebfe5
some archive tests
jkbecker May 8, 2021
160b3f9
rsync_dest -> arch_dest refactoring
jkbecker May 8, 2021
fff7c22
Merge branch 'development' into archivelocal
altendky May 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/plotman/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ def compute_priority(phase, gb_free, n_plots):

def get_archdir_freebytes(arch_cfg):
archdir_freebytes = {}
df_cmd = ('ssh %s@%s df -aBK | grep " %s/"' %
(arch_cfg.rsyncd_user, arch_cfg.rsyncd_host, arch_cfg.rsyncd_path) )
if arch_cfg.mode == 'remote':
df_cmd = ('ssh %s@%s df -aBK | grep " %s/"' %
(arch_cfg.rsyncd_user, arch_cfg.rsyncd_host, arch_cfg.rsyncd_path) )
elif arch_cfg.mode == 'local':
df_cmd = ('df -BK | grep " %s/"' % arch_cfg.rsyncd_path )
jkbecker marked this conversation as resolved.
Show resolved Hide resolved
else:
raise KeyError(f'Archive mode must be "remote" or "local" ({arch_cfg.mode!r} given). Please inspect plotman.yaml.')
with subprocess.Popen(df_cmd, shell=True, stdout=subprocess.PIPE) as proc:
for line in proc.stdout.readlines():
fields = line.split()
Expand All @@ -91,11 +96,16 @@ def get_archdir_freebytes(arch_cfg):
return archdir_freebytes

def rsync_dest(arch_cfg, arch_dir):
rsync_path = arch_dir.replace(arch_cfg.rsyncd_path, arch_cfg.rsyncd_module)
if rsync_path.startswith('/'):
rsync_path = rsync_path[1:] # Avoid dup slashes. TODO use path join?
rsync_url = 'rsync://%s@%s:12000/%s' % (
arch_cfg.rsyncd_user, arch_cfg.rsyncd_host, rsync_path)
if arch_cfg.mode == 'remote':
rsync_path = arch_dir.replace(arch_cfg.rsyncd_path, arch_cfg.rsyncd_module)
if rsync_path.startswith('/'):
rsync_path = rsync_path[1:] # Avoid dup slashes. TODO use path join?
rsync_url = 'rsync://%s@%s:12000/%s' % (
arch_cfg.rsyncd_user, arch_cfg.rsyncd_host, rsync_path)
elif arch_cfg.mode == 'local':
rsync_url = arch_dir
else:
raise KeyError(f'Archive mode must be "remote" or "local" ("{arch_cfg.mode!r}" given). Please inspect plotman.yaml.')
return rsync_url

# TODO: maybe consolidate with similar code in job.py?
Expand Down
1 change: 1 addition & 0 deletions src/plotman/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Archive:
rsyncd_host: str
rsyncd_user: str
index: int = 0 # If not explicit, "index" will default to 0
mode: str = 'remote'
jkbecker marked this conversation as resolved.
Show resolved Hide resolved

@dataclass
class TmpOverrides:
Expand Down
12 changes: 11 additions & 1 deletion src/plotman/resources/plotman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ directories:
# have four plotters, you could set this to 0, 1, 2, and 3, on
# the 4 machines, or 0, 1, 0, 1.
# index: 0

# Optional switch to enable local archiving (defaults to remote if absent).
# Note: rsyncd_module, rsyncd_host and rsyncd_user are ignored in local mode.
# mode: remote # remote or local
# Note for local mode:
# The rsyncd_path should be the directory *in which* your archive
# disks are mounted. For example, if your archive disks are
# /mnt/archive1 and /mnt/archive2, the path should be /mnt.
# Note that *all* mounted drives within that path will be
# considered - so if you have other things mounted as well,
# make sure you mount all Chia archive drives to some custom
# directory that only contains Chia archive mountpoints.

# Plotting scheduling parameters
scheduling:
Expand Down