Commit Graph

167 Commits

Author SHA1 Message Date
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
Dan McGee
0f6a0a1cd0 Support mirror status JSON by tier
Just as we do for the normal status HTML view.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-14 08:54:33 -06:00
Dan McGee
ff6db38f1d Ensure URLs without check data work on mirror details page
Less noticeable in production as the templates don't show
'@@@INVALID@@@' there, but we were trying to access attributes that
don't actually exist on certain mirror objects.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-14 01:27:34 -06:00
Dan McGee
6f0ae6746b Drop country column from mirror table
We now always look for this information at the URL level, not the mirror
level. This simplifies quite a bit of code in and around the mirror
views.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-14 01:05:54 -06:00
Dan McGee
5b8b6991b0 Add migration to move country data down to the URL level
Rather than have the weird indirection we need now to find the right
country for URLs, just always store it on the URL.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-14 00:34:49 -06:00
Dan McGee
66850026ca Use content_type and not mimetype on HttpResponse()
Bug #16519 in Django deprecates mimetype, so update our code
accordingly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-13 22:34:33 -06:00
Dan McGee
bec73c7a37 Round two of mirror status query improvements
This seems to generate much more performant queries at the database
level than what we were previously doing, and also doesn't show
duplicate rows.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-12 15:56:36 -06:00
Dan McGee
2b68963ad1 Ensure mirror protocols are distinct
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-12-27 16:37:49 -06:00
Dan McGee
f0f6f7235a Fix mirror URL duplication in status view
We need to ensure we don't duplicate URLs in the status view, so add a
distinct() call back in to the queryset when it was inadvertently
dropped in commit a2cfa7edbb. This negates a lot of the performance
gains we had, unfortunately, so it looks like a nested subquery might be
more efficient. Disappointing the planner can't do this for us.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-21 00:25:04 -05:00
Dan McGee
6dd4d54bb0 Use Python 2.7 dictionary comprehension syntax
Rather than the old idiom of dict((k, v) for <> in <>).

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16 16:37:52 -06:00
Dan McGee
a2cfa7edbb Optimize mirror status data fetching
Now that we have as many mirror URLs as we do, we can do a better job
fetching and aggregating this data. The prior method resulted in a
rather unwieldy query being pushed down to the database with a
horrendously long GROUP BY clause. Instead of trying to group by
everything at once so we can retrieve mirror URL info at the same time,
separate the two queries- one for getting URL performance data, one for
the qualitative data.

The impetus behind fixing this is the PostgreSQL slow query log in
production; this currently shows up the most of any queries we run in
the system.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16 16:37:52 -06:00
Dan McGee
92837c93ac Prefetch the available protocols on the mirror overview page
Otherwise we are doing one query per mirror, which at this point is over
100 separate queries.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-12 21:37:08 -06:00
Dan McGee
55d2d3ae51 Add get_latest_by to MirrorLog Meta class
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-12 09:41:28 -06:00
Dan McGee
99bfdda5f2 Add title to mirror status data points
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-11 16:40:21 -06:00
Dan McGee
e26d572228 Mirror graph tweaking after usage with real data
* Clamp y-axis minimum to 0.
* Don't plot `is_success == false` values.
* Ensure URLs are sorted predictably.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-11 15:12:20 -06:00