diff --git a/src/subCommands/deploy/impl/provision_config.ts b/src/subCommands/deploy/impl/provision_config.ts index 7feb7bb9..11ed767c 100644 --- a/src/subCommands/deploy/impl/provision_config.ts +++ b/src/subCommands/deploy/impl/provision_config.ts @@ -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'; @@ -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); @@ -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() { diff --git a/src/subCommands/deploy/impl/scaling_config.ts b/src/subCommands/deploy/impl/scaling_config.ts index 5050f862..841fdbeb 100644 --- a/src/subCommands/deploy/impl/scaling_config.ts +++ b/src/subCommands/deploy/impl/scaling_config.ts @@ -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) { @@ -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}`,