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 alertId parameter in get chained alert API and paginate associated alerts if alertId param is mentioned #1071

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

eirsep
Copy link
Member

@eirsep eirsep commented Aug 2, 2023

Get chained alert API will support filtering based on an alertId. The motivation is to fetch associated alerts with support for pagination. The size and sort params would apply to fetch associated alerts in this api when alert id is mentioned

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.

…d alerts if alertId param is mentioned

Signed-off-by: Surya Sashank Nistala <[email protected]>
@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Merging #1071 (b210e70) into main (03acc53) will increase coverage by 0.03%.
The diff coverage is 79.16%.

@@             Coverage Diff              @@
##               main    #1071      +/-   ##
============================================
+ Coverage     67.70%   67.73%   +0.03%     
  Complexity      105      105              
============================================
  Files           160      160              
  Lines         10324    10343      +19     
  Branches       1518     1522       +4     
============================================
+ Hits           6990     7006      +16     
- Misses         2671     2672       +1     
- Partials        663      665       +2     
Files Changed Coverage Δ
...ting/transport/TransportGetWorkflowAlertsAction.kt 67.96% <77.77%> (+1.30%) ⬆️
...lerting/resthandler/RestGetWorkflowAlertsAction.kt 95.55% <83.33%> (-1.95%) ⬇️

... and 6 files with indirect coverage changes

actionListener.onResponse(GetWorkflowAlertsResponse(alerts, associatedAlerts, totalAlertCount))
} catch (e: Exception) {
actionListener.onFailure(AlertingException("Failed to get alerts", RestStatus.INTERNAL_SERVER_ERROR, e))
}
}

private suspend fun getAssociatedAlerts(associatedAlerts: MutableList<Alert>, alerts: MutableList<Alert>, alertIndex: String) {
private suspend fun getAssociatedAlerts(
Copy link
Member

Choose a reason for hiding this comment

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

How is pagination done here?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed this and verified in test

// if alert id is mentioned we cannot set "from" field as it may not return id. we would be using it to paginate associated alerts
val from = if (getWorkflowAlertsRequest.alertIds.isNullOrEmpty())
tableProp.startIndex
else 0
Copy link
Member

Choose a reason for hiding this comment

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

The startIndex isn't being passed over to getAssociatedAlerts

Copy link
Member Author

Choose a reason for hiding this comment

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

we dont need it to be passed over. we will use tableProp.startIndex

we need this check on from param if alertId is mentioned because we cannot paginate for single id in search request to fetch the chained alerts

@eirsep eirsep merged commit d9f66b3 into opensearch-project:main Aug 2, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 2, 2023
…d alerts if alertId param is mentioned (#1071)

* add alertId parameter in get chained alert API and paginate associated alerts if alertId param is mentioned

Signed-off-by: Surya Sashank Nistala <[email protected]>

* set from param in associated alerts search request

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit d9f66b3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 2, 2023
…d alerts if alertId param is mentioned (#1071)

* add alertId parameter in get chained alert API and paginate associated alerts if alertId param is mentioned

Signed-off-by: Surya Sashank Nistala <[email protected]>

* set from param in associated alerts search request

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit d9f66b3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
eirsep pushed a commit that referenced this pull request Aug 2, 2023
…d alerts if alertId param is mentioned (#1071) (#1074)

* add alertId parameter in get chained alert API and paginate associated alerts if alertId param is mentioned



* set from param in associated alerts search request



---------


(cherry picked from commit d9f66b3)

Signed-off-by: Surya Sashank Nistala <[email protected]>
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>
lezzago pushed a commit that referenced this pull request Aug 23, 2023
…d alerts if alertId param is mentioned (#1071) (#1073)

* add alertId parameter in get chained alert API and paginate associated alerts if alertId param is mentioned



* set from param in associated alerts search request



---------


(cherry picked from commit d9f66b3)

Signed-off-by: Surya Sashank Nistala <[email protected]>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.9 backports PRs to 2.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants