Skip to content
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

Fix non existent container showing in report #15405

Merged

Conversation

nimrodshn
Copy link
Contributor

Currently, we output 'archived' containers to the user in the report 'Pods per Ready Status'.
In this PR we fix this behavior to only show the user the current containers.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1435958

Screenshots:

-Before:
screenshot from 2017-06-20 15-34-54
-After:
screenshot from 2017-06-20 15-36-30

Notice the list shrunk from 14 to 9.
cc: @simon3z @moolitayer @kbrock

@nimrodshn
Copy link
Contributor Author

@miq-bot add_label containers/providers bug wip

@nimrodshn
Copy link
Contributor Author

@simon3z we should probably review the other container related reports and make sure this behavior is the same for them also.. what do you think?

@miq-bot
Copy link
Member

miq-bot commented Jun 20, 2017

@nimrodshn Cannot apply the following label because they are not recognized: containers/providers bug wip

1 similar comment
@miq-bot
Copy link
Member

miq-bot commented Jun 20, 2017

@nimrodshn Cannot apply the following label because they are not recognized: containers/providers bug wip

@miq-bot miq-bot added the wip label Jun 20, 2017
@nimrodshn
Copy link
Contributor Author

@miq-bot add_labels containers/providers, bug, wip

@miq-bot
Copy link
Member

miq-bot commented Jun 20, 2017

@nimrodshn Cannot apply the following label because they are not recognized: containers/providers

@miq-bot miq-bot added the bug label Jun 20, 2017
@nimrodshn
Copy link
Contributor Author

@kbrock ended up using you're solution 👍

@simon3z
Copy link
Contributor

simon3z commented Jun 21, 2017

conditions: !ruby/object:MiqExpression
  exp:
    IS NOT NULL:
      field: ContainerGroup.ext_management_system-name

This heavily relies on the underlying implementation 😢

What if the deletion will be handled with an extra deleted flag as @Ladas is working on?

I feel we should rely on an explicit attribute of the objects... I think there is the deleted_on field that we can leverage (instead of the implicit underlying implementation of the disconnection).

@nimrodshn
Copy link
Contributor Author

@simon3z I think leveraging the deleted can work - just need for @Ladas PR (#15250) to get merged 😢

Currently, conditionds is implemented to support only conditions on MiqExpression meaning class fields and not Active Record Associations. From what I gathered deleted flag is a class field so it should work.

@simon3z
Copy link
Contributor

simon3z commented Jun 21, 2017

@simon3z I think leveraging the deleted can work - just need for @Ladas PR (#15250) to get merged

@nimrodshn that's why I said deleted_on

@nimrodshn
Copy link
Contributor Author

@simon3z I'll give it a try 👍

@Ladas
Copy link
Contributor

Ladas commented Jun 22, 2017

@nimrodshn @simon3z yeah, deleted_on should always work, I think I will just make it the only source of truth, for the sake of simplicity

@nimrodshn nimrodshn force-pushed the fix_nonexistent_containers_in_report branch from 667c5e5 to 2cb802b Compare June 26, 2017 10:26
@nimrodshn
Copy link
Contributor Author

nimrodshn commented Jun 26, 2017

@simon3z move to deleted_on and also checked the related widgets are working fine. 👍

@nimrodshn nimrodshn changed the title [WIP] Fix non existent container showing in report Fix non existent container showing in report Jun 26, 2017
@miq-bot miq-bot removed the wip label Jun 26, 2017
Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nimrodshn
looking good

@nimrodshn
Copy link
Contributor Author

@simon3z PTAL.

@simon3z
Copy link
Contributor

simon3z commented Aug 1, 2017

@kbrock ready for merge 👍

@nimrodshn
Copy link
Contributor Author

@gtanzillo @lpichler please review/merge, this report is ready. 😇

conditions: !ruby/object:MiqExpression
exp:
IS NOT NULL:
field: ContainerGroup.deleted_on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is working?
the syntax is defined in MiqExpression::Field::REGEX (just fyi it is not needed to read the regex :) )
for this case it should be ContainerGroup-deleted_on, the "." is for relations(ContainerGroup.ext_management_system-name).
MiqExpression::Field.parse('ContainerGroup-deleted_on') => true

MiqExpression::Field.parse('ContainerGroup.deleted_on') => nil

so please use 'ContainerGroup-deleted_on' (and also in other places)

add minor refactoring

refactored reports
@nimrodshn nimrodshn force-pushed the fix_nonexistent_containers_in_report branch from 2cb802b to 61a54e7 Compare August 10, 2017 13:10
@nimrodshn
Copy link
Contributor Author

@lpichler fixed 👍

@miq-bot
Copy link
Member

miq-bot commented Aug 10, 2017

Checked commit nimrodshn@61a54e7 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
0 files checked, 0 offenses detected
Everything looks fine. ⭐

@kbrock kbrock merged commit e5ff9de into ManageIQ:master Aug 21, 2017
@kbrock
Copy link
Member

kbrock commented Aug 21, 2017

@Ladas are there other tables/reports that need to add a deleted_on field?

@Ladas
Copy link
Contributor

Ladas commented Aug 22, 2017

@kbrock I think we have total 5 tables with deleted on for containers, those having active scope in https://github.com/Ladas/manageiq/blob/e7f155589c2342b10780accab2aab4539ae14b48/app/models/manageiq/providers/container_manager.rb#L11)

@cben we miss active scope for container nodes? Do we have a PR?

@cben
Copy link
Contributor

cben commented Aug 22, 2017

cc @zakiva
Node archiving migration landed but #15351 not yet <-- waiting for core committers hint hint ;-)
That would also apply the active scope. I'm not fully sure what happens currently until it lands.

If I understand this report correctly, it queries ContainerGroup.all, not ems.container_groups? If so it always included archived ones.

Is it good for reports to depend on deleted_on? (1) undiscoverable to users that this is the magic incantation (2) if we change implementation of archiving, reports would break.
Could we expose scopes (of other official way to express "active/archived") to reports?

@kbrock kbrock added this to the Sprint 68 Ending Sep 11, 2017 milestone Aug 22, 2017
@kbrock
Copy link
Member

kbrock commented Aug 22, 2017

@cben - darn. good point.
Wish we didn't even have to explicitly use active too, but that is the way it is.

Is someone adding archive scope to the containers?

@moolitayer
Copy link

moolitayer commented Aug 23, 2017

@kbrock ArchivedMixin?
BTW Do we need to add archived? as a virtual_column to be able include it in reports?

If I understand this report correctly, it queries ContainerGroup.all, not ems.container_groups? If so it always included archived ones

Probably didn't understand what you meant there @cben. Isn't this why we are adding the condition (maybe you were responding to something)

Is it good for reports to depend on deleted_on? (1) undiscoverable to users that this is the magic incantation (2) if we change implementation of archiving, reports would break.
Could we expose scopes (of other official way to express "active/archived") to reports?

We would definitely be better off by relying on ArchivedMixin's methods. I don't know if that makes sense in this context - looks like reports are designed to go straight to the DB. Can we use a default scope for that goal?

2.3.0 :010 > class User < ActiveRecord::Base
2.3.0 :011?>   default_scope { where(:name => 'admin')}
2.3.0 :012?>   end
 => [#<Proc:0x00000008378ea0@(irb):11>] 
2.3.0 :013 > User.all
  User Load (84.9ms)  SELECT "users".* FROM "users" WHERE "users"."name" = $1  [["name", "admin"]]
  User Inst Including Associations (0.0ms - 0rows)
 => #<ActiveRecord::Relation []> 
2.3.0 :014 > 

@simon3z
Copy link
Contributor

simon3z commented Aug 24, 2017

@miq-bot add_label fine/yes

@simon3z
Copy link
Contributor

simon3z commented Aug 24, 2017

@miq-bot add_label fine/yes

@nimrodshn @Ladas @cben keep me honest we can backport this to fine, the deleted_on field was already present there, no dependency on any schema change, etc.

@Ladas
Copy link
Contributor

Ladas commented Aug 24, 2017

@simon3z yes if there is the deleted_on column, then it should work.

btw. we don't have an index on deleted_on column in Fine, but it should not hurt the perf, since ContainerGroup table is pretty small (PG will probably do sequential scan instead of using the index anyway)

@kbrock
Copy link
Member

kbrock commented Aug 24, 2017

@moolitayer no to default_scope, but adding in the active scope does sound like a good plan.

simaishi pushed a commit that referenced this pull request Aug 24, 2017
…n_report

Fix non existent container showing in report
(cherry picked from commit e5ff9de)

https://bugzilla.redhat.com/show_bug.cgi?id=1484895
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit fc661191a53422bdd8d99be68b7580adc2708d62
Author: Keenan Brock <keenan@thebrocks.net>
Date:   Mon Aug 21 14:19:46 2017 -0400

    Merge pull request #15405 from nimrodshn/fix_nonexistent_containers_in_report
    
    Fix non existent container showing in report
    (cherry picked from commit e5ff9de1256593406408912636225c61ec696c3e)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1484895

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
…ainers_in_report

Fix non existent container showing in report
(cherry picked from commit e5ff9de)

https://bugzilla.redhat.com/show_bug.cgi?id=1484895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants