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

Support MDS on ListDetectors page #716

Closed

Conversation

jackiehanyang
Copy link
Collaborator

@jackiehanyang jackiehanyang commented Apr 4, 2024

Description

This pr adds MDS support on ListDetectors page. The default data source will be selected when MDS support is enabled.

Screenshot 2024-04-04 at 15 39 35

Screenshot 2024-04-08 at 12 41 56

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Member

@huyaboo huyaboo left a comment

Choose a reason for hiding this comment

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

Could you please provide detailed steps with testing your changes? Does it still function with MDS disabled and/or hide local cluster enabled/disabled?

public/models/interfaces.ts Show resolved Hide resolved
server/plugin.ts Outdated

export interface ADPluginSetupDependencies {
dataSourceManagement: ReturnType<DataSourceManagementPlugin['setup']>;
dataSource: DataSourcePluginSetup;
Copy link
Member

Choose a reason for hiding this comment

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

If dataSourceManagement and dataSource are optionalPlugins, these shouldn't be required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will update this part

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated in the latest commit

server/utils/helpers.ts Show resolved Hide resolved
server/utils/helpers.ts Show resolved Hide resolved
public/pages/DetectorsList/containers/List/List.tsx Outdated Show resolved Hide resolved
public/pages/utils/helpers.ts Show resolved Hide resolved
server/plugin.ts Show resolved Hide resolved
@BionIT
Copy link

BionIT commented Apr 8, 2024

Can we add some context and manual tests have been done for the PR?

@huyaboo
Copy link
Member

huyaboo commented Apr 8, 2024

Approved but a couple of action items once this is merged:

  1. Add some tests
  2. Finalize with UX the behavior of AD Plugin if the DataSourceSelectable component returns to the callback function the invalid state ([]) and make that change in a subsequent PR.

@jackiehanyang
Copy link
Collaborator Author

Can we add some context and manual tests have been done for the PR?

This pr just add the data source component on the list page and render the page according to data source selector. I will provide a record to include this page on the other pr I opened

@jackiehanyang
Copy link
Collaborator Author

Approved but a couple of action items once this is merged:

  1. Add some tests
  2. Finalize with UX the behavior of AD Plugin if the DataSourceSelectable component returns to the callback function the invalid state ([]) and make that change in a subsequent PR.

noted

Copy link
Member

@ohltyler ohltyler left a comment

Choose a reason for hiding this comment

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

Really great to understand the internals of this. Biggest suggestion here is to have a plan to refactor/support passing the selected data source ID through all of the node APIs. Details in comments

server/routes/ad.ts Show resolved Hide resolved
@@ -89,6 +89,7 @@ export type GetDetectorsQueryParams = {
indices?: string;
sortDirection: SORT_DIRECTION;
sortField: string;
dataSourceId?: string;
Copy link
Member

Choose a reason for hiding this comment

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

it isn't scalable or consistent to add this ID as part of this particular interface that's used just for the getDetectors() server-side call. We'll need it for all server-side fns, including all of the AD ones, alerting ones, and general cluster ones. Can you explore a common pattern that could be added to all routes, for example, maybe appending or prepending the data source ID in the path itself and parsing out similar to how detectorID is done for some of them is a possibility. All plugins will have the same problem of how to propagate the data source ID from public -> server-side, is there a common pattern being done by others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm adding the dataSourceId as port of this particular interface just for this list page. Because for list page, it uses a specific interface for its query params. Since dataSourceId also serves as a query param on this page, so I'm just adding it to this interface. For other pages, I'm appending the data source id the path itself. Please check the pr for detailed page - https://github.com/opensearch-project/anomaly-detection-dashboards-plugin/pull/719/files#diff-cc594889ac44cb130233969adf3da57a18f360a2a77c57ee273aad5f39d6d733

Copy link
Member

Choose a reason for hiding this comment

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

Understood, and cool, looks like some are adjusted that way there. Let's make all of them consistent through the node path the first time though. This will make it much cleaner and avoid making changes to this data model which doesn't logically fit.

server/plugin.ts Show resolved Hide resolved
server/utils/helpers.ts Show resolved Hide resolved
@ohltyler
Copy link
Member

ohltyler commented Apr 8, 2024

Also, let's make sure unit tests are passing. +1 to @huyaboo comment as well, maybe we can have a meta issue to make sure we have 1/ updated unit tests and 2/ a few integ tests for sanity testing. @huyaboo / @BionIT is there integ test framework support for mocking multiple data sources and invoking multiple cluster clients?

@jackiehanyang
Copy link
Collaborator Author

Also, let's make sure unit tests are passing. +1 to @huyaboo comment as well, maybe we can have a meta issue to make sure we have 1/ updated unit tests and 2/ a few integ tests for sanity testing. @huyaboo / @BionIT is there integ test framework support for mocking multiple data sources and invoking multiple cluster clients?

great suggestion. meta issue created - #721

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.

4 participants