Merge lp:~pfalcon/linaro-android-mirror/per-host-config into lp:linaro-android-mirror
Proposed by
Paul Sokolovsky
Status: | Merged |
---|---|
Merged at revision: | 46 |
Proposed branch: | lp:~pfalcon/linaro-android-mirror/per-host-config |
Merge into: | lp:linaro-android-mirror |
Diff against target: |
91 lines (+39/-4) 2 files modified
linaro_android_mirror/mirrorer.py (+29/-3) linaro_android_mirror/settings.py (+10/-1) |
To merge this branch: | bzr merge lp:~pfalcon/linaro-android-mirror/per-host-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guilherme Salgado (community) | Approve | ||
Review via email: mp+63336@code.launchpad.net |
Description of the change
This patch allows to specify individual configuration for each upstream git host we mirror. Currently implemented setting for stale check (don't sync with host if was synced recently enough) and number of concurrent sync jobs (-jN).
This should alleviate issues which were seen/reported with mirror service during last week:
* git.omapzoom.org needs -j1 to sync reliably, but forcing all hosts to -j1 does affect mirroring performance (Patrik Ryd)
* yesterday, android.
To post a comment you must log in.
Hi Paul,
This looks good to me; I've just a couple suggestions below.
review approve
> === modified file 'linaro_ android_ mirror/ mirrorer. py' android_ mirror/ mirrorer. py 2011-06-02 13:34:21 +0000 android_ mirror/ mirrorer. py 2011-06-03 07:52:34 +0000 internet. defer import ( DeferredLock) status( data, target_directory): status( data, host_config): cmd_status: ", data join(settings. MIRROR_ PREFIX, host_config[ "host"] ) 'manifests' ) 'manifests. git') UPSTREAM_ HOSTS: UPSTREAM_ HOSTS[hostname] UPSTREAM_ HOSTS[" *"]
> --- linaro_
> +++ linaro_
> @@ -1,6 +1,7 @@
> from collections import defaultdict
> import errno
> import os
> +import time
>
> from twisted.
> Deferred,
> @@ -19,9 +20,10 @@
>
> _directory_locks = defaultdict(
>
> -def check_cmd_
> +def check_cmd_
> # print "check_
> stdout, stderr, exitcode = data
> + target_directory = os.path.
> if exitcode != 0:
> log.msg("error executing command: stdout: '%s', stderr: '%s', exitcode: %d" % (stdout, stderr, exitcode))
> raise Exception(stderr)
> @@ -46,6 +48,26 @@
> symlink(
> symlink(
> symlink('repo')
> +
> + if hostname in settings.
> + host_config = settings.
> + else:
> + host_config = settings.
> + host_config["host"] = hostname
I'm slightly concerned about the fact that this is a long-running settings. UPSTREAM_ HOSTS[hostname| "*"])) and passing that on to
process changing a mutable setting. I see that the host will be
overwritten every time this function gets called, so it shouldn't be a
problem, but we might have problems if the recipient of host_config
decides to change it further. We can easily avoid that by making a copy
of the host config (e.g.
copy.copy(
the callback.
> + join(target_ directory, '.synced') stamp). st_mtime get("stale" , 0): get("stale" , 0))) join(target_ directory, '.repo/ manifest. xml') manifest_ path) file.write( manifest) REPO_SYNC_ EXTRA_ARGS REPO_SYNC_ EXTRA_ARGS + ['-j%d' % host_config. get("jobs" , 1)]
> + # Get last successful sync timestamp
> + stamp = os.path.
> + try:
> + stamp_mtime = os.stat(
> + except OSError:
> + stamp_mtime = 0
> +
> + # Check for fresh enough
> + if time.time() - stamp_mtime < host_config.
> + log.msg("Mirror %s was synced %ds ago, stale threshold (%ds) not reached" %
> + (target_directory, time.time() - stamp_mtime, host_config.
> + return
> +
> manifest_path = os.path.
> try:
> os.unlink(
> @@ -54,7 +76,7 @@
> raise
> with open(manifest_path, 'w') as manifest_file:
> manifest_
> - args = ['sync'] + settings.
> + args = ['sync'] + settings.
Is it worth allowing host configs to not specify the number of jobs to
use? I'm thinking that it may be better to make it required instead of
providing a default that is far from ideal.
> print "running", settings.REPO, args, 'in', target_directory tAndValue(
> if settings.DRY_RUN:
> d = Deferred()
> @@ -62,7 +84,7 @@
> else:
> d = getProcessOutpu
> ...