Commit Graph

23 Commits

Author SHA1 Message Date
Dan McGee
c0bf9e2066 Remove custom utc_now() function, use django.utils.timezone.now()
This was around from the time when we handled timezones sanely and
Django did not; now that we are on 1.4 we no longer need our own code to
handle this.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-24 19:57:20 -05:00
Dan McGee
3c4ceb1633 mirrorcheck: Don't use bulk_create on sqlite3
It isn't worth it, as we run into the 999 max SQL statement variables
issue when using it on any significant amount of mirrors. Since this is
just a development database setup, and it isn't a command we need to run
especially fast, we can ditch it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-08 21:08:04 -05:00
Dan McGee
a87da032cb Handle HTTPException being thrown in mirrorcheck
Managed to see this bubble up today when running the mirrorcheck command
on a less than ideal connection that was experiencing timeouts at the
wrong time.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-08 21:07:04 -05:00
Dan McGee
2f7d770b26 Add rsync support to mirrorcheck and other small improvements
The main changes in this patch implement rsync:// protocol checking
support by calling the rsync binary, requested in FS#29878. We track and
log much of the same things as we already do for FTP and HTTP URLs-
check time, last sync, total check duration, etc.

Also added in this patch is a configurable timeout value which defaults
to the previous hardcoded value of 10 seconds; this can be passed as an
option to the mirrorcheck command.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-13 20:19:03 -05:00
Dan McGee
44eb2d5ee0 Use a custom User-Agent when checking mirror URLs
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29 21:26:23 -05:00
Dan McGee
8d21e9f4b1 mirrorresolv: only run update query if values changed
98% of the time, we won't need to update the existing values as it will
be the same as the prior run of this command. Do a quick check of the
old and new values and don't send anything to the database if there is
no need for an update.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-28 18:25:37 -05:00
Dan McGee
fd1c992472 Use bulk_create() when inserting mirror log entries
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-24 17:21:09 -05:00
Dan McGee
90e08b4863 Make all datetime objects fully timezone aware
This is most of the transition to Django 1.4 `USE_TZ = True`. We need to
ensure we don't mix aware and non-aware datetime objects when dealing
with datetimes in the code. Add a utc_now() helper method that we can
use most places, and ensure there is always a timezone attached when
necessary.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-23 19:54:40 -05:00
Dan McGee
110c79ad06 Small Python convention fixup
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-16 14:23:57 -05:00
Dan McGee
5fe626c6cc Management command cleanup
Now that we aren't seeing odd segfaults and hung tasks, we can remove
the traceback stuff from the scripts. Also use the 'io' module only, it
has been long enough.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 16:17:42 -05:00
Dan McGee
1b91de9435 mirrors: pylint discovered cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-18 15:10:20 -05:00
Dan McGee
1e3191ff56 Never parse generated lastsync file
We should be encouraging our mirrors to serve us the original file, not
something they create and come up with.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-18 14:49:28 -05:00
Dan McGee
6d5909ca5d Auto-resolve mirror URLs on save
This prevents people from having to mess with these checkboxes at all in
the admin, and we incur no delay on their initial values being correct
waiting for the cron job to run.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-27 12:44:30 -06:00
Dan McGee
fc7fc1d10a Slight tweaks to mirror commands
We know we are doing updates when setting IPv4/IPv6 information, so set
force_update to True to save the useless select query on each save(). For
mirror checks, use a less cumbersome deque for the results since it is also
thread-safe, and have all the log entries committed in one go.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-22 15:43:48 -06:00
Dan McGee
0bb5e9fd6d Defer format string substitution to logger
Don't use 'fmtstr % (arg1, arg2)' type format; logger can be passed a format
string and the arguments to populate it. Saves a bit of work for strings
that never end up getting displayed anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 15:10:48 -06:00
Dan McGee
7a320edae1 Move database interaction out of the threaded section
We were seeing a lot of hangs and long-running never-ending processes. This
might be due to some multithreading issues within Django, so move the save()
calls to a loop after the join() on the threads doing the mirror polling.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 13:40:01 -06:00
Dan McGee
fe5e460d06 Mirror check script cleanup
Don't import all the constants from logging, just use logging.* instead.
Also, fix some typos that somehow snuck into one of my commits.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-13 18:44:17 -05:00
PyroPeter
28cc96af28 Add mirrorresolv manage.py command
Dan:
* Fix up some style issues such as spacing between operators
* Ensure one failed lookup doesn't crash the whole script
* Be silent out of the box if there are no errors, just like mirrorcheck

Signed-off-by: PyroPeter <abi1789@googlemail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-13 18:42:51 -05:00
Dan McGee
e2612ab3f6 mirrorcheck: catch and handle another socket timeout case
We were seeing processes hang on the Arch server. It looks like there are
ways for socket.timeout to come out of the main check code, so add another
except block to catch this case. In addition, make sure we always call
task_done() even on failures so processes eventually die.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-11 20:49:04 -05:00
Dan McGee
2e299273e2 mirrorcheck: record duration on file not found errors
On an HTTP 404, FTP 550, or inability to parse the lastsync file, record the
duration of the check even though we couldn't get a time from the mirror.
This allows for these checks to show up as completed but in error, which is
more what.

Previously, inability to parse the date was also recorded as a success, so
change that to be a failure and record an error message with it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-07 08:07:03 -05:00
Dan McGee
b8a78408ff Small updates to mirrorcheck command
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-09-21 17:29:45 -05:00
Dan McGee
1f44788e1e Add debugger when having to parse lastsync file
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-09-21 09:10:33 -05:00
Dan McGee
3d8bc07622 Add 'mirrorcheck' command
This does the actual work of going out and checking the mirror status. In
short, it polls every active mirror URL for the 'lastsync' file and then
records the appropriate details. These include the contents of that file,
how long the total time to retrieve took, and any errors encountered.

In order to finish up a bit faster, we spawn several threads to do the
actual work. This parallelization allows the whole check process to take
around 30 seconds rather than several minutes.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-09-21 09:10:33 -05:00