Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

added re-generating and writing the Volume UUID if it is empty (#6568)

Aleksey Kosovef4eda076186
diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go
index 76e3afbdfc..26164ffc3e 100644
--- a/weed/stats/metrics.go
+++ b/weed/stats/metrics.go
@@ -1,7 +1,6 @@
package stats
import (
- "log"
"net"
"net/http"
"os"
@@ -436,7 +435,7 @@ func StartMetricsServer(ip string, port int) {
return
}
http.Handle("/metrics", promhttp.HandlerFor(Gather, promhttp.HandlerOpts{}))
- log.Fatal(http.ListenAndServe(JoinHostPort(ip, port), nil))
+ glog.Fatal(http.ListenAndServe(JoinHostPort(ip, port), nil))
}
func SourceName(port uint32) string {
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index dd78735d27..47f1b3d6fa 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -40,21 +40,28 @@ type DiskLocation struct {
func GenerateDirUuid(dir string) (dirUuidString string, err error) {
glog.V(1).Infof("Getting uuid of volume directory:%s", dir)
- dirUuidString = ""
fileName := dir + "/vol_dir.uuid"
if !util.FileExists(fileName) {
- dirUuid, _ := uuid.NewRandom()
- dirUuidString = dirUuid.String()
- writeErr := util.WriteFile(fileName, []byte(dirUuidString), 0644)
- if writeErr != nil {
- return "", fmt.Errorf("failed to write uuid to %s : %v", fileName, writeErr)
- }
+ dirUuidString, err = writeNewUuid(fileName)
} else {
uuidData, readErr := os.ReadFile(fileName)
if readErr != nil {
return "", fmt.Errorf("failed to read uuid from %s : %v", fileName, readErr)
}
- dirUuidString = string(uuidData)
+ if len(uuidData) > 0 {
+ dirUuidString = string(uuidData)
+ } else {
+ dirUuidString, err = writeNewUuid(fileName)
+ }
+ }
+ return dirUuidString, err
+}
+
+func writeNewUuid(fileName string) (string, error) {
+ dirUuid, _ := uuid.NewRandom()
+ dirUuidString := dirUuid.String()
+ if err := util.WriteFile(fileName, []byte(dirUuidString), 0644); err != nil {
+ return "", fmt.Errorf("failed to write uuid to %s : %v", fileName, err)
}
return dirUuidString, nil
}