Bug 1515287 - Delete DockerMetaTags when docker tags are deleted
Summary: Delete DockerMetaTags when docker tags are deleted
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Container Management
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Partha Aji
QA Contact: Nikhil Kathole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-20 14:02 UTC by Partha Aji
Modified: 2019-09-26 15:37 UTC (History)
5 users (show)

Fixed In Version: rubygem-katello-3.4.5.29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:54:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 21326 0 None None None 2017-11-20 14:02:03 UTC

Description Partha Aji 2017-11-20 14:02:00 UTC
DockerMetaTags are not getting deleted when docker tags are.

Deletion of docker tags only results in the nullification. 
What we need to happen is some thing along
if dockerTag.deleted?
   check if schema1 meta tag does Not have a schema2 entry and if so delete it.
   check if schema2 meta tag does Not have a schema1 entry and if so delete it.
end

To see a good example try the following in a rails or foreman-rake console
<pre>
>> dmt = ::Katello::DockerMetaTag.first
>> dmt.schema1.try(:destroy) ; dmt.schema2.try(:destroy)
>> dmt = ::Katello::DockerMetaTag.find(dmt.id) # reload
#Actual
<Katello::DockerMetaTag id: 4978, schema1_id: 5753, schema2_id: nil, name: "1.24.2-glibc", repository_id: 3>

#Expected
#ActiveRecord::RecordNotFound: Couldn't find Katello::DockerMetaTag with 'id'=4978
#This operation should fail because deleting the associated docker tags should wipe out the meta tag
</pre>

Comment 1 Partha Aji 2017-11-20 14:02:06 UTC
Created from redmine issue http://projects.theforeman.org/issues/21326

Comment 2 Partha Aji 2017-11-20 14:02:09 UTC
Upstream bug assigned to paji

Comment 3 Satellite Program 2017-11-20 15:23:34 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21326 has been resolved.

Comment 6 Nikhil Kathole 2017-12-14 10:42:05 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 28

irb(main):022:0> dmt = ::Katello::DockerMetaTag.first
=> #<Katello::DockerMetaTag id: 2, schema1_id: 2, schema2_id: 119, name: "1.26.2-glibc", repository_id: 36>

irb(main):023:0> dmt.schema1.try(:destroy) ; dmt.schema2.try(:destroy)
=> #<Katello::DockerTag id: 119, name: "1.26.2-glibc", repository_id: 36, created_at: "2017-12-11 08:16:43", updated_at: "2017-12-11 08:16:43", uuid: "e6a5dea0-cd5f-4250-8a19-5e9f17ff7aa6", docker_manifest_id: 13>

irb(main):024:0> dmt = ::Katello::DockerMetaTag.find(dmt.id)
ActiveRecord::RecordNotFound: Couldn't find Katello::DockerMetaTag with 'id'=2
        from /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/core.rb:155:in `find'
        from (irb):24
        from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
        from /opt/rh/rh-ror42/root/usr/share/gems/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
        from /usr/share/foreman/lib/tasks/console.rake:8:in `block in <top (required)>'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
        from /opt/rh/rh-ruby23/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
        from /opt/rh/rh-ruby23/root/usr/share/gems/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
        from /opt/rh/rh-ruby23/root/usr/bin/rake:23:in `load'
        from /opt/rh/rh-ruby23/root/usr/bin/rake:23:in `<main>'


Found expected results. Could not find DockerMetaTags as associated docker tag deleted.

Comment 7 Satellite Program 2018-02-21 16:54:37 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> > 
> > For information on the advisory, and where to find the updated files, follow the link below.
> > 
> > If the solution does not work for you, open a new bug report.
> > 
> > https://access.redhat.com/errata/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.