-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failed deployments report (#890)
* refactor: convert retry failed deployments into component * fix: ignore fix for failed deployments * fix: mocked synchronization manager import
- Loading branch information
guidota
authored
Feb 1, 2022
1 parent
6105dcf
commit 97054c9
Showing
9 changed files
with
162 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
content/src/service/synchronization/retryFailedDeployments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { IBaseComponent } from '@well-known-components/interfaces' | ||
import { EnvironmentConfig } from '../../Environment' | ||
import { retryFailedDeploymentExecution } from '../../logic/deployments' | ||
import { AppComponents } from '../../types' | ||
|
||
export type IRetryFailedDeploymentsComponent = IBaseComponent & { | ||
schedule: () => Promise<void> | ||
} | ||
/** | ||
* This component schedules the retry of failed deployments. | ||
*/ | ||
export const createRetryFailedDeployments = ( | ||
components: Pick< | ||
AppComponents, | ||
| 'env' | ||
| 'metrics' | ||
| 'staticConfigs' | ||
| 'fetcher' | ||
| 'downloadQueue' | ||
| 'logs' | ||
| 'deployer' | ||
| 'contentCluster' | ||
| 'failedDeploymentsCache' | ||
> | ||
): IRetryFailedDeploymentsComponent => { | ||
const retryDelay = components.env.getConfig<number>(EnvironmentConfig.RETRY_FAILED_DEPLOYMENTS_DELAY_TIME) | ||
const logger = components.logs.getLogger('RetryFailedDeployments') | ||
let timeoutId: NodeJS.Timeout | undefined | ||
let running = false | ||
return { | ||
start: async () => { | ||
running = true | ||
logger.debug('Starting retry failed deployments') | ||
}, | ||
stop: async () => { | ||
running = false | ||
if (timeoutId) { | ||
clearTimeout(timeoutId) | ||
} | ||
logger.debug('Stopping retry failed deployments') | ||
}, | ||
schedule: async () => { | ||
while (running) { | ||
await new Promise((resolve) => { | ||
timeoutId = setTimeout(resolve, retryDelay) | ||
}) | ||
if (!running) return | ||
try { | ||
logger.debug('Executing retry failed deployments') | ||
await retryFailedDeploymentExecution(components, logger) | ||
} catch (err: any) { | ||
logger.error(err) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
content/test/helpers/service/synchronization/MockedSynchronizationManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ClusterSynchronizationManager } from '../../../../src/service/synchronization/SynchronizationManager' | ||
import { ISynchronizationManager } from '../../../../src/service/synchronization/SynchronizationManager' | ||
|
||
export function makeNoopSynchronizationManager(component: ClusterSynchronizationManager) { | ||
export function makeNoopSynchronizationManager(component: ISynchronizationManager) { | ||
jest.spyOn(component, 'syncWithServers').mockResolvedValue() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters