Skip to content

Commit f10c110

Browse files
authored
Merge pull request #126 from devsapp/provision-timeout
fix: scalingConfig timeout error
2 parents 531826b + 69467c2 commit f10c110

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/subCommands/deploy/impl/provision_config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { IInputs } from '../../../interface';
66
import logger from '../../../logger';
77
import Base from './base';
88
import { sleep } from '../../../utils';
9-
import ScalingConfig from './scaling_config';
109
import { provisionConfigErrorRetry } from '../utils';
1110
// import Logs from '../../logs';
1211

@@ -19,7 +18,6 @@ export default class ProvisionConfig extends Base {
1918
remote: any;
2019
ProvisionMode: string;
2120
readonly functionName: string;
22-
scalingConfig: ScalingConfig;
2321

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

3934
async before() {

src/subCommands/deploy/impl/scaling_config.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ export default class ScalingConfig extends Base {
102102
}
103103
}
104104

105+
let getCurrentErrorCount = 0;
105106
const maxRetries = 180;
106107

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

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

120136
logger.info(
121137
`waiting ${this.functionName}/${qualifier} scaling OK: currentInstances: ${currentInstances}, minInstances: ${minInstances}`,

0 commit comments

Comments
 (0)