fix: cleanup s3 mount directory before glance start (#14167)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2022-04-28 16:49:57 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 3a4f2b4183
commit 9410f3165a
+15 -11
View File
@@ -177,22 +177,26 @@ func initS3() {
log.Fatalf("failed write s3 pass file")
}
}()
cleanS3Dir := func() {
// check the s3 mount point has been mounted by previous glance instance
// if it is mounted, just wait
for {
if err := procutils.NewRemoteCommandAsFarAsPossible("umount", options.Options.S3MountPoint).Run(); err == nil {
time.Sleep(time.Second)
} else {
break
}
}
}
cleanS3Dir()
if !fileutils2.Exists(options.Options.S3MountPoint) {
err := os.MkdirAll(options.Options.S3MountPoint, 0755)
if err != nil {
log.Fatalf("fail to create %s: %s", options.Options.S3MountPoint, err)
}
}
// check the s3 mount point has been mounted by previous glance instance
// if it is mounted, just wait
for {
if err := procutils.NewRemoteCommandAsFarAsPossible("mountpoint", options.Options.S3MountPoint).Run(); err == nil {
// sleep 1 second
procutils.NewRemoteCommandAsFarAsPossible("umount", options.Options.S3MountPoint).Run()
time.Sleep(time.Second)
} else {
break
}
} else {
cleanS3Dir()
}
out, err := procutils.NewCommand("s3fs",