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

feat(monitoring): add dns reporter #1376

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style(monitorin): cleaner style
kishore03109 committed Jun 27, 2024

Verified

This commit was signed with the committer’s verified signature.
Meulengracht Philip Meulengracht
commit 548f0df34c191e3993e1e6766290b76ae7d03df8
37 changes: 10 additions & 27 deletions src/monitoring/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import dns from "dns/promises"

import { retry } from "@octokit/plugin-retry"
import { Octokit } from "@octokit/rest"
import autoBind from "auto-bind"
import axios from "axios"
import _ from "lodash"
import { errAsync, okAsync, ResultAsync } from "neverthrow"

import parentLogger from "@logger/logger"
@@ -32,12 +34,6 @@ type keyCdnZoneAlias = {
name: string
}

interface KeyCdnResponse {
data: {
zonealiases: keyCdnZoneAlias[]
}
}

interface RedirectionDomain {
source: string
target: string
@@ -116,8 +112,11 @@ export default class MonitoringService {
*/
getRedirectionDomains() {
const SYSTEM_GITHUB_TOKEN = config.get("github.systemToken")
const OctokitRetry = Octokit.plugin()
const octokitWithRetry = new OctokitRetry({
// seems to be a bug in typing, this is a direct
// copy paste from the octokit documentation
// https://octokit.github.io/rest.js/v20#automatic-retries
const OctokitRetry = Octokit.plugin(retry as any)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if this is required! saw your comment but going to the linked site doesn't seem to suggest this.

image

this might be due to our tsconfig not changing, which seems to be required by the retry library
image

i think we might want to update our tsconfig and check again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sadly i get this even after changing
Screenshot 2024-06-06 at 3 54 25 PM
Screenshot 2024-06-06 at 3 55 10 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey @seaerchin, this has since been update by increasing the version number, thanks for the catch

const octokitWithRetry: Octokit = new OctokitRetry({
auth: SYSTEM_GITHUB_TOKEN,
request: { retries: 5 },
})
@@ -164,25 +163,9 @@ export default class MonitoringService {
]).andThen(([amplifyDeployments, redirectionDomains, keyCdnDomains]) => {
this.monitoringServiceLogger.info("Fetched all domains")
return okAsync(
[...amplifyDeployments, ...redirectionDomains, ...keyCdnDomains].sort(
(a, b) => {
const domainA = a.domain
const domainB = b.domain
if (
domainA.startsWith("www.") &&
domainA.slice(`www.`.length) === domainB
) {
return 0
}
if (
domainB.startsWith("www.") &&
domainA === domainB.slice(`www.`.length)
) {
return 0
}
if (domainA === domainB) return 0
return domainA > domainB ? 1 : -1
}
_.sortBy(
[...amplifyDeployments, ...redirectionDomains, ...keyCdnDomains],
(val) => (val.domain.startsWith("www.") ? val.domain.slice(4) : val)
)
)
})