From 4fe3f2d8abe19e6c9c618c1a92e613cf6330bf93 Mon Sep 17 00:00:00 2001 From: Martin Slemr Date: Tue, 3 Jul 2018 17:27:23 +0200 Subject: [PATCH] ContainerImage assoc. destroying ContainerImageRegistry only nullify dependency. Fixes OpenShift specs --- app/models/container_image_registry.rb | 2 +- app/models/manageiq/providers/container_manager.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/container_image_registry.rb b/app/models/container_image_registry.rb index 1d34c093b43..8c8aaf28e37 100644 --- a/app/models/container_image_registry.rb +++ b/app/models/container_image_registry.rb @@ -1,6 +1,6 @@ class ContainerImageRegistry < ApplicationRecord belongs_to :ext_management_system, :foreign_key => "ems_id" - has_many :container_images, :dependent => :destroy # What about deleted registry but containers are still running + has_many :container_images, :dependent => :nullify has_many :containers, :through => :container_images has_many :container_services has_many :container_groups, :through => :container_services diff --git a/app/models/manageiq/providers/container_manager.rb b/app/models/manageiq/providers/container_manager.rb index 3ad6efdd438..64de0172dea 100644 --- a/app/models/manageiq/providers/container_manager.rb +++ b/app/models/manageiq/providers/container_manager.rb @@ -17,7 +17,7 @@ class ContainerManager < BaseManager has_many :container_quotas, -> { active }, :foreign_key => :ems_id has_many :container_limits, :foreign_key => :ems_id, :dependent => :destroy has_many :container_image_registries, :foreign_key => :ems_id, :dependent => :destroy - has_many :container_images, -> { active }, :foreign_key => :ems_id + has_many :container_images, -> { active }, :foreign_key => :ems_id, :dependent => :destroy has_many :persistent_volumes, :as => :parent, :dependent => :destroy has_many :persistent_volume_claims, :foreign_key => :ems_id, :dependent => :destroy has_many :container_builds, :foreign_key => :ems_id, :dependent => :destroy