Skip to content
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
5 changes: 0 additions & 5 deletions src/subCommands/deploy/impl/provision_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { IInputs } from '../../../interface';
import logger from '../../../logger';
import Base from './base';
import { sleep } from '../../../utils';
import ScalingConfig from './scaling_config';
import { provisionConfigErrorRetry } from '../utils';
// import Logs from '../../logs';

Expand All @@ -19,7 +18,6 @@ export default class ProvisionConfig extends Base {
remote: any;
ProvisionMode: string;
readonly functionName: string;
scalingConfig: ScalingConfig;

constructor(inputs: IInputs, opts: IOpts) {
super(inputs, opts.yes);
Expand All @@ -31,9 +29,6 @@ export default class ProvisionConfig extends Base {
this.ProvisionMode = _.get(this.local, 'mode', 'sync');
_.unset(this.local, 'mode');
logger.debug(`need deploy provisionConfig: ${JSON.stringify(provisionConfig)}`);
this.scalingConfig = new ScalingConfig(inputs, {
yes: opts.yes,
});
}

async before() {
Expand Down
18 changes: 17 additions & 1 deletion src/subCommands/deploy/impl/scaling_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ export default class ScalingConfig extends Base {
}
}

let getCurrentErrorCount = 0;
const maxRetries = 180;

for (let index = 0; index < maxRetries; index++) {
// eslint-disable-next-line no-await-in-loop
const result = await this.fcSdk.getFunctionScalingConfig(this.functionName, qualifier);
const { currentInstances } = result || {};
const { currentInstances, currentError } = result || {};

// 检查是否已达到最小实例数
if (currentInstances && currentInstances >= result.minInstances) {
Expand All @@ -116,6 +117,21 @@ export default class ScalingConfig extends Base {
);
return;
}
if (currentError && currentError.length > 0) {
// 如果是系统内部错误,则继续尝试
if (!currentError.includes('an internal error has occurred')) {
// 不是系统内部错误,满足一定的重试次数则退出
getCurrentErrorCount++;
if (getCurrentErrorCount > 3 || (index > 6 && getCurrentErrorCount > 0)) {
logger.error(
`get ${this.functionName}/${qualifier} scaling config getCurrentErrorCount=${getCurrentErrorCount}`,
);
throw new Error(
`get ${this.functionName}/${qualifier} scaling config error: ${currentError}`,
);
}
}
}

logger.info(
`waiting ${this.functionName}/${qualifier} scaling OK: currentInstances: ${currentInstances}, minInstances: ${minInstances}`,
Expand Down
Loading