Skip to content

Commit

Permalink
fixup better rollback successful message
Browse files Browse the repository at this point in the history
  • Loading branch information
amarthadan committed Jan 20, 2023
1 parent 554e82c commit 020049e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions packages/airnode-deployer/src/cli/commands.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { loadConfig } from '@api3/airnode-node';
import { loadConfig, deriveDeploymentVersionId } from '@api3/airnode-node';
import { go } from '@api3/promise-utils';
import { bold } from 'chalk';
import { deployAirnode, removeAirnode, saveDeploymentFiles } from '../infrastructure';
import { writeReceiptFile, parseReceiptFile, parseSecretsFile } from '../utils';
import { writeReceiptFile, parseReceiptFile, parseSecretsFile, deriveAirnodeAddress } from '../utils';
import * as logger from '../utils/logger';
import { logAndReturnError, MultiMessageError } from '../utils/infrastructure';

Expand Down Expand Up @@ -73,6 +73,8 @@ export async function deploy(configPath: string, secretsPath: string, receiptFil
const output = goDeployAirnode.data;
if (output.httpGatewayUrl) logger.info(`HTTP gateway URL: ${output.httpGatewayUrl}`);
if (output.httpSignedDataGatewayUrl) logger.info(`HTTP signed data gateway URL: ${output.httpSignedDataGatewayUrl}`);

return { creationTime: time };
}

export async function removeWithReceipt(receiptFilename: string) {
Expand All @@ -95,10 +97,24 @@ export async function rollback(deploymentId: string, versionId: string, receiptF

try {
await saveDeploymentFiles(deploymentId, versionId, configPathTmp, secretsPathTmp);
await deploy(configPathTmp, secretsPathTmp, receiptFile, autoRemove);
const { creationTime } = await deploy(configPathTmp, secretsPathTmp, receiptFile, autoRemove);

const secrets = parseSecretsFile(secretsPathTmp);
const config = loadConfig(configPathTmp, secrets);
const { airnodeWalletMnemonic, cloudProvider, stage, nodeVersion } = config.nodeSettings;
const airnodeAddress = deriveAirnodeAddress(airnodeWalletMnemonic);
const newVersionId = deriveDeploymentVersionId(
cloudProvider,
airnodeAddress,
stage,
nodeVersion,
`${creationTime.getTime()}`
);

spinner.succeed(
`Rollback of deployment '${deploymentId}' successful, new version '${newVersionId}' with configuration from version '${versionId}' created`
);
} finally {
fs.rmSync(configDirTmp, { recursive: true });
}

spinner.succeed(`Rollback of deployment '${deploymentId}' to version '${versionId}' successful`);
}
2 changes: 1 addition & 1 deletion packages/airnode-deployer/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function drawHeader() {
);
}

async function runCommand(command: () => Promise<void>) {
async function runCommand(command: () => Promise<any>) {
const goCommand = await go(command);
if (!goCommand.success) {
loggerUtils.log('\n\n\nError details:');
Expand Down

0 comments on commit 020049e

Please sign in to comment.