-
Notifications
You must be signed in to change notification settings - Fork 48
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
Enable email notifier to send emails for health check failures #244
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
I have already sent 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.
Just skimmed.
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/notifier/EmailNotifier.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/module/ClusterStateListenerModule.java
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
63c4aff
to
e21ac36
Compare
@prakhar10 could you squash your commits? I think this enhancement should include some tests, there are currently none for notifications. |
f3d067d
to
73e9a67
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/HealthChecker.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/notifier/EmailNotifier.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/notifier/EmailNotifier.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/notifier/EmailNotifier.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/clustermonitor/TestHealthCheck.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/clustermonitor/TestHealthCheck.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/module/TestClusterStateListenerModule.java
Show resolved
Hide resolved
7ef8848
to
8d57974
Compare
8d57974
to
6db0428
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.
Good progress, some suggestions on the tests
ImmutableList.Builder<TrinoClusterStatsObserver> observerBuilder = ImmutableList.builder(); | ||
observerBuilder.add(new HealthCheckObserver(mgr)); | ||
observerBuilder.add(new ClusterStatsObserver(backendStateManager)); | ||
if (notifierConfiguration.isEnabled()) { |
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.
Remove
NotifierConfiguration notifierConfiguration = getConfiguration().getNotifier();
above and use
if (monitorConfig.getNotifier().isEnabled()) {
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 think we cannot get monitorConfig.getNotifier()
because monitorConfig is an object of MonitorConfiguration
and not NotifierConfiguration
@Test | ||
public void testSendNotificationCustomContent() | ||
{ | ||
NotifierConfiguration notifierConfiguration = mock(NotifierConfiguration.class); |
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.
A mock isn't needed here - just initialize directly and use the setters. This applies to the other tests using NotifierConfiguration
as well
|
||
EmailNotifier emailNotifier = new EmailNotifier(notifierConfiguration); | ||
|
||
emailNotifier.sendNotification("Test Subject", "Test Content"); |
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.
Its not clear to me what this is testing. Can you assert a success condition, or is the test just that this runs without throwing an error?
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.
yeah it was just basically to see if there are no errors produced since the method returns void
@Test | ||
public void testNotifyUnhealthyCluster() | ||
{ | ||
Notifier notifier = Mockito.mock(Notifier.class); |
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 test suite may be better with a TestingNotifier
implementation of Notifier
instead of of mocks - wdyt @prakhar10 and @ebyhr? Sth like
public class TestingNotifier
implements Notifier
{
List<Notification> notifications = new ArrayList<>();
public void sendNotification(String from, List<String> recipients, String subject, String content)
{
recipients.forEach(recipient -> notifications.add(new Notification(from, recipient, subject, content))
}
public List<Notification> getNotifications()
{
return notifications;
}
class Notification {
//should have fields for rom, recipient, subject, content
}
}
Then tests can observe the notifications produced rather than testing for internal details like method invocations.
public class TestClusterStateListenerModule | ||
{ | ||
@Test | ||
public void testGetClusterStatsObservers() |
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.
Rename to testClusterStateListenerModule
@prakhar10 can you address to the feedback comments |
- Includes new stack with Semi UI, Vite, React, TypeScript, and E-charts framework as major components - Removes Dropwizard UI usage, further enabling removal of Dropwizard altogether
* Clean brew install in quick start doc * Use gateway version 7 * Use PostgreSQL docker container
- Including recommendation for dev and test usage only
- change langing page to /dashboard - Add hyperlink to Trino Gateway in UI
The restUserInfo method in the LoginResource class and the findQueryHistory method in the GatewayWapResource were using string manipulation of the getMemberOf method from the LbPrincipal to do role authorization. This change fixes the role authorization to be consistent throughout the app by utilizing the isUserInRole method that keeps the context of the LbAuthorization when checking user access to the ADMIN, USER, and API roles.
- with process forwarding config only for now
Ensure objects are serializable without AUTO_DETECT_GETTERS. Convert request objects into record to reduce boilerplate.
Branch was messed up, created a new PR - #319 |
This change enables to send email notifications for healthcheck failures on backend trino clusters.
New fields added in the
NotifierConfiguration.java
class:enabled
- To enable or disable sending emails for healthcheck failuresgatewayInstance
- To specify gateway instance name in case there are multiple instances. This will be displayed in the email subject so that one can know in which instance the cluster is unhealthy.customContent
- To provide custom email body in case the default content is not very helpful.