Revert "Merge pull request #557 from coreos-inc/revert-migration"
This reverts commitc4f938898a
, reversing changes made to7ad2522dbe
.
This commit is contained in:
parent
5c063bd285
commit
39cfe77d42
11 changed files with 232 additions and 65 deletions
|
@ -0,0 +1,24 @@
|
|||
"""Backfill image fields from image storages
|
||||
|
||||
Revision ID: 2e0380215d01
|
||||
Revises: 3ff4fbc94644
|
||||
Create Date: 2015-09-15 16:57:42.850246
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2e0380215d01'
|
||||
down_revision = '3ff4fbc94644'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from util.migrate.backfill_image_fields import backfill_image_fields
|
||||
from util.migrate.backfill_v1_metadata import backfill_v1_metadata
|
||||
|
||||
|
||||
def upgrade(tables):
|
||||
backfill_image_fields()
|
||||
backfill_v1_metadata()
|
||||
|
||||
def downgrade(tables):
|
||||
pass
|
|
@ -79,7 +79,14 @@ def get_repository_images_base(namespace_name, repository_name, query_modifier):
|
|||
|
||||
query = query_modifier(query)
|
||||
|
||||
location_list = list(query)
|
||||
return invert_placement_query_results(query)
|
||||
|
||||
|
||||
def invert_placement_query_results(placement_query):
|
||||
""" This method will take a query which returns placements, storages, and images, and have it
|
||||
return images and their storages, along with the placement set on each storage.
|
||||
"""
|
||||
location_list = list(placement_query)
|
||||
|
||||
images = {}
|
||||
for location in location_list:
|
||||
|
@ -333,7 +340,6 @@ def set_image_size(docker_image_id, namespace_name, repository_name, image_size,
|
|||
try:
|
||||
# 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
|
||||
ancestor_size = (ImageStorage
|
||||
.select(fn.Sum(ImageStorage.image_size))
|
||||
.join(Image)
|
||||
|
@ -342,6 +348,7 @@ def set_image_size(docker_image_id, namespace_name, repository_name, image_size,
|
|||
|
||||
# TODO stop writing to storage when all readers are removed
|
||||
if ancestor_size is not None:
|
||||
# total_size = image_size + parent_image.storage.aggregate_size
|
||||
total_size = ancestor_size + image_size
|
||||
image.storage.aggregate_size = total_size
|
||||
image.aggregate_size = total_size
|
||||
|
|
Reference in a new issue