Skip to content

Commit

Permalink
Fixes #37139 - Block content view publish during repository publicati…
Browse files Browse the repository at this point in the history
…on tasks
  • Loading branch information
sjha4 committed Feb 2, 2024
1 parent 3dcae86 commit 9f47fbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ def check_ready_to_publish!(importing: false, syncable: false)
check_ready_to_import!
else
fail _("Import-only content views can not be published directly") if import_only? && !syncable
check_repositories_blocking_publish!
check_composite_action_allowed!(organization.library)
check_docker_repository_names!([organization.library])
check_orphaned_content_facets!(environments: self.environments)
Expand All @@ -637,6 +638,14 @@ def check_ready_to_publish!(importing: false, syncable: false)
true
end

def check_repositories_blocking_publish!
repositories_with_blocking_tasks = repositories.select { |repo| repo.blocking_tasks }

if repositories_with_blocking_tasks.any?
fail _("Pending tasks detected in repositories of this content view. Please wait before publishing.")
end
end

def check_docker_repository_names!(environments)
environments.each do |environment|
repositories = []
Expand Down
12 changes: 12 additions & 0 deletions app/models/katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,18 @@ def latest_dynflow_sync
for_resource(self).order(:started_at).last
end

def blocking_tasks
blocking_task_labels = [
::Actions::Katello::Repository::Sync.name,
::Actions::Katello::Repository::UploadFiles.name
]
ForemanTasks::Task::DynflowTask.where(:label => blocking_task_labels)
.where.not(state: 'stopped')
.for_resource(self)
.order(:started_at)
.last
end

# returns other instances of this repo with the same library
# equivalent of repo
def environmental_instances(view)
Expand Down

0 comments on commit 9f47fbb

Please sign in to comment.