Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Adjust pulp2_last_updated date for the copied errata.
Browse files Browse the repository at this point in the history
Needed in order to allow user (e.g. Katello) to identify content changed since the last run.
Pulp 2 copy operation doesn't update timestamps.

re #8417
  • Loading branch information
goosemania committed Mar 22, 2021
1 parent e21447b commit 07d9a3a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.2.19 on 2021-03-22 13:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('pulp_2to3_migration', '0026_p2content_UQ'),
]

operations = [
migrations.AddIndex(
model_name='pulp2repocontent',
index=models.Index(fields=['pulp2_created'], name='pulp_2to3_m_pulp2_c_267ffa_idx'),
),
]
1 change: 1 addition & 0 deletions pulp_2to3_migration/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Meta:
unique_together = ('pulp2_repository', 'pulp2_unit_id')
indexes = [
models.Index(fields=['pulp2_content_type_id']),
models.Index(fields=['pulp2_created'])
]


Expand Down
14 changes: 10 additions & 4 deletions pulp_2to3_migration/app/pre_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def pre_migrate_content_type(content_model, mutable_type, lazy_type, premigrate_
).select_related(
'pulp2_repository'
).only(
'pulp2_repository'
)
'pulp2_repository', 'pulp2_created',
).order_by('pulp2_created')

mongo_content_qs = content_model.pulp2.objects(
id__in=content_relations.values_list('pulp2_unit_id', flat=True))
Expand All @@ -278,15 +278,21 @@ def pre_migrate_content_type(content_model, mutable_type, lazy_type, premigrate_
pulp2_subid='',
)

# Ensure that no existing pulp2content with slipped into bulk_create.
# Ensure that no existing pulp2content slipped into bulk_create.
# Otherwise, we'll have a problem with later bulk_create for detail models.
if Pulp2Content.objects.filter(specific_content_q).exists():
continue

item = Pulp2Content(
pulp2_id=record.id,
pulp2_content_type_id=record._content_type_id,
pulp2_last_updated=record._last_updated,
# Set `pulp2_last_updated` to the date of when a content unit got copied.
# (We can't set it to anything higher, in case pre-migration crashes and we would
# need to pick it up correctly on the next re-run.)
# When erratum is copied in pulp 2, it doesn't change its _last_updated timestamp.
# It means that Katello has no way to identify that the erratum has been copied
# since the last migration run, without reimporting all errata, which is expensive.
pulp2_last_updated=int(relation.pulp2_created.timestamp()),
pulp2_storage_path=record._storage_path,
downloaded=downloaded,
pulp2_repo=relation.pulp2_repository
Expand Down

0 comments on commit 07d9a3a

Please sign in to comment.