mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: cleanup s3 mount directory before glance start (#14167)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user