Skip to content

Commit 2ecaad9

Browse files
committed
fix: ossMountConfig endpoint and diff
1 parent e337178 commit 2ecaad9

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

__tests__/ut/subCommands/deploy/impl/function_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ describe('Service', () => {
757757
{
758758
mountDir: `/mnt/oss_test-function`,
759759
bucketName: 'test-oss-bucket',
760-
endpoint: 'https://oss-cn-hangzhou.aliyuncs.com',
760+
endpoint: 'http://oss-cn-hangzhou-internal.aliyuncs.com',
761761
bucketPath: `/test-function`,
762762
readOnly: false,
763763
},

src/resources/fc/impl/replace-function-config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default function (_local: any, _remote: any) {
1616

1717
// 线上配置如果存在,则需要将 auto 资源替换为线上资源配置
1818
if (remote) {
19-
const { remoteNasConfig, remoteVpcConfig, remoteLogConfig, remoteRole } =
19+
const { remoteNasConfig, remoteVpcConfig, remoteLogConfig, remoteRole, remoteOssConfig } =
2020
getRemoteResourceConfig(remote);
21-
const { nasAuto, vpcAuto, slsAuto, roleAuto } = computeLocalAuto(local);
21+
const { nasAuto, vpcAuto, slsAuto, roleAuto, ossAuto } = computeLocalAuto(local);
2222
logger.debug(
2323
`Init local compute local auto, nasAuto: ${nasAuto}; vpcAuto: ${vpcAuto}; slsAuto: ${slsAuto}; roleAuto: ${roleAuto}`,
2424
);
@@ -73,6 +73,10 @@ export default function (_local: any, _remote: any) {
7373
_.set(local, 'logConfig', remoteLogConfig);
7474
}
7575

76+
if (ossAuto && !_.isEmpty(remoteOssConfig?.mountPoints)){
77+
_.set(local, 'ossMountConfig', remoteOssConfig);
78+
}
79+
7680
if (!local.role) {
7781
if (roleAuto) {
7882
_.set(local, 'role', _.isString(remoteRole) && remoteRole !== '' ? remoteRole : 'auto');

src/resources/fc/impl/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import { INasConfig, IVpcConfig, ILogConfig, Runtime } from '../../../interface';
2+
import { INasConfig, IVpcConfig, ILogConfig, Runtime, IOssMountConfig } from '../../../interface';
33
import { isAuto, isAutoVpcConfig } from '../../../utils';
44
import logger from '../../../logger';
55
import { isDebugMode } from '@serverless-devs/utils';
@@ -24,8 +24,9 @@ export function getRemoteResourceConfig(remote) {
2424
const remoteNasConfig = _.get(remote, 'nasConfig') as INasConfig;
2525
const remoteVpcConfig = _.get(remote, 'vpcConfig') as IVpcConfig;
2626
const remoteLogConfig = _.get(remote, 'logConfig') as ILogConfig;
27+
const remoteOssConfig = _.get(remote, 'ossMountConfig') as IOssMountConfig;
2728
const remoteRole = _.get(remote, 'role');
28-
return { remoteNasConfig, remoteVpcConfig, remoteLogConfig, remoteRole };
29+
return { remoteNasConfig, remoteVpcConfig, remoteLogConfig, remoteRole, remoteOssConfig };
2930
}
3031

3132
/**

src/resources/oss/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class OSS {
1717
securityToken: credentials.SecurityToken,
1818
endpoint: ossEndpoint,
1919
regionId: region,
20-
timeout: process.env.OSS_TIMEOUT || 60000,
20+
timeout: process.env.OSS_CLIENT_TIMEOUT || 60000,
2121
});
2222
this.client = new Oss();
2323
}

src/subCommands/deploy/impl/function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ ossMountConfig:
375375
mountPoints:
376376
- mountDir: /mnt/oss_${functionName}
377377
bucketName: ${ossBucket}
378-
endpoint: ${ossEndpoint}
378+
endpoint: http://oss-${region}-internal.aliyuncs.com
379379
bucketPath: /${functionName}
380380
readOnly: false\n`),
381381
);
@@ -385,7 +385,7 @@ ossMountConfig:
385385
{
386386
mountDir: `/mnt/oss_${functionName}`,
387387
bucketName: ossBucket,
388-
endpoint: ossEndpoint,
388+
endpoint: `http://oss-${region}-internal.aliyuncs.com`,
389389
bucketPath: `/${functionName}`,
390390
readOnly: false,
391391
},

0 commit comments

Comments
 (0)