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

NoOpTrigger #420

Merged
merged 4 commits into from
May 4, 2023
Merged

NoOpTrigger #420

merged 4 commits into from
May 4, 2023

Conversation

petardz
Copy link
Contributor

@petardz petardz commented May 2, 2023

Description

Added NoOpTrigger to be used when constructing monitor error alerts or alerts which are not generated as a result of ran triggers

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

@petardz petardz requested a review from a team May 2, 2023 21:22
@petardz petardz force-pushed the noop-trigger branch 2 times, most recently from b44b696 to 1c0718a Compare May 2, 2023 21:28
eirsep
eirsep previously approved these changes May 2, 2023
@eirsep
Copy link
Member

eirsep commented May 2, 2023

plz resolve conflicts

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2023

Codecov Report

Merging #420 (22f437e) into main (6af3110) will increase coverage by 0.04%.
The diff coverage is 78.57%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #420      +/-   ##
============================================
+ Coverage     72.82%   72.87%   +0.04%     
- Complexity      701      712      +11     
============================================
  Files           112      113       +1     
  Lines          4670     4711      +41     
  Branches        602      606       +4     
============================================
+ Hits           3401     3433      +32     
- Misses         1019     1024       +5     
- Partials        250      254       +4     
Impacted Files Coverage Δ
...n/org/opensearch/commons/alerting/model/Monitor.kt 81.77% <0.00%> (-0.43%) ⬇️
...g/opensearch/commons/alerting/model/NoOpTrigger.kt 70.37% <70.37%> (ø)
...lin/org/opensearch/commons/alerting/model/Alert.kt 75.10% <100.00%> (+1.26%) ⬆️
...n/org/opensearch/commons/alerting/model/Trigger.kt 85.71% <100.00%> (+0.71%) ⬆️

@lezzago
Copy link
Member

lezzago commented May 3, 2023

Is the idea to use the NoOpTriggers to create error alerts for all monitor types when the monitor fails?

@petardz
Copy link
Contributor Author

petardz commented May 3, 2023

yes

import org.opensearch.core.xcontent.XContentParser
import java.io.IOException

data class NoOpTrigger(
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 only difference from a normal trigger is that it has no condition, so its technically always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea it has id/name so that Alert's fields can be populated. Also, creating monitor with this trigger is not permitted.(require statement in init of monitor model)

@lezzago
Copy link
Member

lezzago commented May 3, 2023

yes

How exactly will the NoOptrigger be used in the monitor executions? Also why is this needed for the error alerts? Can't we have a function in Alerting to generate error alerts from monitor failures and have that shared amongst all the monitor runners? Something similar to that is already in place.

Also would the idea be for users to make monitors with these noop triggers?

@petardz
Copy link
Contributor Author

petardz commented May 3, 2023

yes

How exactly will the NoOptrigger be used in the monitor executions? Also why is this needed for the error alerts? Can't we have a function in Alerting to generate error alerts from monitor failures and have that shared amongst all the monitor runners? Something similar to that is already in place.

Also would the idea be for users to make monitors with these noop triggers?

After discussion with @getsaurabh02 conclusion was that it is safest to keep constraint of mandatory trigger parameter in Alert constructors, hence the NoOpTrigger implementation.

You can't make monitors with this type of trigger. I added this constraint inside init block of Monitor class.

@@ -357,6 +358,16 @@ class XContentTests {
assertEquals("Round tripping alert doesn't work", alert, parsedAlert)
}

@Test
Copy link
Member

Choose a reason for hiding this comment

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

Lets add xcontent tests for NoOp triggers.

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
petardz added 2 commits May 4, 2023 23:15
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
@eirsep eirsep merged commit c507ac9 into opensearch-project:main May 4, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 4, 2023
* added noop trigger

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit c507ac9)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 4, 2023
* added noop trigger

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit c507ac9)
lezzago pushed a commit that referenced this pull request May 4, 2023
* added noop trigger

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit c507ac9)

Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
eirsep pushed a commit that referenced this pull request May 4, 2023
* added noop trigger

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit c507ac9)

Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
AWSHurneyt pushed a commit to AWSHurneyt/common-utils that referenced this pull request Apr 12, 2024
* added noop trigger

Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com>
(cherry picked from commit c507ac9)

Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
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