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

Add a new event group level #17611

Merged
merged 1 commit into from
Jul 11, 2018
Merged

Conversation

CharlleDaniel
Copy link
Member

@CharlleDaniel CharlleDaniel commented Jun 19, 2018

This PR is able to :

  • Add support to add new group levels in the EventStream class.
  • Add the warning group_level, that the user can filter warning events on the API.

@CharlleDaniel
Copy link
Member Author

@miq-bot add_reviewer @agrare

@CharlleDaniel
Copy link
Member Author

@miq-bot assign @agrare

@agrare
Copy link
Member

agrare commented Jun 20, 2018

I'm not sure who best to review this, maybe @gmcculloug or @lfu ?
I don't know where the event groups are used.

@agrare agrare removed their request for review June 20, 2018 09:41
@agrare agrare assigned gmcculloug and unassigned agrare Jun 20, 2018
@gmcculloug gmcculloug requested a review from lfu June 20, 2018 11:29
@CharlleDaniel
Copy link
Member Author

CharlleDaniel commented Jun 20, 2018

@agrare no problem. Thank you 👍

level = v[:detail].include?(event_type) ? :detail : :critical
level = :detail # the level is detail as default
group = event_groups.find do |_k, value|
lvl_found = GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) }
Copy link
Member

Choose a reason for hiding this comment

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

Is & a typo here?
Where are the warning events defined? Otherwise value[:warning] returns nil.

Copy link
Member Author

Choose a reason for hiding this comment

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

hey & not is a typo, this handle new values and avoid the flow be stopped when occurs nil.include?. Also we can define warning events in the settings.yml for each provider and I will open a PR to add warning events in the provider lenovo after this PR be merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@CharlleDaniel Could you please write some test cases to ensure the format of the return value is the same as before?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lfu ok, no problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lfu done, the tests were created.

@CharlleDaniel CharlleDaniel force-pushed the add_group_levels branch 2 times, most recently from ac19bad to 45bbdd3 Compare June 21, 2018 14:24
group = event_groups.find do |_k, value|
lvl_found = GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) }
level = lvl_found if lvl_found # update the level variable if found the current level.
lvl_found # the level found or nil
Copy link
Member

Choose a reason for hiding this comment

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

How about this?

  def self.group_and_level(event_type)
    group, value = event_groups.detect { |_k, v| GROUP_LEVELS.any? { |g| v[g]&.include?(event_type) } }
    if group.nil?
      group, level = :other, :detail
    else
      level = GROUP_LEVELS.detect { |g| value[g].include?(event_type) }
    end
    return group, level
  end

Copy link
Member Author

Choose a reason for hiding this comment

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

@lfu This works, but I think that is more complex, cause you need to do one more iteration. So I prefer the another form, but thank you.

Copy link
Member

Choose a reason for hiding this comment

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

It can be simplified as:

  def self.group_and_level(event_type)
    level = :detail # the level is detail as default
    group, _ = event_groups.find do |_k, value|
      GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) }.tap do |level_found|
        level = level_found if level_found
      end
    end

    group ||= :other
    return group, level
  end

Copy link
Member Author

@CharlleDaniel CharlleDaniel Jun 25, 2018

Choose a reason for hiding this comment

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

I liked this and changed the code to your suggestion, thank you 😄 .

group[:name]
return if group.nil?
group = event_groups[group]
group.nil? ? 'Other' : group[:name]
Copy link
Member

@lfu lfu Jun 21, 2018

Choose a reason for hiding this comment

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

This method used to support passed in group as a string and it returns nil if group is nil.
Is it intentional to change the behavior?

Copy link
Member

Choose a reason for hiding this comment

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

Can we also add test cases here to ensure the behavior is not changed accidentally?

Copy link
Member Author

@CharlleDaniel CharlleDaniel Jun 21, 2018

Choose a reason for hiding this comment

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

This method used to support passed in group as a string and it returns nil if group is nil.
Is it intentional to change the behavior?

@lfu Good point, it is a symbol, but I will add the group.sym again because the group column have a type as string( Line 31 ) and when persisted in the virtual column it is converted as string. Someone can do EventStream.group, receive a string and try get the group_name passing the string as param.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we also add test cases here to ensure the behavior is not changed accidentally?

I think the tests already cover this case.

@lfu
Copy link
Member

lfu commented Jun 21, 2018

@dclarizio @h-kataria Wondering if this PR would have any impact on the timeline UI.

@CharlleDaniel CharlleDaniel force-pushed the add_group_levels branch 2 times, most recently from 56c9c08 to ec410eb Compare June 21, 2018 17:05
@CharlleDaniel
Copy link
Member Author

@lfu I tested the timeline and everything looks good.
timeline

@h-kataria
Copy link
Contributor

@CharlleDaniel @lfu the new Group level "Warning" being added in this PR will not show up in UI unless changes are made in UI code to show/support the new level. Currently timeline options screen only shows Critical and Detail group level events only. This will require some UI work to show events from "Warning" group level.
As a side note, Is this new group level supported by all provider types, some providers might not have any events under the new group.

@miq-bot
Copy link
Member

miq-bot commented Jun 25, 2018

Checked commit CharlleDaniel@be7834d with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@CharlleDaniel
Copy link
Member Author

@lfu Morning, if you not have more suggestion could you to approve this PR 😅 ? I will open a PR adding support to filter warning events on the UI today or tomorrow.

@gmcculloug
Copy link
Member

@CharlleDaniel Can you comment on the questions raise here #17611 (comment) ?

@CharlleDaniel
Copy link
Member Author

CharlleDaniel commented Jun 25, 2018

@gmcculloug and @h-kataria about this comment, all providers are able to use the new group level if they want. Otherwise there are providers that not have events_groups or not need to use this new group level, but the group levels (new and old) not break the provider flow. Also, I will open a PR adding support to filter warning events on the UI today or tomorrow.

@CharlleDaniel
Copy link
Member Author

CharlleDaniel commented Jun 27, 2018

@gmcculloug morning, if you not have more discussions, could you approve this PR? 😅

@h-kataria
Copy link
Contributor

@CharlleDaniel if a provider does not support the new group level, will the new level still show up in UI, it will not yield any timeline results in that case since there wont be any event groups under that, correct?

@CharlleDaniel
Copy link
Member Author

CharlleDaniel commented Jul 11, 2018

@h-kataria hey morning,

if a provider does not support the new group level, will the new level still show up in UI, it will not yield any timeline results in that case since there wont be any event groups under that, correct?

Yes, but we can see the same case in categories field, always showing all categories even if provider do not have any event in it.

timeline2

@h-kataria
Copy link
Contributor

👍

@h-kataria h-kataria added this to the Sprint 90 Ending Jul 16, 2018 milestone Jul 11, 2018
@h-kataria h-kataria merged commit aabfc0e into ManageIQ:master Jul 11, 2018
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.

6 participants