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

Issue 1366 - Slack integrations [ Siblings Check ] #1530

Conversation

PedroFonsecaDEV
Copy link
Contributor

Issue This PR Addresses

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

This PR is part of the solution of #1366.
Siblings Checkers: DEV and PROD checking each other periodically.

We also have an internal checker:
Slack Integration: Docker Events

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@PedroFonsecaDEV PedroFonsecaDEV self-assigned this Dec 13, 2020
@PedroFonsecaDEV PedroFonsecaDEV added type: enhancement New feature or request type: nice to have Feature that'd be nice to have, but not a priority area: tools area: deployment Production or Staging deployment labels Dec 13, 2020
@PedroFonsecaDEV
Copy link
Contributor Author

PedroFonsecaDEV commented Dec 13, 2020

Screen Shot 2020-12-12 at 10 18 02 PM

Obs: We need to change the message.

Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

It looks good, just a few nits. We'll need a teams/zoom session to test this.

# body: "text": "This is the message"
# });
# This will send the following message to our Slack channel: "This is the message"
SLACK_SEND_MESSAGE=
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure of what this means. Is SLACK_SEND_MESSAGE the text that will be sent to the channel?
Also, I don't think you need to show an example here, the URL to webhooks should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example requested by @humphd:
#1472 (comment)

SLACK_SEND_MESSAGE is an URL that receives a fetch/post with the message as the body and publishes it on our slack channel. It's almost like an API KEY, everyone with this URL will be able to send messages to our slack channel.

Copy link
Member

Choose a reason for hiding this comment

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

I still think the example should go in the docs, where all the env vars are explained.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, you are right. We should add them to this doc too.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a URL, let's label it as such. I think @manekenpix's confusion is partly due to the name. What about SLACK_WEBHOOK_URL instead?

Comment on lines 12 to 14
// Server health check

firstCheck();
Copy link
Member

Choose a reason for hiding this comment

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

You could just call it healthCheck()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. It will make more sense in this scope.

Comment on lines 7 to 9
process.DEPLOY_TYPE === 'production'
? 'https://telescope.cdot.systems/health.'
: 'https://dev.telescope.cdot.systems/health.';
Copy link
Member

Choose a reason for hiding this comment

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

We could do here what @humphd suggested. We can make the servers check each other, so if the machine is down, we'd still get the status, but I think that you'd need to add a case in which the server never answers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will sketch this feature. I think it will be better to understand it. But basically, we have the firstCheck running every 2 min. If the firstCheck fails, it will trigger the secondCheck that stops the firstCheck and performs a fetch every 10sec. If the secondCheck fails for the first time, the message "SERVER DOWN" is sent to us on SLACK. Once the message is sent, the secondCheck continues to run (the message informing us about the crash is sent just once). When the server is back, secondCheck sends the message "SERVER IS BACK", stop itself and triggers the firstCheck.

Because we rely on the network, sometimes the firstCheck can emit a false-negative when it fails due to network "issues" (timeout, etc.). That's why I created this system to double-check the server and try to avoid false-negative messages on our slack channel.

@PedroFonsecaDEV
Copy link
Contributor Author

@manekenpix

It looks good, just a few nits. We'll need a teams/zoom session to test this.

Sure. Let's do it.

@PedroFonsecaDEV
Copy link
Contributor Author

@manekenpix @humphd
SlackIntegration-siblings-checker

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Looking better and better. I agree, let's get on a call early this week and test it together. Let's co-ordinate on Slack when these changes are done and we can test for real.

# body: "text": "This is the message"
# });
# This will send the following message to our Slack channel: "This is the message"
SLACK_SEND_MESSAGE=
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a URL, let's label it as such. I think @manekenpix's confusion is partly due to the name. What about SLACK_WEBHOOK_URL instead?

@@ -0,0 +1,81 @@
/* eslint-disable no-use-before-define */
/* eslint-disable no-unused-expressions */
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these really necessary? Can we not change your code to fit our linting style?

Copy link
Contributor Author

@PedroFonsecaDEV PedroFonsecaDEV Jan 18, 2021

Choose a reason for hiding this comment

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

Regarding the /* eslint-disable no-unused-expressions */ is solved.

But regarding /* eslint-disable no-use-before-define */
I have tried until I run out of ideas.

Because the firstCheck calls the secondCheck and vice versa.

const a = () => {
b(); -> LINTER: "b" was used before it was defined.
}
const b = () => {
a()
}

Any idea about this is welcome.

clearIntervalAsync(timerOne);
secondCheck();
}
}, 120000);
Copy link
Contributor

Choose a reason for hiding this comment

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

All these magic numbers should probably be something we can configure via env.

image_url:
status === 200
? 'https://data.whicdn.com/images/186936913/original.jpg'
: 'https://64.media.tumblr.com/090e86896948354262566ddb906e514e/tumblr_mxrsfhStH61r62zwpo1_500.jpg',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we pull images we depend on into our repo so we can rely on the URLs not going down in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, this is just a test message.

tools/autodeployment/src/sibling-checker/index.js Outdated Show resolved Hide resolved
@PedroFonsecaDEV PedroFonsecaDEV changed the title Issue 1366 - Slack integrations [ Siblings Checker ] Issue 1366 - Slack integrations [ Siblings Check ] Jan 18, 2021
@Metropass
Copy link
Contributor

This is very cool, might I add a suggestion?

I know this is bare bones at the moment, but I was wondering if we can write the status of the server into a .txt file

It might be a bit easier on the eyes, and it'll help archive the logs from the server

@PedroFonsecaDEV
Copy link
Contributor Author

This is very cool, might I add a suggestion?

I know this is bare bones at the moment, but I was wondering if we can write the status of the server into a .txt file

It might be a bit easier on the eyes, and it'll help archive the logs from the server

Could you please elaborate more?

@PedroFonsecaDEV
Copy link
Contributor Author

I'm updating the images because I'm not sure about the license of the previous images.

@izhuravlev
Copy link
Contributor

Thank you very much to everyone committing to this PR, your work is very appreciated.

We will be coming back to this PR later, so we are closing it for now.

@izhuravlev izhuravlev closed this Feb 23, 2021
@PedroFonsecaDEV
Copy link
Contributor Author

Sorry, I will reopen this PR for testing purposes.

@PedroFonsecaDEV
Copy link
Contributor Author

Okay tested. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: deployment Production or Staging deployment area: tools Blocked Can't do this, until something else is done type: enhancement New feature or request type: nice to have Feature that'd be nice to have, but not a priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate Slack integrations for failed or successful builds