Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0e885aaf
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e885aaf
编写于
12月 08, 2020
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
retry all cosmosdb ops
上级
3212ddbc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
24 deletion
+34
-24
build/azure-pipelines/common/createAsset.ts
build/azure-pipelines/common/createAsset.ts
+1
-20
build/azure-pipelines/common/createBuild.ts
build/azure-pipelines/common/createBuild.ts
+2
-1
build/azure-pipelines/common/releaseBuild.ts
build/azure-pipelines/common/releaseBuild.ts
+2
-1
build/azure-pipelines/common/retry.ts
build/azure-pipelines/common/retry.ts
+26
-0
build/azure-pipelines/common/sync-mooncake.ts
build/azure-pipelines/common/sync-mooncake.ts
+3
-2
未找到文件。
build/azure-pipelines/common/createAsset.ts
浏览文件 @
0e885aaf
...
...
@@ -11,6 +11,7 @@ import * as crypto from 'crypto';
import
*
as
azure
from
'
azure-storage
'
;
import
*
as
mime
from
'
mime
'
;
import
{
CosmosClient
}
from
'
@azure/cosmos
'
;
import
{
retry
}
from
'
./retry
'
;
interface
Asset
{
platform
:
string
;
...
...
@@ -66,26 +67,6 @@ function getEnv(name: string): string {
return
result
;
}
async
function
retry
<
T
>
(
fn
:
()
=>
Promise
<
T
>
):
Promise
<
T
>
{
for
(
let
run
=
1
;
run
<=
10
;
run
++
)
{
try
{
return
await
fn
();
}
catch
(
err
)
{
if
(
!
/ECONNRESET/
.
test
(
err
.
message
))
{
throw
err
;
}
const
millis
=
(
Math
.
random
()
*
200
)
+
(
50
*
Math
.
pow
(
1.5
,
run
));
console
.
log
(
`Creating build asset failed with ECONNRESET, retrying in
${
millis
}
ms...`
);
// maximum delay is 10th retry: ~3 seconds
await
new
Promise
(
c
=>
setTimeout
(
c
,
millis
));
}
}
throw
new
Error
(
'
Retried too many times
'
);
}
async
function
main
():
Promise
<
void
>
{
const
[,
,
platform
,
type
,
fileName
,
filePath
]
=
process
.
argv
;
const
quality
=
getEnv
(
'
VSCODE_QUALITY
'
);
...
...
build/azure-pipelines/common/createBuild.ts
浏览文件 @
0e885aaf
...
...
@@ -6,6 +6,7 @@
'
use strict
'
;
import
{
CosmosClient
}
from
'
@azure/cosmos
'
;
import
{
retry
}
from
'
./retry
'
;
if
(
process
.
argv
.
length
!==
3
)
{
console
.
error
(
'
Usage: node createBuild.js VERSION
'
);
...
...
@@ -48,7 +49,7 @@ async function main(): Promise<void> {
const
client
=
new
CosmosClient
({
endpoint
:
process
.
env
[
'
AZURE_DOCUMENTDB_ENDPOINT
'
]
!
,
key
:
process
.
env
[
'
AZURE_DOCUMENTDB_MASTERKEY
'
]
});
const
scripts
=
client
.
database
(
'
builds
'
).
container
(
quality
).
scripts
;
await
scripts
.
storedProcedure
(
'
createBuild
'
).
execute
(
''
,
[{
...
build
,
_partitionKey
:
''
}]
);
await
retry
(()
=>
scripts
.
storedProcedure
(
'
createBuild
'
).
execute
(
''
,
[{
...
build
,
_partitionKey
:
''
}])
);
}
main
().
then
(()
=>
{
...
...
build/azure-pipelines/common/releaseBuild.ts
浏览文件 @
0e885aaf
...
...
@@ -6,6 +6,7 @@
'
use strict
'
;
import
{
CosmosClient
}
from
'
@azure/cosmos
'
;
import
{
retry
}
from
'
./retry
'
;
function
getEnv
(
name
:
string
):
string
{
const
result
=
process
.
env
[
name
];
...
...
@@ -58,7 +59,7 @@ async function main(): Promise<void> {
console
.
log
(
`Releasing build
${
commit
}
...`
);
const
scripts
=
client
.
database
(
'
builds
'
).
container
(
quality
).
scripts
;
await
scripts
.
storedProcedure
(
'
releaseBuild
'
).
execute
(
''
,
[
commit
]
);
await
retry
(()
=>
scripts
.
storedProcedure
(
'
releaseBuild
'
).
execute
(
''
,
[
commit
])
);
}
main
().
then
(()
=>
{
...
...
build/azure-pipelines/common/retry.ts
0 → 100644
浏览文件 @
0e885aaf
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
export
async
function
retry
<
T
>
(
fn
:
()
=>
Promise
<
T
>
):
Promise
<
T
>
{
for
(
let
run
=
1
;
run
<=
10
;
run
++
)
{
try
{
return
await
fn
();
}
catch
(
err
)
{
if
(
!
/ECONNRESET/
.
test
(
err
.
message
))
{
throw
err
;
}
const
millis
=
(
Math
.
random
()
*
200
)
+
(
50
*
Math
.
pow
(
1.5
,
run
));
console
.
log
(
`Failed with ECONNRESET, retrying in
${
millis
}
ms...`
);
// maximum delay is 10th retry: ~3 seconds
await
new
Promise
(
c
=>
setTimeout
(
c
,
millis
));
}
}
throw
new
Error
(
'
Retried too many times
'
);
}
build/azure-pipelines/common/sync-mooncake.ts
浏览文件 @
0e885aaf
...
...
@@ -9,6 +9,7 @@ import * as url from 'url';
import
*
as
azure
from
'
azure-storage
'
;
import
*
as
mime
from
'
mime
'
;
import
{
CosmosClient
}
from
'
@azure/cosmos
'
;
import
{
retry
}
from
'
./retry
'
;
function
log
(...
args
:
any
[])
{
console
.
log
(...[
`[
${
new
Date
().
toISOString
()}
]`
,
...
args
]);
...
...
@@ -99,8 +100,8 @@ async function sync(commit: string, quality: string): Promise<void> {
log
(
` Updating build in DB...`
);
const
mooncakeUrl
=
`
${
process
.
env
[
'
MOONCAKE_CDN_URL
'
]}${
blobPath
}
`
;
await
container
.
scripts
.
storedProcedure
(
'
setAssetMooncakeUrl
'
)
.
execute
(
''
,
[
commit
,
asset
.
platform
,
asset
.
type
,
mooncakeUrl
]);
await
retry
(()
=>
container
.
scripts
.
storedProcedure
(
'
setAssetMooncakeUrl
'
)
.
execute
(
''
,
[
commit
,
asset
.
platform
,
asset
.
type
,
mooncakeUrl
])
)
;
log
(
` Done ✔️`
);
}
catch
(
err
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录