-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soft delete instead of disconnect for containers models #15251
Changes from all commits
0ec229a
719c919
606b675
050f1f9
1295547
50b4153
7d72385
44ef947
d4448cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,16 @@ class ContainerManager < BaseManager | |
include SupportsFeatureMixin | ||
|
||
has_many :container_nodes, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_groups, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_groups, -> { active }, :foreign_key => :ems_id | ||
has_many :container_services, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_replicators, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :containers, :foreign_key => :ems_id | ||
has_many :container_projects, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :containers, -> { active }, :foreign_key => :ems_id | ||
has_many :container_definitions, -> { active }, :foreign_key => :ems_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cben you've defined but there is :ems_id on the container_definitions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Both old and graph refresh set this ems_id, we have a test. Please replace my definion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in bb2f07a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you intentionally removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kbrock yes that is defined on all_xy relations, that include also soft-deleted items |
||
has_many :container_projects, -> { active }, :foreign_key => :ems_id | ||
has_many :container_quotas, :foreign_key => :ems_id, :dependent => :destroy | ||
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, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_images, -> { active }, :foreign_key => :ems_id | ||
has_many :persistent_volumes, :as => :parent, :dependent => :destroy | ||
has_many :persistent_volume_claims, :foreign_key => :ems_id, :dependent => :destroy | ||
has_many :container_component_statuses, :foreign_key => :ems_id, :dependent => :destroy | ||
|
@@ -26,7 +27,6 @@ class ContainerManager < BaseManager | |
has_many :computer_system_hardwares, :through => :computer_systems, :source => :hardware | ||
has_many :computer_system_operating_systems, :through => :computer_systems, :source => :operating_system | ||
has_many :container_volumes, :through => :container_groups | ||
has_many :container_definitions, :through => :container_groups | ||
has_many :container_port_configs, :through => :container_definitions | ||
has_many :container_env_vars, :through => :container_definitions | ||
has_many :security_contexts, :through => :container_definitions | ||
|
@@ -36,10 +36,13 @@ class ContainerManager < BaseManager | |
has_many :container_limit_items, :through => :container_limits | ||
has_many :container_template_parameters, :through => :container_templates | ||
|
||
# Archived entities to destroy when the container manager is deleted | ||
has_many :old_container_groups, :foreign_key => :old_ems_id, :dependent => :destroy, :class_name => "ContainerGroup" | ||
has_many :old_container_projects, :foreign_key => :old_ems_id, :dependent => :destroy, :class_name => "ContainerProject" | ||
has_many :old_container_images, :foreign_key => :old_ems_id, :dependent => :destroy, :class_name => "ContainerImage" | ||
# Archived and active entities to destroy when the container manager is deleted | ||
has_many :all_containers, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "Container" | ||
has_many :all_container_groups, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerGroup" | ||
has_many :all_container_projects, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerProject" | ||
has_many :all_container_images, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerImage" | ||
has_many :all_container_definitions, :foreign_key => :ems_id, :dependent => :destroy, :class_name => "ContainerDefinition" | ||
|
||
|
||
virtual_column :port_show, :type => :string | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few lines below, it still does
I suppose for consistency we'll also want to stop that and retain the normal relation, just with one or both sides archived. And
project.container_groups
association would default to-> { active }
to preserve current behavior.@zakiva @zeari what do you think? Is this the desired end state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked with @zakiva, we're also clearing
self.container_node_id = nil
which will make less sense after ManageIQ/manageiq-schema#22 starts archiving nodes.I think let's get both this and ManageIQ/manageiq-schema#22 merged, then revisit these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It make sense to unify the behavior and not delete the foreign keys. It will be a zombie-free land at some point :-)