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

Ofer/311468 filter event by storage system #8424

Conversation

Oferlis
Copy link

@Oferlis Oferlis commented Aug 24, 2022

Added a new selection field in the events monitoring page to filter by a physical storage system.

Before:
image

After:
image

The new field will show the connected physical storage systems and will filter by the selection.

  • When entering the monitoring page from the storage manager page, selecting an empty set will present all the events available.
  • When entering the monitoring page from a specific physical storage, an empty set will present the current physical storage events.

@GilbertCherrie
Copy link
Member

@agrare I don't have any storage managers with monitoring or timelines enabled so I couldn't fully test this. Although @Oferlis I did notice that this PR also added this field to the timelines page for VMS and instances, is that intentional?
Screen Shot 2022-08-29 at 3 35 16 PM

@Oferlis
Copy link
Author

Oferlis commented Aug 30, 2022

Hey @GilbertCherrie, the addition of the storage system field for the VMS and instances was not intentional, as this PR was related to physical storage.
What is the preferred way of approaching this in your opinion?

@Oferlis Oferlis force-pushed the ofer/311468-filter_event_by_storage_system branch from 997e245 to 8da576e Compare August 30, 2022 12:06
@GilbertCherrie
Copy link
Member

GilbertCherrie commented Aug 30, 2022

@Oferlis You can create a variable in the physical storage controller file and set it to true, such as
@isPhysicalStorage = True then in your haml file you check if this value is true to render that drop down or not. What you did works but it adds an extra haml file that we don't need. Let me know if what I said makes sense or not.

@Oferlis
Copy link
Author

Oferlis commented Sep 5, 2022

Hey @agrare @GilbertCherrie,
Do you have any comments regarding the PR?

@agrare
Copy link
Member

agrare commented Sep 6, 2022

I'd like a UI reviewer before I merge this, @jeffibm @GilbertCherrie @DavidResende0

@@ -31,6 +33,14 @@ ManageIQ.angular.app.controller('timelineOptionsController', ['miqService', 'url
vm.reportModel.tl_categories = [];
};

vm.showFilterField = function() {
let bool = false;
if(vm.model === "PhysicalStorage" || vm.model === "ExtManagementSystem"){
Copy link
Member

@GilbertCherrie GilbertCherrie Sep 6, 2022

Choose a reason for hiding this comment

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

@Oferlis The vm.model === "ExtManagementSystem" shouldn't be used because if you go into the monitoring page for a cloud provider it will have the value of "ExtManagementSystem" for vm.model and cause this field to be rendered there as shown in the screenshot.

Screen Shot 2022-09-06 at 6 46 54 PM

Copy link
Author

Choose a reason for hiding this comment

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

Just changed it to rely on the Autosde model so any other model will not be effected.
Changes will be pushed today.

Comment on lines 1288 to 1289
storages = PhysicalStorage.all.ids
storages.map{|k| [PhysicalStorage.find_by(:id=>k).name, k]}
Copy link
Member

Choose a reason for hiding this comment

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

Hm there is a lot wrong with this...

  1. I don't think this should be in the base application_helper when it is storage_system specific
  2. It queries for physical storages one-at-a-time rather than in batches
  3. It is showing ALL physical storages regardless of tenant/group/RBAC

This needs a re-think IMO

Copy link
Author

Choose a reason for hiding this comment

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

I modified the function so it will be less problematic, please tell me if this is fine with you:
Screen Shot 2022-09-12 at 10 23 53

Also, where should I place it?
The timeline JS files are in the UI repo in this is relevant to it

Copy link
Member

Choose a reason for hiding this comment

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

If you want to return an array of [name, id] the way to do that in the most efficient way possible is PhysicalStorage.pluck(:name, :id)

I still don't think we can return all physical storages here though, if you have two tenants wouldn't tenant A see all physical storages in tenant B and vice versa?

Copy link
Author

Choose a reason for hiding this comment

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

Changed it to the pluck method you suggested, and it looks good.
For the other part, I can use the Autosde::PhysicalStorage, is this better? it will make sure only AutoSDE objects are returned

Copy link
Member

Choose a reason for hiding this comment

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

For the other part, I can use the Autosde::PhysicalStorage, is this better? it will make sure only AutoSDE objects are returned

No it really doesn't because two tenants can both have AutoSDE providers. Need help from the UI team here because I'm not sure what is common here but you have to use something that has a user context like a selected provider or an RBAC filtered list of physical_storages

Copy link
Author

Choose a reason for hiding this comment

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

Who can I contact in the UI team?

Copy link
Member

Choose a reason for hiding this comment

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

I would hope they are already reviewing this, but /cc @jeffibm @DavidResende0 @GilbertCherrie

Comment on lines 2 to 9
def calculate_properties
super
self[:hidden] = true unless visible?
end

def visible?
@record.supports?(:timeline)
end
Copy link
Member

Choose a reason for hiding this comment

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

These are identical to the parent class, why override them?

Copy link
Author

Choose a reason for hiding this comment

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

This file was a reminder from the first commit, it is deleted.

end

def disabled?
@error_message.present?
Copy link
Member

Choose a reason for hiding this comment

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

Will this ever be true? The parent class sets @error_message in a conditional block then checks for .present? but this never sets it so how could it ever be true?

Copy link
Author

Choose a reason for hiding this comment

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

This file was a reminder from the first commit, it is deleted.

@@ -7,6 +7,7 @@ ManageIQ.angular.app.controller('timelineOptionsController', ['miqService', 'url
tl_timerange: 'weeks',
tl_timepivot: 'ending',
tl_result: 'success',
tl_storage_systems: [''],
Copy link
Member

Choose a reason for hiding this comment

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

Is the rest of this provider specific? I don't see anything else here about infra hosts or cloud vms...

Copy link
Author

Choose a reason for hiding this comment

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

This is storage specific, is there a better solution in your eyes?

rec_cond, *rec_params = @tl_record.event_where_clause(@tl_options.evt_type)
parameters = rec_params + [from_dt, to_dt]
else
rec_cond = tl_map_storage_systems(params[:tl_storage_systems])
Copy link
Member

Choose a reason for hiding this comment

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

So it looks like if you aren't on a specific record, you want to show all events from all storage systems?
Would it make more sense to have @tl_record be the Autosde::StorageManager and keep using the same @tl_record.event_where_clause ?

Copy link
Author

Choose a reason for hiding this comment

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

I edited the function as you recommended, the function is related to the StorageManager and PhysicalStorage models now.
Changes will be pushed hopefully today.

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

Just going to throw a NAK on this since I have a couple serious concerns

@@ -93,10 +93,11 @@ def tl_build_timeline_report_options
from_dt = create_time_in_utc("#{from_date.strftime} 00:00:00",
session[:user_tz])

rec_cond, *rec_params = @tl_record.event_where_clause(@tl_options.evt_type)
conditions = [rec_cond, "timestamp >= ?", "timestamp <= ?"]
rec_cond, *rec_params = @tl_record.event_where_clause(@tl_options.evt_type, params[:tl_storage_systems])
Copy link
Member

Choose a reason for hiding this comment

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

So the comment seems to have been lost in the changes, but this is still an issue. We can't be adding in provider specifics like storage_systems here in the general timeline options.

I think it is better to have @tl_record be your EMS and you can return all the storages related to the ems (this also fixes your RBAC issue) and/or have @tl_record be a specific storage system (also resolves the RBAC issue)

Copy link
Author

Choose a reason for hiding this comment

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

The suggested change is the situation today (Master branch), where when using the EMS, all the physical storages are displayed, and when selecting specific storage only its events are presented.

The params are returned from the form the user filled, so not passing them will mean no filtering, which is the purpose of the PR.

As I see it, the change will have to add provider-specific code somewhere in the code (which I agree is not good), so the problem will be moved to another file or function. Is there a solution that you think might fit here?

Copy link
Member

Choose a reason for hiding this comment

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

@jeffibm @GilbertCherrie @DavidResende0 is there a way for the Autosde provider to override the timeline UI page without modifying the core options?

@MelsHyrule
Copy link
Member

Hi just got sent this PR, catching up on reading all the comments. Currently this page is due in for a conversion to React and is currently underway. With this conversion we can add schema to the AutoSDE provider a la https://github.com/ManageIQ/manageiq-providers-openstack/blob/master/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb#L135-L146 and have that include the 'Select Storage System' field when is appropriate. This will leave the rest of the fields intact for all other cases.

@GilbertCherrie
Copy link
Member

Hi just got sent this PR, catching up on reading all the comments. Currently this page is due in for a conversion to React and is currently underway. With this conversion we can add schema to the AutoSDE provider a la https://github.com/ManageIQ/manageiq-providers-openstack/blob/master/app/models/manageiq/providers/openstack/storage_manager/cinder_manager/cloud_volume.rb#L135-L146 and have that include the 'Select Storage System' field when is appropriate. This will leave the rest of the fields intact for all other cases.

@agrare I agree with @MelsHyrule here, it would probably be much easier to just handle this with a react conversion than figuring out how to make the form provider specific

@agrare
Copy link
Member

agrare commented Sep 15, 2022

@GilbertCherrie @MelsHyrule 👍 sounds good to me thanks

@Oferlis Oferlis requested a review from a team as a code owner September 20, 2022 11:58
@miq-bot
Copy link
Member

miq-bot commented Sep 20, 2022

Checked commits Autosde/manageiq-ui-classic@a222e7d~...9954745 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
3 files checked, 1 offense detected

app/views/layouts/_tl_options.html.haml

  • ⚠️ - Line 123 - Layout/TrailingEmptyLines: Final newline missing.

@Oferlis
Copy link
Author

Oferlis commented Sep 20, 2022

Hi, @GilbertCherrie @MelsHyrule,
Thank you for the update, when this conversion will be introduced? just so I get an approximation

@MelsHyrule
Copy link
Member

@Oferlis The conversion should be introduced sometime before Q4 so within the next month or so

@miq-bot
Copy link
Member

miq-bot commented Nov 1, 2022

This pull request is not mergeable. Please rebase and repush.

@Oferlis
Copy link
Author

Oferlis commented Nov 3, 2022

Hi @agrare @MelsHyrule,

I am back at this PR as I noticed the transition to React.
Regarding the approach @GilbertCherrie suggested, as I see it the textual functions are for textual values only.
I aim to add a field to the form to filter by physical storage, so manipulating the Ruby files (timelines.rb, and such, as I did before) is still the only solution I can see.

another approach will be to filter the JSON response in the miq_timeline.js file, but it will introduce provider-specific code in the UI files.

Any thoughts?

@MelsHyrule
Copy link
Member

So poking around what I would do, is I would start testing to see how I would introduce the physical storage filter using react. In my original comment I pointed out params_for_attach so you could introduce the drop down with an API.options call. You'll need to rebase this branch onto latest since some of the files you've changed here no longer exist within the repo. We're already passing in the id of what we select (see here) so you can use that to your advantage.

Once the drop down is actually set up and behaving as expected then I would look into including the physical storage option into the ruby file logic. It would likely go in tl_build_timeline_report_options or tl_gen_timeline_data in timelines.rb but i'd need to get my hands in there with data that has providers with physical storages to test properly.

Hopefully this answers your question. Let me know if you need any further help!

@Oferlis
Copy link
Author

Oferlis commented Nov 8, 2022

I have opened another branch for the new changes, but the conversation is documented here

Thank you for the reply, I have managed to get to the point where I need to handle the Ruby files, (tl_build_timeline_report_options or tl_gen_timeline_data functions).

As @agrare commented in #8424 (comment)
I should avoid introducing provider-specific code in the general timeline option, but I cannot find a workaround - the filtering must be passed in these functions. Any thoughts?

@MelsHyrule
Copy link
Member

So the steps to take would be the following:

@Oferlis
Copy link
Author

Oferlis commented Nov 16, 2022

I managed to use the API link in the browser to test the response to the call:

/api/event_streams?expand=resources&attributes=group,group_level,group_name,id,event_type,physical_storage_id,message,ems_id,type&filter[]=group_level=critical&filter[]=or%20physical_storage_id=[1] -> as shown in the discussion, with the physical storage filtration I added.

As I understand, that data (from the API call) needs to be passed to the miq_timeline.js to further filter the JSON response, but that file needs to be converted to React before that can happen. Is the file conversion planned to take action?

@Oferlis
Copy link
Author

Oferlis commented Nov 28, 2022

@MelsHyrule, I didn't tag you in the last comment, so you probably weren't notified. what you think? How should we proceed?

@MelsHyrule
Copy link
Member

@Oferlis Hey! Just got back from vacation so only just saw your messages. I'll be reaching out to the UI team to discuss what's the best way to proceed further with this. Will ping you once we have an answer.

@MelsHyrule
Copy link
Member

@Oferlis Conversion to react for the required app/javascript/oldjs/miq_timeline.js page is currently underway. You can find the PR here.

@Oferlis
Copy link
Author

Oferlis commented Dec 8, 2022

@Oferlis Conversion to react for the required app/javascript/oldjs/miq_timeline.js page is currently underway. You can find the PR here.

Thank you for the update.

@miq-bot miq-bot added the stale label Mar 13, 2023
@miq-bot miq-bot closed this Mar 13, 2023
@miq-bot
Copy link
Member

miq-bot commented Mar 13, 2023

This pull request has been automatically closed because it has not been updated for at least 3 months.

Feel free to reopen this pull request if these changes are still valid.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@Fryguy Fryguy removed the stale label Jul 27, 2023
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