apache / apache/cloudstack

Nas backup restore fails if the backup repository mount options have a trailing space

未关闭 适合新手
#14,013 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
component:backup
主要语言
Java
星标
3.1k
派生
1.4k
平均合并
6 天 19 小时
30 天内合并 PR
32

描述

### problem

Backup works because mount options are processed inside the shell script `nasbackup.sh` where trailing spaces are not a problem.

But restore (`LibvirtRestoreBackupCommandWrapper`) builds and runs mount in Java

```

if (StringUtils.isNotBlank(mountOptions)) {
mountCmd.add("-o");
mountCmd.add(mountOptions);
}
Script.executeCommand(mountCmd.toArray(new String[0]));

```
Script.executeCommand(String...) builds a ProcessBuilder argument list
mount receives the literal -o "vers=4.1 ". libmount splits options only on commas, so the trailing blank stays glued to the last option, and mount.nfs/the kernel rejects it as a malformed or unknown option ("an incorrect mount option was specified").

`WARN utils.script.Script (logid:435302bd) Process [445800] for command [sudo /usr/bin/mount -t nfs encountered the error: [mount.nfs: an incorrect mount option was specified for /usr/share/cloudstack-agent/tmp/csbackup...`

### versions

ACS 4.22.1

### The steps to reproduce the bug

1. Create a backup repository - specify mount options (`vers=4.1 `) with a trailing space
2. Create backup
3. Restore backup - it fails
...

### What to do about it?

Trim trailing whitespaces before using the mount options

贡献指南

打开贡献指南

调研方向

从 LibvirtRestoreBackupCommandWrapper 开始,检查 mountOptions 如何传递给 Script.executeCommand;将其与 nasbackup.sh 中的 shell 处理进行比较。使用带有尾随空白的存储库选项重现恢复过程,然后验证恢复成功,并确认现有的 mount 命令行为保持不变。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, shell
领域
backend, infrastructure
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
活跃
描述清晰度
描述清楚
新手友好度
76/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。