Commit Graph

181 Commits

Author SHA1 Message Date
Dan McGee
945337177d Add last_modified column to mirrors
This will make it easier in the future to clear out inactive mirrors
that haven't been touched in a while.

Signed-off-by: Dan McGee <dan@archlinux.org>
2014-03-29 11:56:32 -05:00
Dan McGee
16b22e4bfc Upgrade django-countries to 2.0
Signed-off-by: Dan McGee <dan@archlinux.org>
2014-02-22 08:49:58 -06:00
Dan McGee
fe37b46c50 Add a 'last_modified' function for mirror status pages
We can use this on both the HTML and JSON views of this data to prevent
recomputation for smart clients that respect the modified date header.

Signed-off-by: Dan McGee <dan@archlinux.org>
2014-01-11 13:37:12 -06:00
Dan McGee
5eff1ab9bf Set all attributes to default values on status URL fetch
We were missing two duration-related attributes here, causing some 500
errors to happen if we had cached status_data around that didn't agree
with our current list of checked mirrors. Don't blow up on the JSON data
fetch by ensuring we provide a value, even if it is out of date.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-23 11:51:04 -06:00
Dan McGee
d80908e21e Change import location of django_countries fields
This will work with both the newer and older versions.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-23 09:44:11 -06:00
Dan McGee
77a45dc7bc Use select_related() in new mirror URL details view
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-15 13:33:50 -06:00
Dan McGee
79aef280dd Add mirror URL details page
This will allow those that care about mirrors to zoom into URL-level
details for each mirror and examine the individual check results.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-15 13:28:13 -06:00
Dan McGee
3c7b02753a Add delay function to MirrorLog model
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-15 13:21:04 -06:00
Dan McGee
bdfa22500f Use stable parameters for cacheable function
It doesn't do much good to mark a function as cacheable if we call it
every single time with different arguments due to using the current date
and time. Fix it by passing the offset in instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-14 17:10:52 -06:00
Dan McGee
a116f0d942 Add update query for extracting Flyspray bug number
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-14 11:24:57 -06:00
Dan McGee
d83e084205 Add Flyspray Bug field to mirror model
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-14 11:15:42 -06:00
Dan McGee
ecece25814 Show all mirror status data to authorized users
Regardless of whether the mirror URL is active or not, we often have
data we can show the end user, especially if mirror admins care to see
the data we've been gathering.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-12-14 10:53:04 -06:00
Dan McGee
9adc2e5312 Stop using Django-provided floatformat template tag
It turns out this is a HUGE part of our slow mirror status template
rendering, due to the internal workings. Everything is converted to a
Python decimal object which is way slower than just staying in native
floating point. Given we are always dealing with floats when we need to
do our formatting, a home-rolled template tag can accomplish this much
faster.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-11-27 17:53:37 -05:00
Dan McGee
ee6002c911 Django 1.6 upgrade, deprecation cleanup
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-11-06 21:17:27 -06:00
Dan McGee
3061d1c951 Django 1.6 upgrade, deprecation cleanup
PendingDeprecationWarning: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form needs updating

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-11-06 20:56:15 -06:00
Dan McGee
b667851385 Fix completion percentage calculation in mirror status
We sometimes record a duration even on a failed fetch attempt, such as
if we get an HTTP 404. However, we never record a last_sync value on a
failed fetch. Use this field instead to sum up the total number of
successful checks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-07-13 10:46:58 -05:00
Dan McGee
9e4a093914 Re-enable caching for somewhat expensive mirror status query
This should be a small enough chunk of data that it isn't super
expensive to put into and pull out of memcached.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-06-20 14:11:23 -05:00
Dan McGee
80d323c392 Guard logging operation to prevent needless text join
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-06-01 14:53:51 -05:00
Dan McGee
49bf498879 Ensure only active mirror URLs are listed
This fixes things up on the download page as well as the individual
mirror details page.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-06-01 14:53:17 -05:00
Dan McGee
31bc66e23c Whoops, committed a little bit too much
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-05-31 19:29:23 -05:00
Dan McGee
e50471b9a7 Honor mirror URL active attribute in several places
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-05-31 19:21:47 -05:00
Dan McGee
bbeb927605 Add active column to mirror URLs 2013-05-31 19:12:29 -05:00
Dan McGee
64a92174c0 Begin removal of FTP mirror support
FTP is a terrible protocol these days compared to HTTP. IPv6 support is
spotty at best, it is much slower for the connect/begin transfer cycle,
and overall just doesn't provide anything HTTP does better. Start
killing bits that we've added to treat FTP as a first-class protocol and
regulate it to the back seat.

The expectation here is once this commit goes live to the production
site, the FTP mirror URLs themselves will get removed completely from
the database, and the FTP protocol object itself will get deleted.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-05-21 20:24:55 -05:00
Dan McGee
8097a1fdef Add mirror error logs to mirror details page
Give a window of 7 days for logs here rather than the default 24 hours
we do on the main status page since we are only retrieving details for a
single mirror with a handful of URLs. This should make it easier to have
all information regarding one mirror in a single location.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-05-10 18:10:04 -05:00
Dan McGee
6de0cfbd23 Fix some None issues with sqlite3 and mirror status
If certain attributes came back from the database as NULL, we had issues
parsing them. Pass None/NULL straight through rather than trying to
type-convert.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-20 11:13:49 -05:00
Dan McGee
b7b2474064 Various minor code cleanups and fixes
Most of these were suggested by PyCharm, and include everything from
little syntax issues and other bad smells to dead or bad code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-16 22:12:01 -05:00
Dan McGee
0589853360 Remove COUNTRY_LOOKUP global variable
This is only used in one place, so it makes more sense for it to not be
globally accessible.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-16 21:52:20 -05:00
Dan McGee
4fd50fa622 Tweaks to mirror status chart generation
* Use 'jQuery' rather than '$'
* Use same colors for URLs in every chart for clarity

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-14 15:23:09 -05:00
Dan McGee
9b07cb1ebd Draw one mirror status graph per check location
Rather than lump it all together and have odd spikes depending on which
side of the Atlantic checked a mirror in a given timeslot, draw a chart
per check location.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-14 15:08:25 -05:00
Dan McGee
0cad22a5ec Add a JSON view for retrieving mirror check locations
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-14 13:59:49 -05:00
Dan McGee
f357a39a49 Remove cache_function decorator from a few spots
The benefit of these storage operations might be outweighed by the cost,
especially given how infrequently these functions are called.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-14 13:21:20 -05:00
Dan McGee
213aa3a2fa Reduce mirror status query madness
Move completely to custom SQL for this logic. The Django ORM just
doesn't play nice with the kind of query we are looking to do, so it is
easier to do using raw SQL.

The biggest pain factor here is in supporting sqlite as it doesn't have
nearly the capabilities in handling datetime types directly in the
database, as well as having some different type conversion necessities.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-14 13:12:13 -05:00
Dan McGee
c588d1c85f Support only a single mirror ID in error/status retrieval
This simplifies things and makes injecting this single mirror ID into
custom SQL a whole lot easier.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-13 11:41:35 -05:00
Dan McGee
2c24ee9100 Calculate average URL delay in the database
Rather than doing this in the Python code and needing 12,000+ rows
returned from the database, we can do it in the database and get fewer
than 300 rows back.

If I recall correctly, the reason this was not done originally was due
to our usage of MySQL and some really bad date math/overflow stuff it
did when the interval between last_sync and check_time were greater than
about a week. Luckily, we have switched to using a more sane database.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-13 11:41:33 -05:00
Dan McGee
06e1e857ab Allow mirror rsync IPs to be IPv4/IPv6 addresses or networks
This gives us a bunch more flexibility on this field, and now supports
all the options that the rsync config file supports.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-10 21:03:09 -05:00
Dan McGee
133d16f91f Add IP family lookup to CheckLocation model
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-29 15:51:50 -05:00
Dan McGee
b8ee7b1ee2 mirrorcheck: s/if/elif/ when determining what check function to run
This was a silly thinko here; it caused the logs to fill up with a bunch
of 'unknown url type: rsync' errors.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-13 13:36:14 -05:00
Dan McGee
46d21e03e8 Don't check FTP + IPv6 combination
Very few, if any, FTP servers support connections over IPv6.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-12 20:18:51 -05:00
Dan McGee
ace95f6e53 Don't add blank options to rsync command line
Rsync doesn't like this so much:
    Unexpected remote arg: rsync://mirror.example.com/archlinux/lastsync
    rsync error: syntax or usage error (code 1) at main.c(1214) [sender=3.0.9]

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 21:38:58 -06:00
Dan McGee
7c8b09b95c Teach mirrorcheck management command about check locations
This adds the -l/--location argument to the command in order to pass in
a check location that we are currently running from. This locks the IP
address family to the one derived from the address on that location, and
stores any check results tagged with a location ID.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 20:58:09 -06:00
Dan McGee
9917ee3482 Add location ID to mirror logs
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 20:49:38 -06:00
Dan McGee
d9dbe4fb1e Add family property to mirror check location
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 20:43:09 -06:00
Dan McGee
3e0209f5e8 Revert "mirrorcheck: Don't use bulk_create on sqlite3"
This reverts commit 3c4ceb16. We don't need this anymore as bulk_create
gets automatic batching now on sqlite3 so it is safe to use.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 19:56:48 -06:00
Dan McGee
71259ab4c2 Add mirror CheckLocationAdmin
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 19:53:11 -06:00
Dan McGee
1dbf311774 Add 'created' field to more mirror models
We have been better about doing this to most of our models, but the ones
here didn't have a created field. Add it where appropriate and set a
reasonably old default value.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 19:45:52 -06:00
Dan McGee
d158ce71e4 Add mirror check locations model
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-06 19:40:24 -06:00
Dan McGee
10af269ed2 Add HTTPS mirror protocol fixture
For now, it is not included in the default selection, but we have a few
existing mirrors that do support it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-03-04 18:14:44 -06:00
Dan McGee
5566d43a77 Use 'update_fields' model.save() kwarg
This was added in Django 1.5 and allows saving only a subset of a
model's fields. It makes sense in a few cases to utilize it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-09 16:50:45 -06:00
Dan McGee
dd8e94f697 Lengthen the mirror rsync IP address field
Make it long enough to support a full-form IPv6 address with a subnet.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-20 15:01:13 -06:00
Dan McGee
1f9aef78f3 Remove debugging print statement
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-16 00:18:26 -06:00