Skip to content

Fix nas config and logConfig#135

Merged
rsonghuster merged 1 commit intomasterfrom
fix-nasConfig
Jan 20, 2026
Merged

Fix nas config and logConfig#135
rsonghuster merged 1 commit intomasterfrom
fix-nasConfig

Conversation

@liuzewen99
Copy link
Copy Markdown
Collaborator

No description provided.

@liuzewen99 liuzewen99 force-pushed the fix-nasConfig branch 4 times, most recently from abbd147 to b4c3f0d Compare January 19, 2026 10:20
Comment thread src/subCommands/deploy/impl/function.ts Outdated
enableInstanceMetrics: true
enableRequestMetrics: true
logBeginRule: DefaultRegex
enableInstanceMetrics: ${customFields.enableInstanceMetrics}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个感觉有点问题啊,不应该是跟 376-380 行一样的逻辑吗

Comment thread src/subCommands/deploy/impl/function.ts Outdated
const { project, logstore } = await sls.deploy();
const logAutoConfig = parseAutoConfig(this.local.logConfig as string);
const logParams = logAutoConfig?.params || {};
const existingLogConfig =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里已经是 sls Auto 的逻辑了, 为什么还有 existingLogConfig?

handler: index.handler
memorySize: 128
timeout: 60
nasConfig: auto|mountDir=/custom/nas/mount/path|serverAddr=/custom/nas/mount/path
Copy link
Copy Markdown
Contributor

@rsonghuster rsonghuster Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mountDir 一般是 /home 或者 /mnt 开头, 你这个测试起来应该跑不过

Image

Comment thread src/subCommands/model/index.ts Outdated
const customMountDir = params.mountDir
? validateAndNormalizePath(params.mountDir, 'mountDir')
: `/mnt/${functionName}`;
const customServerAddr = params.serverAddr ? params.serverAddr : `${functionName}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 params.serverAddr 名字叫 params.nasDir 更容易理解点, 而且和 fc 的 serverAddr 没有冲突

Comment thread src/subCommands/model/index.ts Outdated
let serverAddr = `${mountTargetDomain}:/${functionName}`;
const nasAutoConfig = parseAutoConfig(this.local.nasConfig as string);
const params = nasAutoConfig?.params || {};
const customMountDir = params.mountDir
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customMountDir 改成 fcDir 吧,更容易理解点

Comment thread src/subCommands/model/index.ts Outdated
const nasAutoConfig = parseAutoConfig(this.local.nasConfig as string);
const params = nasAutoConfig?.params || {};
const customMountDir = params.mountDir
? validateAndNormalizePath(params.mountDir, 'mountDir')
Copy link
Copy Markdown
Contributor

@rsonghuster rsonghuster Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果这个函数仅仅是校验 fcDir

Image

我建议使用更科学的代码, 比如:

  1. 必须是 / 开头
  2. /mnt/ 和 /mnt 这种没有子目录的不被允许
  3. 这些前缀开头不被允许
    [
    '/bin', '/boot', '/dev', '/etc', '/lib', '/lib64',
    '/media', '/opt', '/proc', '/root', '/run',
    '/sbin', '/srv', '/sys', '/usr', '/var'
    ]
  4. 长度不要超过 128

Comment thread src/utils/index.ts Outdated
* 验证并规范化路径
*/
export function validateAndNormalizePath(path: string, paramName = 'path'): string {
if (typeof path !== 'string') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

265-286 行没有任何意思, 不满足直接报错就好了

Comment thread src/utils/index.ts Outdated
if (normalizedPath === prefix || normalizedPath.startsWith(`${prefix}/`)) {
const message = `Invalid ${paramName}, ${prefix} and its subdirectories are not allowed`;
if (logger) logger.warn(message);
return '/';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接报错

Comment thread src/utils/index.ts Outdated
if (normalizedPath === '/mnt' || normalizedPath === '/mnt/') {
const message = `Invalid ${paramName}, /mnt without subdirectory is not allowed`;
if (logger) logger.warn(message);
return '/';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接报错, 你传给 fc, fc 那边还是会报错, 还不如直接拦了

Comment thread src/utils/index.ts Outdated
/**
* 验证并规范化路径
*/
export function validateAndNormalizePath(path: string, paramName = 'path'): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

函数validateAndNormalizePath名字就叫 checkFcDir , 语义明确点

Comment thread src/utils/index.ts Outdated
}

// 检查 /mnt 是否为顶级目录且没有子目录
if (normalizedPath === '/mnt' || normalizedPath === '/mnt/') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我只是举个例子啊! 不是固定的 /mnt 。。。。。

@liuzewen99 liuzewen99 force-pushed the fix-nasConfig branch 3 times, most recently from ad984e2 to 8c3890c Compare January 20, 2026 08:53
@rsonghuster rsonghuster merged commit 0cb5e83 into master Jan 20, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants