apache / apache/cloudstack

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

Offen Anfängerfreundlich
#14,013 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
component:backup
Vorherrschende Sprache
Java
Sterne
3.1k
Forks
1.4k
Ø Merge
6 T. 19 Std.
Gemergte PRs (30 T.)
32

Beschreibung

### 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne bei LibvirtRestoreBackupCommandWrapper und untersuche, wie mountOptions an Script.executeCommand übergeben werden; vergleiche dies mit der Shell-Verarbeitung in nasbackup.sh. Reproduziere die Wiederherstellung mithilfe einer Repository-Option mit nachgestellten Leerzeichen und überprüfe anschließend, dass die Wiederherstellung erfolgreich ist und das bestehende Verhalten des Mount-Befehls unverändert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, shell
Bereich
backend, infrastructure
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
76/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.