Remove migration (temporarily), fix a broken test, and make the aggregate size calculation use the entire image ancestry (for now).
This commit is contained in:
parent
b8d88c0f4e
commit
44ff85d044
3 changed files with 9 additions and 26 deletions
|
@ -1,22 +0,0 @@
|
|||
"""Backfill aggregate size columns
|
||||
|
||||
Revision ID: 87c29d0cd05
|
||||
Revises: 2b2529fd23ff
|
||||
Create Date: 2015-03-16 17:55:30.148557
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '87c29d0cd05'
|
||||
down_revision = '2b2529fd23ff'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from util.backfill_aggregate_sizes import backfill_aggregate_sizes
|
||||
|
||||
|
||||
def upgrade(tables):
|
||||
backfill_aggregate_sizes()
|
||||
|
||||
def downgrade(tables):
|
||||
pass
|
|
@ -1454,8 +1454,13 @@ def set_image_size(docker_image_id, namespace_name, repository_name, image_size,
|
|||
ancestors = image.ancestors.split('/')[1:-1]
|
||||
if ancestors:
|
||||
try:
|
||||
parent_image = Image.get(Image.id == ancestors[-1])
|
||||
total_size = image_size + parent_image.storage.aggregate_size
|
||||
# TODO(jschorr): Switch to this faster route once we have full ancestor aggregate_size
|
||||
# parent_image = Image.get(Image.id == ancestors[-1])
|
||||
# total_size = image_size + parent_image.storage.aggregate_size
|
||||
total_size = (ImageStorage.select(fn.Sum(ImageStorage.image_size))
|
||||
.join(Image)
|
||||
.where(Image.id << ancestors)) + image_size
|
||||
|
||||
image.storage.aggregate_size = total_size
|
||||
except Image.DoesNotExist:
|
||||
pass
|
||||
|
|
|
@ -58,7 +58,7 @@ class TestImageTree(unittest.TestCase):
|
|||
|
||||
result = tree.find_longest_path(base_image.id, checker)
|
||||
self.assertEquals(4, len(result))
|
||||
self.assertEquals('v2.0', tree.tag_containing_image(result[-1]))
|
||||
self.assertEquals('prod', tree.tag_containing_image(result[-1]))
|
||||
|
||||
def test_filtering(self):
|
||||
all_images = list(model.get_repository_images(NAMESPACE, COMPLEX_REPO))
|
||||
|
@ -88,7 +88,7 @@ class TestImageTree(unittest.TestCase):
|
|||
|
||||
# Only use the first two images. They don't have tags, but the method should
|
||||
# still return the tag that contains them.
|
||||
self.assertEquals('v2.0', tree.tag_containing_image(result[0]))
|
||||
self.assertEquals('staging', tree.tag_containing_image(result[0]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Reference in a new issue