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

fix(sl): fix error code #1366

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

import { config } from "@config/config"

export enum JobStatus {

Check warning on line 5 in src/constants/constants.ts

View workflow job for this annotation

GitHub Actions / lint

'JobStatus' is already declared in the upper scope on line 5 column 13
Ready = "READY", // Ready to run jobs
Running = "RUNNING", // A job is running
Failed = "FAILED", // A job has failed and recovery is needed
}

export enum SiteStatus {

Check warning on line 11 in src/constants/constants.ts

View workflow job for this annotation

GitHub Actions / lint

'SiteStatus' is already declared in the upper scope on line 11 column 13
Empty = "EMPTY", // A site record site is being initialized
Initialized = "INITIALIZED",
Launched = "LAUNCHED",
}

export enum RedirectionTypes {

Check warning on line 17 in src/constants/constants.ts

View workflow job for this annotation

GitHub Actions / lint

'RedirectionTypes' is already declared in the upper scope on line 17 column 13
CNAME = "CNAME",
A = "A",
}

export enum CollaboratorRoles {

Check warning on line 22 in src/constants/constants.ts

View workflow job for this annotation

GitHub Actions / lint

'CollaboratorRoles' is already declared in the upper scope on line 22 column 13
Admin = "ADMIN",
Contributor = "CONTRIBUTOR",
IsomerAdmin = "ISOMERADMIN",
Expand All @@ -30,7 +30,7 @@
CollaboratorRoles.IsomerAdmin
>

export enum ReviewRequestStatus {

Check warning on line 33 in src/constants/constants.ts

View workflow job for this annotation

GitHub Actions / lint

'ReviewRequestStatus' is already declared in the upper scope on line 33 column 13
Approved = "APPROVED",
Open = "OPEN",
Merged = "MERGED",
Expand Down Expand Up @@ -76,6 +76,8 @@
"18.138.108.8",
"18.139.47.66",
]
export const ALLOWED_DNS_ERROR_CODES = ["ENOTFOUND", "ENODATA"]

Comment on lines +79 to +80
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ENOTFOUND seems to be a catch all actually, should we be including this in the list of acceptable error codes?

From the node dns docs:

Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

Copy link
Contributor Author

@kishore03109 kishore03109 May 10, 2024

Choose a reason for hiding this comment

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

do you know of any other way to capture no host name ah?
i agree that this is not the best way since we have a blind spot here, but their api does not seem to have an check for just the existence of a host name.

note that do have an error code for say timeout (ERR_SOCKET_CONNECTION_TIMEOUT ), so was hopeful that this would enough to catch transient network errors

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this happen on every site launch? Or is this an infrequent error caused by the agency not putting up their records in time? If it's infrequent there might be value in having to manually check, rather than possibly giving the agency a false positive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check happens once every site launch. But the error 'ENOTFOUND' is specifically thrown for every new domain that is being launched. We have had multiple incidents happen due to human error during SL (think one happened just this week with the pr to indirection layer iirc), so I am very inclined not to have manual checks. This PR's test plan has a sense check by running dns.promises on your docker for both resolve6 AND CAA for sites that have and dont have the above values. My stance is errors slip through will be rare, and as such the false positive is low enough to not affect operations.

export const DNS_INDIRECTION_DOMAIN = "hostedon.isomer.gov.sg"
export const DNS_INDIRECTION_REPO = "isomer-indirection"
export const ISOMER_ADMIN_EMAIL = "[email protected]"
Expand Down
14 changes: 11 additions & 3 deletions support/routes/v2/formsg/formsgSiteLaunch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import InitializationError from "@errors/InitializationError"

import { getField, getFieldsFromTable } from "@utils/formsg-utils"

import { ISOMER_SUPPORT_EMAIL } from "@root/constants"
import { ALLOWED_DNS_ERROR_CODES, ISOMER_SUPPORT_EMAIL } from "@root/constants"
import { attachFormSGHandler } from "@root/middleware"
import { mailer } from "@root/services/utilServices/MailClient"
import {
Expand Down Expand Up @@ -258,7 +258,11 @@ export class FormsgSiteLaunchRouter {
value: record,
}))
} catch (e) {
if (isErrnoException(e) && e.code === "ENODATA") {
if (
isErrnoException(e) &&
e.code &&
ALLOWED_DNS_ERROR_CODES.includes(e.code)
) {
this.siteLaunchLogger.info({
message: `Domain does not have any AAAA records.`,
meta: {
Expand Down Expand Up @@ -329,7 +333,11 @@ export class FormsgSiteLaunchRouter {

return result
} catch (e) {
if (isErrnoException(e) && e.code === "ENODATA") {
if (
isErrnoException(e) &&
e.code &&
ALLOWED_DNS_ERROR_CODES.includes(e.code)
) {
this.siteLaunchLogger.info({
message: `Domain does not have any CAA records.`,
meta: {
Expand Down
Loading