-
Notifications
You must be signed in to change notification settings - Fork 14
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 error that local cluster cannot get version #606
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If adding a new API, make sure it is integrated into the rest of the redux store and our route service framework. For example, see #330 which onboards the search connectors API.
We don't want to make direct calls from client-side, as it can be unstable, cause issues with tests, doesn't integrate with our error handling propagation, and could lead to NPEs.
router.get( | ||
{ | ||
path: `${BASE_NODE_API_PATH}/version`, | ||
validate: { | ||
params: schema.object({ | ||
pattern: schema.string(), | ||
}), | ||
}, | ||
}, | ||
opensearchRoutesService.catIndices | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This route is not being used. If adding a server-side call, let's properly integrate with the redux store for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this part is not used. Has removed the unused code.
const response = await callWithRequest('cat.indices', { | ||
index: pattern, | ||
format: 'json', | ||
}); | ||
|
||
// re-formatting the index results to match Index | ||
const cleanedIndices = response.map((index: any) => ({ | ||
name: index.index, | ||
health: index.health, | ||
})) as Index[]; | ||
|
||
return res.ok({ body: cleanedIndices }); | ||
} catch (err: any) { | ||
return generateCustomError(res, err); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about this call - why is cat indices needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this part.
@@ -71,7 +78,7 @@ const filterPresetsByVersion = async ( | |||
return workflows; | |||
} | |||
|
|||
if (!dataSourceId) { | |||
if (dataSourceId === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember some discrepancy on how empty string vs. undefined is handled for data sources. @saimedhi please confirm if this change makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the scenario of local cluster, data source id would be an empty string ''. !dataSourceId
would be true here so it will return empty presets for local cluster.
This is not the behavior we want so I changed the condition to only return empty if data source id is undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamahuan , I agree with your change.
- When local cluster is used, dataSourceId = ''
- When no compatible datasource is used, dataSourceId is undefined. Implies dataSourceId not present in page Url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing the code added in "filter presets and processors based on backend version" PR.
Lets connect and test all the possible scenarios before merging this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check the mds feature flag to determine if mds is enabled instead of checking if dataSourceId is present? Checking the feature flag should be the best practice and less error-prone
something like this - something like this - https://github.com/opensearch-project/anomaly-detection-dashboards-plugin/blob/main/public/pages/DetectorsList/containers/List/List.tsx#L147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jackie, I am not sure if I completely understand your comment. Line 76 and 77 checks if MDS is disabled, if so, we are showing all the presets assuming version >= 2.19. The other 2 cases checks 2 difference scenarios:
- if datasourceId === '', that means we are using local clusters
- if datasourceId === 'undefined', that means no compatible data source is used.
Are you suggesting removing line 81 to check the scenario where datasource is enabled? I am unsure semantically, if enabling datasource consists of the 2 above scenarios. May I know if @ohltyler @saimedhi have any ideas about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 76 and 77 checks if MDS is disabled
Don't use if(dataSourceId === undefined)
to check if MDS is disabled, read the feature flag from config file and check the feature flag to determine if MDS is enabled. Something like this if(MDSEnabled)
- https://github.com/opensearch-project/anomaly-detection-dashboards-plugin/blob/main/public/services.ts#L65
if (dataSourceId === '') { | ||
const response = await getCore().http.post('/api/console/proxy', { | ||
query: { path: '/', method: 'GET', dataSourceId: '' }, | ||
}); | ||
return response.version.number; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's integrate this properly into redux and our server-side route services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Add check local cluster version check into route.service
file and redux into presetRedux
file
// query: { path: '/', method: 'GET', dataSourceId: '' }, | ||
// }); | ||
// return response.version.number; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamahuan , could you remove this commented lines.
(state: AppState) => state.presets | ||
); | ||
const [allWorkflows, setAllWorkflows] = useState<WorkflowTemplate[]>([]); | ||
const [filteredWorkflows, setFilteredWorkflows] = useState< | ||
WorkflowTemplate[] | ||
>([]); | ||
const [isVersionLoading, setIsVersionLoading] = useState(false); | ||
// const [isVersionLoading, setIsVersionLoading] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamahuan, please clean up the commented code. Thank you for the fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I'm ok with the change, but it should go to a more logical reducer - suggest to move to opensearch_reducer. Also, after moving, suggest to reuse the existing loading
state var there; a new one shouldn't be needed.
17cac7e
to
96dffc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - please resolve the merge conflicts, and work with Sai to ensure everything is tested and working as expected. Thanks!
Signed-off-by: Kama Huang <kamahuan@amazon.com> refactor get local cluster version logic into service route and redux Signed-off-by: Kama Huang <kamahuan@amazon.com> refactor getVersion logic into opensearch reducer Signed-off-by: Kama Huang <kamahuan@amazon.com> adding loading state back to presetReducer Signed-off-by: Kama Huang <kamahuan@amazon.com> fixing unit tests Signed-off-by: Kama Huang <kamahuan@amazon.com>
Signed-off-by: Kama Huang <kamahuan@amazon.com>
Signed-off-by: Kama Huang <kamahuan@amazon.com> (cherry picked from commit 39ed7aa) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 39ed7aa) Signed-off-by: Kama Huang <kamahuan@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Currently in the new work flow page, when user click local data source, it shows a loading state and does not render any presets. This PR fix this issue by getting version from the datasource and render the presets based on the data source version.
Issues Resolved
None
UI changes after code change
for version 2.19
for version 2.17
Check List
--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.