@@ -123,6 +123,46 @@ export default class ScalingConfig extends Base {
123123 }
124124 }
125125
126+ /**
127+ * 删除弹性配置
128+ */
129+ async removeScalingConfig ( qualifier : string ) {
130+ try {
131+ if ( ! _ . isEmpty ( this . remote ) ) {
132+ logger . info ( `Remove remote scalingConfig of ${ this . functionName } /${ qualifier } ` ) ;
133+ await this . fcSdk . removeFunctionScalingConfig ( this . functionName , qualifier ) ;
134+
135+ // 等待弹性配置实例数降至0
136+ const maxRetries = 12 ;
137+ for ( let index = 0 ; index < maxRetries ; index ++ ) {
138+ // eslint-disable-next-line no-await-in-loop
139+ const result = await this . fcSdk . getFunctionScalingConfig ( this . functionName , qualifier ) ;
140+ const { currentInstances } = result || { } ;
141+
142+ if ( ! currentInstances || currentInstances === 0 ) {
143+ logger . info ( `ScalingConfig of ${ this . functionName } /${ qualifier } removed successfully` ) ;
144+ return ;
145+ }
146+
147+ logger . info (
148+ `waiting ${ this . functionName } /${ qualifier } scaling currentInstances to 0 ...` ,
149+ ) ;
150+ // eslint-disable-next-line no-await-in-loop
151+ await sleep ( 5 ) ;
152+ }
153+
154+ logger . warn (
155+ `Timeout waiting for scalingConfig of ${ this . functionName } /${ qualifier } to be removed` ,
156+ ) ;
157+ }
158+ } catch ( ex ) {
159+ logger . error (
160+ `Remove remote scalingConfig of ${ this . functionName } /${ qualifier } error: ${ ex . message } ` ,
161+ ) ;
162+ throw ex ;
163+ }
164+ }
165+
126166 /**
127167 * 等待弹性配置实例就绪
128168 */
@@ -175,46 +215,6 @@ export default class ScalingConfig extends Base {
175215 ) ;
176216 }
177217
178- /**
179- * 删除弹性配置
180- */
181- private async removeScalingConfig ( qualifier : string ) {
182- try {
183- if ( ! _ . isEmpty ( this . remote ) ) {
184- logger . info ( `Remove remote scalingConfig of ${ this . functionName } /${ qualifier } ` ) ;
185- await this . fcSdk . removeFunctionScalingConfig ( this . functionName , qualifier ) ;
186-
187- // 等待弹性配置实例数降至0
188- const maxRetries = 12 ;
189- for ( let index = 0 ; index < maxRetries ; index ++ ) {
190- // eslint-disable-next-line no-await-in-loop
191- const result = await this . fcSdk . getFunctionScalingConfig ( this . functionName , qualifier ) ;
192- const { currentInstances } = result || { } ;
193-
194- if ( ! currentInstances || currentInstances === 0 ) {
195- logger . info ( `ScalingConfig of ${ this . functionName } /${ qualifier } removed successfully` ) ;
196- return ;
197- }
198-
199- logger . info (
200- `waiting ${ this . functionName } /${ qualifier } scaling currentInstances to 0 ...` ,
201- ) ;
202- // eslint-disable-next-line no-await-in-loop
203- await sleep ( 5 ) ;
204- }
205-
206- logger . warn (
207- `Timeout waiting for scalingConfig of ${ this . functionName } /${ qualifier } to be removed` ,
208- ) ;
209- }
210- } catch ( ex ) {
211- logger . error (
212- `Remove remote scalingConfig of ${ this . functionName } /${ qualifier } error: ${ ex . message } ` ,
213- ) ;
214- throw ex ;
215- }
216- }
217-
218218 /**
219219 * 清理弹性配置对象
220220 */
0 commit comments