Skip to content

Commit

Permalink
Fixes #37609 - Migrate sha1 repos only at the next edit/sync time
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Jul 3, 2024
1 parent ace28c6 commit 2072d3f
Show file tree
Hide file tree
Showing 7 changed files with 1,361 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/lib/actions/pulp3/repository/create_publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def plan(repository, smart_proxy, options)
def invoke_external_task
unless input[:skip_publication_creation]
repository = ::Katello::Repository.find(input[:repository_id])
if repository.root.sha1_checksum?
repository.root.remove_sha1_checksum_type
repository.root.save!
end
output[:response] = repository.backend_service(smart_proxy).with_mirror_adapter.create_publication
end
end
Expand Down
10 changes: 10 additions & 0 deletions app/models/katello/root_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class RootRepository < Katello::Model
has_many :repository_references, :class_name => 'Katello::Pulp3::RepositoryReference',
:dependent => :destroy, :inverse_of => :root_repository

before_validation :remove_sha1_checksum_type, if: :sha1_checksum?

validates_lengths_from_database :except => [:label]
validates_with Validators::KatelloLabelFormatValidator, :attributes => :label
validates_with Validators::KatelloNameFormatValidator, :attributes => :name
Expand Down Expand Up @@ -157,6 +159,14 @@ def self.in_organization(org)
joins(:product).where("#{Katello::Product.table_name}.organization_id" => org)
end

def sha1_checksum?
checksum_type == 'sha1'
end

def remove_sha1_checksum_type
self.checksum_type = nil
end

def ensure_content_attribute_restrictions
CONTENT_ATTRIBUTE_RESTRICTIONS.each do |attribute, value|
if self.send(attribute).present? && !value.include?(self.content_type)
Expand Down
10 changes: 0 additions & 10 deletions db/migrate/20240531193030_remove_sha1_repository_checksum_type.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ <h4 translate>Sync Settings</h4>
options="checksums"
on-save="save(repository)">
</dd>
<p ng-hide="repository.checksum_type !== 'sha1'" class="help-block" translate>
The sha1 checksum type is no longer supported. The checksum type will reset to 'Default' at the next edit or change in content.
</p>
</span>

<span ng-show="repository.content_type === 'yum' && repository.mirroring_policy === 'additive'">
Expand Down
9 changes: 9 additions & 0 deletions test/actions/pulp3/orchestration/generate_metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@ def test_generate_with_source_repo
ForemanTasks.sync_task(
::Actions::Pulp3::Orchestration::Repository::Delete, @clone, @primary)
end

def test_generate_with_sha1_root_repo_checksum
root = @repo.root
root.checksum_type = 'sha1'
root.save!(validate: false)
ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::GenerateMetadata, @repo, @primary, force_publication: true)
root.reload
assert_nil root.checksum_type
end
end
end
Loading

0 comments on commit 2072d3f

Please sign in to comment.