Skip to content

Commit

Permalink
Merge pull request #1164 from isomerpages/release/0.67.1
Browse files Browse the repository at this point in the history
Release/0.67.1
  • Loading branch information
alexanderleegs authored Feb 22, 2024
2 parents 7bc1a17 + 6388fbc commit 6a1ac28
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.67.1](https://github.com/isomerpages/isomercms-backend/compare/v0.67.0...v0.67.1)

- Revert "Chore/lock repos when repairing (#1149)" [`a746288`](https://github.com/isomerpages/isomercms-backend/commit/a7462884ba9f1d072d1a1bac97e5d4c25d338adf)

#### [v0.67.0](https://github.com/isomerpages/isomercms-backend/compare/v0.66.4...v0.67.0)

> 22 February 2024
- fix(start-commands): update commands to be different by env [`#1159`](https://github.com/isomerpages/isomercms-backend/pull/1159)
- fix(dompurify): further limit src [`#1156`](https://github.com/isomerpages/isomercms-backend/pull/1156)
- fix(file-ext): prevent users from bypassing checks on file extensions [`#1157`](https://github.com/isomerpages/isomercms-backend/pull/1157)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isomercms",
"version": "0.67.0",
"version": "0.67.1",
"private": true,
"scripts": {
"build": "tsc -p tsconfig.build.json",
Expand Down
21 changes: 2 additions & 19 deletions src/routes/formsg/formsgGGsRepair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ import { ResultAsync, errAsync, fromPromise, okAsync } from "neverthrow"

import { config } from "@config/config"

import { lock, unlock } from "@utils/mutex-utils"

import {
EFS_VOL_PATH_STAGING,
EFS_VOL_PATH_STAGING_LITE,
} from "@root/constants"
import GitFileSystemError from "@root/errors/GitFileSystemError"
import InitializationError from "@root/errors/InitializationError"
import LockedError from "@root/errors/LockedError"
import { consoleLogger } from "@root/logger/console.logger"
import logger from "@root/logger/logger"
import { attachFormSGHandler } from "@root/middleware"
Expand Down Expand Up @@ -117,20 +114,15 @@ export class FormsgGGsRepairRouter {
}

handleGGsFormSubmission = (repoNames: string[], requesterEmail: string) => {
const repairs: ResultAsync<string, GitFileSystemError | LockedError>[] = []
const repairs: ResultAsync<string, GitFileSystemError>[] = []

const clonedStagingRepos: string[] = []
const syncedStagingAndStagingLiteRepos: string[] = []
const LOCK_TIME_SECONDS = 15 * 60 // 15 minutes
repoNames.forEach((repoName) => {
const repoUrl = `[email protected]:isomerpages/${repoName}.git`

repairs.push(
ResultAsync.fromPromise(
lock(repoName, LOCK_TIME_SECONDS),
(err) => new LockedError(`Unable to lock repo ${repoName}`)
)
.andThen(() => this.doesRepoNeedClone(repoName))
this.doesRepoNeedClone(repoName)
.andThen(() => {
const isStaging = true
return (
Expand Down Expand Up @@ -174,15 +166,6 @@ export class FormsgGGsRepairRouter {
return okAsync(result)
})
)
.andThen((result) => {
// Failure to unlock is not blocking
ResultAsync.fromPromise(unlock(repoName), () => {
logger.error(
"Failed to unlock repo - repo will unlock after at most 15 min"
)
})
return okAsync(result)
})
)
})

Expand Down
8 changes: 4 additions & 4 deletions src/utils/mutex-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ const mockUnlock = (siteName) => {
mockMutexObj[siteName] = false
}

const lock = async (siteName, lockLengthSeconds = 60) => {
const lock = async (siteName) => {
try {
const expiryTime =
Math.floor(new Date().valueOf() / 1000) + lockLengthSeconds
const ONE_MIN_FROM_CURR_DATE_IN_SECONDS_FROM_EPOCH_TIME =
Math.floor(new Date().valueOf() / 1000) + 60

if (isE2eTestRepo(siteName)) return
if (!IS_DEV) {
const params = {
TableName: MUTEX_TABLE_NAME,
Item: {
repo_id: siteName,
expdate: expiryTime,
expdate: ONE_MIN_FROM_CURR_DATE_IN_SECONDS_FROM_EPOCH_TIME,
},
ConditionExpression: "attribute_not_exists(repo_id)",
}
Expand Down

0 comments on commit 6a1ac28

Please sign in to comment.