Fix missing snapshot mount directory.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-03-19 20:12:23 +01:00
parent 474470c6d8
commit d61405b3ca

14
main.go
View File

@@ -327,8 +327,8 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
if expectedSnapshots, err := generateSnapshotsFromRulesForNow(strings.TrimSpace(string(snapshotRulesB))); err == nil {
log.WithFields(log.Fields{"name": r.Name, "expectedSnapshots": expectedSnapshots}).Trace("Expected snapshots")
if existingSnapshotsB, err := applyEnv(exec.Command("/sbin/mount.objectivefs", "list", "-sz", v.Fs), v.Env).Output(); err == nil {
log.WithFields(log.Fields{"name": r.Name, "existingSnapshots": existingSnapshotsB}).Trace("Existing snapshots")
if existingSnapshots, err := parseExistingSnapshots(string(existingSnapshotsB), v.Fs); err == nil {
log.WithFields(log.Fields{"name": r.Name, "existingSnapshots": existingSnapshots}).Trace("Existing snapshots")
if existingMounts, err := getMountedSnaphots(snapshotsPath); err == nil {
log.WithFields(log.Fields{"name": r.Name, "existingMounts": existingMounts}).Trace("Existing snapshot mounts")
@@ -357,11 +357,15 @@ func (d *ofsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
// Add new mounts
for i, name := range setMinus(setIntersect(existingSnapshots, expectedSnapshots), existingMounts) {
dest := filepath.Join(snapshotsPath, i)
// Note: There is a missing "mount" argument so the mount continues running in a background process
if err := applyEnv(exec.Command("/sbin/mount.objectivefs", name, dest), v.Env).Run(); err != nil {
log.WithFields(log.Fields{"name": r.Name, "snapshot": i}).Warn("Failed to mount a new snapshot.")
if err := os.Mkdir(dest, os.ModePerm); err == nil || os.IsExist(err) {
// Note: There is a missing "mount" argument so the mount continues running in a background process
if err := applyEnv(exec.Command("/sbin/mount.objectivefs", name, dest), v.Env).Run(); err != nil {
log.WithFields(log.Fields{"name": r.Name, "snapshot": i}).Warn("Failed to mount a new snapshot.")
} else {
log.WithFields(log.Fields{"name": r.Name, "snapshot": i}).Debug("Snapshot mounted.")
}
} else {
log.WithFields(log.Fields{"name": r.Name, "snapshot": i}).Debug("Snapshot mounted.")
log.WithFields(log.Fields{"name": r.Name, "snapshot": i}).Warn("Failed to create directory for a snapshot.")
}
}
} else {