Start using error wrapping with fmt.Errorf (#8588)

Use fatih/errwrap to fix all the code to use
error wrapping with fmt.Errorf()
master
Harshavardhana 5 years ago committed by GitHub
parent 0bfd20a8e3
commit 5d3d57c12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/bucket-handlers.go
  2. 132
      cmd/config-migrate.go
  3. 2
      cmd/disk-cache-backend.go
  4. 2
      cmd/endpoint.go
  5. 4
      cmd/etcd.go
  6. 6
      cmd/format-xl.go
  7. 7
      cmd/object-api-multipart_test.go
  8. 2
      cmd/os-reliable.go
  9. 2
      cmd/posix_test.go
  10. 14
      cmd/prepare-storage.go
  11. 6
      cmd/server-main.go
  12. 8
      cmd/sts-handlers.go
  13. 6
      cmd/test-utils_test.go
  14. 6
      cmd/update.go
  15. 6
      cmd/xl-sets.go
  16. 2
      mint/run/core/aws-sdk-go/quick-tests.go
  17. 2
      mint/run/core/healthcheck/healthcheck.go
  18. 2
      mint/run/core/security/tls-tests.go
  19. 2
      mint/run/core/worm/quick-worm-tests.go
  20. 2
      pkg/event/target/mqtt.go
  21. 4
      pkg/event/target/store.go
  22. 4
      pkg/quick/encoding.go
  23. 2
      pkg/s3select/sql/statement.go

@ -117,7 +117,7 @@ func initFederatorBackend(buckets []BucketInfo, objLayer ObjectLayer) {
// We go to here, so we know the bucket no longer exists, but is registered in DNS to this server // We go to here, so we know the bucket no longer exists, but is registered in DNS to this server
if err := globalDNSConfig.DeleteRecord(dnsBuckets[index]); err != nil { if err := globalDNSConfig.DeleteRecord(dnsBuckets[index]); err != nil {
return fmt.Errorf("Failed to remove DNS entry for %s due to %v", dnsBuckets[index].Key, err) return fmt.Errorf("Failed to remove DNS entry for %s due to %w", dnsBuckets[index].Key, err)
} }
return nil return nil

@ -246,7 +246,7 @@ func purgeV1() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘1’. %v", err) return fmt.Errorf("Unable to load config version ‘1’. %w", err)
} }
if cv1.Version != "1" { if cv1.Version != "1" {
return fmt.Errorf("unrecognized config version ‘%s’", cv1.Version) return fmt.Errorf("unrecognized config version ‘%s’", cv1.Version)
@ -267,7 +267,7 @@ func migrateV2ToV3() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘2’. %v", err) return fmt.Errorf("Unable to load config version ‘2’. %w", err)
} }
if cv2.Version != "2" { if cv2.Version != "2" {
return nil return nil
@ -275,7 +275,7 @@ func migrateV2ToV3() error {
cred, err := auth.CreateCredentials(cv2.Credentials.AccessKey, cv2.Credentials.SecretKey) cred, err := auth.CreateCredentials(cv2.Credentials.AccessKey, cv2.Credentials.SecretKey)
if err != nil { if err != nil {
return fmt.Errorf("Invalid credential in V2 configuration file. %v", err) return fmt.Errorf("Invalid credential in V2 configuration file. %w", err)
} }
srvConfig := &configV3{} srvConfig := &configV3{}
@ -308,7 +308,7 @@ func migrateV2ToV3() error {
srvConfig.Logger.Syslog = slogger srvConfig.Logger.Syslog = slogger
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv2.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv2.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version)
@ -326,7 +326,7 @@ func migrateV3ToV4() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘3’. %v", err) return fmt.Errorf("Unable to load config version ‘3’. %w", err)
} }
if cv3.Version != "3" { if cv3.Version != "3" {
return nil return nil
@ -346,7 +346,7 @@ func migrateV3ToV4() error {
srvConfig.Logger.Syslog = cv3.Logger.Syslog srvConfig.Logger.Syslog = cv3.Logger.Syslog
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv3.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv3.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version)
@ -364,7 +364,7 @@ func migrateV4ToV5() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘4’. %v", err) return fmt.Errorf("Unable to load config version ‘4’. %w", err)
} }
if cv4.Version != "4" { if cv4.Version != "4" {
return nil return nil
@ -387,7 +387,7 @@ func migrateV4ToV5() error {
srvConfig.Logger.Redis.Enable = false srvConfig.Logger.Redis.Enable = false
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv4.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv4.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version)
@ -405,7 +405,7 @@ func migrateV5ToV6() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘5’. %v", err) return fmt.Errorf("Unable to load config version ‘5’. %w", err)
} }
if cv5.Version != "5" { if cv5.Version != "5" {
return nil return nil
@ -476,7 +476,7 @@ func migrateV5ToV6() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv5.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv5.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version)
@ -494,7 +494,7 @@ func migrateV6ToV7() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘6’. %v", err) return fmt.Errorf("Unable to load config version ‘6’. %w", err)
} }
if cv6.Version != "6" { if cv6.Version != "6" {
return nil return nil
@ -532,7 +532,7 @@ func migrateV6ToV7() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv6.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv6.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version)
@ -550,7 +550,7 @@ func migrateV7ToV8() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘7’. %v", err) return fmt.Errorf("Unable to load config version ‘7’. %w", err)
} }
if cv7.Version != "7" { if cv7.Version != "7" {
return nil return nil
@ -595,7 +595,7 @@ func migrateV7ToV8() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv7.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv7.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version)
@ -612,7 +612,7 @@ func migrateV8ToV9() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘8’. %v", err) return fmt.Errorf("Unable to load config version ‘8’. %w", err)
} }
if cv8.Version != "8" { if cv8.Version != "8" {
return nil return nil
@ -665,7 +665,7 @@ func migrateV8ToV9() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv8.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv8.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version)
@ -682,7 +682,7 @@ func migrateV9ToV10() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘9’. %v", err) return fmt.Errorf("Unable to load config version ‘9’. %w", err)
} }
if cv9.Version != "9" { if cv9.Version != "9" {
return nil return nil
@ -733,7 +733,7 @@ func migrateV9ToV10() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv9.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv9.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version)
@ -750,7 +750,7 @@ func migrateV10ToV11() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘10’. %v", err) return fmt.Errorf("Unable to load config version ‘10’. %w", err)
} }
if cv10.Version != "10" { if cv10.Version != "10" {
return nil return nil
@ -804,7 +804,7 @@ func migrateV10ToV11() error {
srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} srvConfig.Notify.Kafka["1"] = target.KafkaArgs{}
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv10.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv10.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version)
@ -821,7 +821,7 @@ func migrateV11ToV12() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘11’. %v", err) return fmt.Errorf("Unable to load config version ‘11’. %w", err)
} }
if cv11.Version != "11" { if cv11.Version != "11" {
return nil return nil
@ -902,7 +902,7 @@ func migrateV11ToV12() error {
} }
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv11.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv11.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version)
@ -918,7 +918,7 @@ func migrateV12ToV13() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘12’. %v", err) return fmt.Errorf("Unable to load config version ‘12’. %w", err)
} }
if cv12.Version != "12" { if cv12.Version != "12" {
return nil return nil
@ -982,7 +982,7 @@ func migrateV12ToV13() error {
srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} srvConfig.Notify.Webhook["1"] = target.WebhookArgs{}
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv12.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv12.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version)
@ -998,7 +998,7 @@ func migrateV13ToV14() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘13’. %v", err) return fmt.Errorf("Unable to load config version ‘13’. %w", err)
} }
if cv13.Version != "13" { if cv13.Version != "13" {
return nil return nil
@ -1067,7 +1067,7 @@ func migrateV13ToV14() error {
srvConfig.Browser = true srvConfig.Browser = true
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv13.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv13.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version)
@ -1083,7 +1083,7 @@ func migrateV14ToV15() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘14’. %v", err) return fmt.Errorf("Unable to load config version ‘14’. %w", err)
} }
if cv14.Version != "14" { if cv14.Version != "14" {
return nil return nil
@ -1156,7 +1156,7 @@ func migrateV14ToV15() error {
srvConfig.Browser = cv14.Browser srvConfig.Browser = cv14.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv14.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv14.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version)
@ -1173,7 +1173,7 @@ func migrateV15ToV16() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘15’. %v", err) return fmt.Errorf("Unable to load config version ‘15’. %w", err)
} }
if cv15.Version != "15" { if cv15.Version != "15" {
return nil return nil
@ -1246,7 +1246,7 @@ func migrateV15ToV16() error {
srvConfig.Browser = cv15.Browser srvConfig.Browser = cv15.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv15.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv15.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version)
@ -1263,7 +1263,7 @@ func migrateV16ToV17() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘16’. %v", err) return fmt.Errorf("Unable to load config version ‘16’. %w", err)
} }
if cv16.Version != "16" { if cv16.Version != "16" {
return nil return nil
@ -1367,7 +1367,7 @@ func migrateV16ToV17() error {
srvConfig.Browser = cv16.Browser srvConfig.Browser = cv16.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv16.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv16.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version)
@ -1384,7 +1384,7 @@ func migrateV17ToV18() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘17’. %v", err) return fmt.Errorf("Unable to load config version ‘17’. %w", err)
} }
if cv17.Version != "17" { if cv17.Version != "17" {
return nil return nil
@ -1471,7 +1471,7 @@ func migrateV17ToV18() error {
srvConfig.Browser = cv17.Browser srvConfig.Browser = cv17.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv17.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv17.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version)
@ -1486,7 +1486,7 @@ func migrateV18ToV19() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘18’. %v", err) return fmt.Errorf("Unable to load config version ‘18’. %w", err)
} }
if cv18.Version != "18" { if cv18.Version != "18" {
return nil return nil
@ -1577,7 +1577,7 @@ func migrateV18ToV19() error {
srvConfig.Browser = cv18.Browser srvConfig.Browser = cv18.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv18.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv18.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version)
@ -1592,7 +1592,7 @@ func migrateV19ToV20() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘18’. %v", err) return fmt.Errorf("Unable to load config version ‘18’. %w", err)
} }
if cv19.Version != "19" { if cv19.Version != "19" {
return nil return nil
@ -1682,7 +1682,7 @@ func migrateV19ToV20() error {
srvConfig.Browser = cv19.Browser srvConfig.Browser = cv19.Browser
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv19.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv19.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version)
@ -1697,7 +1697,7 @@ func migrateV20ToV21() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘20’. %v", err) return fmt.Errorf("Unable to load config version ‘20’. %w", err)
} }
if cv20.Version != "20" { if cv20.Version != "20" {
return nil return nil
@ -1786,7 +1786,7 @@ func migrateV20ToV21() error {
srvConfig.Domain = cv20.Domain srvConfig.Domain = cv20.Domain
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv20.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv20.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version)
@ -1801,7 +1801,7 @@ func migrateV21ToV22() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘21’. %v", err) return fmt.Errorf("Unable to load config version ‘21’. %w", err)
} }
if cv21.Version != "21" { if cv21.Version != "21" {
return nil return nil
@ -1890,7 +1890,7 @@ func migrateV21ToV22() error {
srvConfig.Domain = cv21.Domain srvConfig.Domain = cv21.Domain
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv21.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv21.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version)
@ -1905,7 +1905,7 @@ func migrateV22ToV23() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘22’. %v", err) return fmt.Errorf("Unable to load config version ‘22’. %w", err)
} }
if cv22.Version != "22" { if cv22.Version != "22" {
return nil return nil
@ -2003,7 +2003,7 @@ func migrateV22ToV23() error {
srvConfig.Cache.Expiry = 90 srvConfig.Cache.Expiry = 90
if err = Save(configFile, srvConfig); err != nil { if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv22.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv22.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version)
@ -2018,7 +2018,7 @@ func migrateV23ToV24() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘23’. %v", err) return fmt.Errorf("Unable to load config version ‘23’. %w", err)
} }
if cv23.Version != "23" { if cv23.Version != "23" {
return nil return nil
@ -2116,7 +2116,7 @@ func migrateV23ToV24() error {
srvConfig.Cache.Expiry = cv23.Cache.Expiry srvConfig.Cache.Expiry = cv23.Cache.Expiry
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv23.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv23.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv23.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv23.Version, srvConfig.Version)
@ -2131,7 +2131,7 @@ func migrateV24ToV25() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘24’. %v", err) return fmt.Errorf("Unable to load config version ‘24’. %w", err)
} }
if cv24.Version != "24" { if cv24.Version != "24" {
return nil return nil
@ -2234,7 +2234,7 @@ func migrateV24ToV25() error {
srvConfig.Cache.Expiry = cv24.Cache.Expiry srvConfig.Cache.Expiry = cv24.Cache.Expiry
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv24.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv24.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv24.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv24.Version, srvConfig.Version)
@ -2249,7 +2249,7 @@ func migrateV25ToV26() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config version ‘25’. %v", err) return fmt.Errorf("Unable to load config version ‘25’. %w", err)
} }
if cv25.Version != "25" { if cv25.Version != "25" {
return nil return nil
@ -2353,7 +2353,7 @@ func migrateV25ToV26() error {
srvConfig.Cache.MaxUse = 80 srvConfig.Cache.MaxUse = 80
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv25.Version, srvConfig.Version, err) return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv25.Version, srvConfig.Version, err)
} }
logger.Info(configMigrateMSGTemplate, configFile, cv25.Version, srvConfig.Version) logger.Info(configMigrateMSGTemplate, configFile, cv25.Version, srvConfig.Version)
@ -2371,7 +2371,7 @@ func migrateV26ToV27() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if srvConfig.Version != "26" { if srvConfig.Version != "26" {
@ -2386,7 +2386,7 @@ func migrateV26ToV27() error {
srvConfig.Logger.HTTP["1"] = logger.HTTP{} srvConfig.Logger.HTTP["1"] = logger.HTTP{}
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from ‘26’ to ‘27’. %v", err) return fmt.Errorf("Failed to migrate config from ‘26’ to ‘27’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "26", "27") logger.Info(configMigrateMSGTemplate, configFile, "26", "27")
@ -2404,7 +2404,7 @@ func migrateV27ToV28() error {
if os.IsNotExist(err) || os.IsPermission(err) { if os.IsNotExist(err) || os.IsPermission(err) {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if srvConfig.Version != "27" { if srvConfig.Version != "27" {
@ -2414,7 +2414,7 @@ func migrateV27ToV28() error {
srvConfig.Version = "28" srvConfig.Version = "28"
srvConfig.KMS = crypto.KMSConfig{} srvConfig.KMS = crypto.KMSConfig{}
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %v", err) return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "27", "28") logger.Info(configMigrateMSGTemplate, configFile, "27", "28")
@ -2534,7 +2534,7 @@ func migrateV27ToV28MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2549,7 +2549,7 @@ func migrateV27ToV28MinioSys(objAPI ObjectLayer) error {
cfg.KMS = crypto.KMSConfig{} cfg.KMS = crypto.KMSConfig{}
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %v", err) return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "27", "28") logger.Info(configMigrateMSGTemplate, configFile, "27", "28")
@ -2563,7 +2563,7 @@ func migrateV28ToV29MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2576,7 +2576,7 @@ func migrateV28ToV29MinioSys(objAPI ObjectLayer) error {
cfg.Version = "29" cfg.Version = "29"
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from ‘28’ to ‘29’. %v", err) return fmt.Errorf("Failed to migrate config from ‘28’ to ‘29’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "28", "29") logger.Info(configMigrateMSGTemplate, configFile, "28", "29")
@ -2590,7 +2590,7 @@ func migrateV29ToV30MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2608,7 +2608,7 @@ func migrateV29ToV30MinioSys(objAPI ObjectLayer) error {
cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator) cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator)
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from ‘29’ to ‘30’. %v", err) return fmt.Errorf("Failed to migrate config from ‘29’ to ‘30’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "29", "30") logger.Info(configMigrateMSGTemplate, configFile, "29", "30")
@ -2622,7 +2622,7 @@ func migrateV30ToV31MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2643,7 +2643,7 @@ func migrateV30ToV31MinioSys(objAPI ObjectLayer) error {
} }
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from ‘30’ to ‘31’. %v", err) return fmt.Errorf("Failed to migrate config from ‘30’ to ‘31’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "30", "31") logger.Info(configMigrateMSGTemplate, configFile, "30", "31")
@ -2657,7 +2657,7 @@ func migrateV31ToV32MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2673,7 +2673,7 @@ func migrateV31ToV32MinioSys(objAPI ObjectLayer) error {
cfg.Notify.NSQ["1"] = target.NSQArgs{} cfg.Notify.NSQ["1"] = target.NSQArgs{}
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from ‘31’ to ‘32’. %v", err) return fmt.Errorf("Failed to migrate config from ‘31’ to ‘32’. %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "31", "32") logger.Info(configMigrateMSGTemplate, configFile, "31", "32")
@ -2687,7 +2687,7 @@ func migrateV32ToV33MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound { if err == errConfigNotFound {
return nil return nil
} else if err != nil { } else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err) return fmt.Errorf("Unable to load config file. %w", err)
} }
if !ok { if !ok {
return nil return nil
@ -2701,7 +2701,7 @@ func migrateV32ToV33MinioSys(objAPI ObjectLayer) error {
cfg.Version = "33" cfg.Version = "33"
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil { if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from '32' to '33' . %v", err) return fmt.Errorf("Failed to migrate config from '32' to '33' . %w", err)
} }
logger.Info(configMigrateMSGTemplate, configFile, "32", "33") logger.Info(configMigrateMSGTemplate, configFile, "32", "33")

@ -124,7 +124,7 @@ type diskCache struct {
// Inits the disk cache dir if it is not initialized already. // Inits the disk cache dir if it is not initialized already.
func newDiskCache(dir string, expiry int, quotaPct int) (*diskCache, error) { func newDiskCache(dir string, expiry int, quotaPct int) (*diskCache, error) {
if err := os.MkdirAll(dir, 0777); err != nil { if err := os.MkdirAll(dir, 0777); err != nil {
return nil, fmt.Errorf("Unable to initialize '%s' dir, %s", dir, err) return nil, fmt.Errorf("Unable to initialize '%s' dir, %w", dir, err)
} }
cache := diskCache{ cache := diskCache{
dir: dir, dir: dir,

@ -118,7 +118,7 @@ func NewEndpoint(arg string) (ep Endpoint, e error) {
host, port, err = net.SplitHostPort(u.Host) host, port, err = net.SplitHostPort(u.Host)
if err != nil { if err != nil {
if !strings.Contains(err.Error(), "missing port in address") { if !strings.Contains(err.Error(), "missing port in address") {
return ep, fmt.Errorf("invalid URL endpoint format: %s", err) return ep, fmt.Errorf("invalid URL endpoint format: %w", err)
} }
host = u.Host host = u.Host

@ -32,9 +32,9 @@ func etcdErrToErr(err error, etcdEndpoints []string) error {
} }
switch err { switch err {
case context.DeadlineExceeded: case context.DeadlineExceeded:
return fmt.Errorf("%s %s", errEtcdUnreachable, etcdEndpoints) return fmt.Errorf("%w %s", errEtcdUnreachable, etcdEndpoints)
default: default:
return fmt.Errorf("unexpected error %s from etcd, please check your endpoints %s", err, etcdEndpoints) return fmt.Errorf("unexpected error %w from etcd, please check your endpoints %s", err, etcdEndpoints)
} }
} }

@ -489,7 +489,7 @@ func formatXLFixDeploymentID(endpoints Endpoints, storageDisks []StorageAPI, ref
formats, sErrs := loadFormatXLAll(storageDisks) formats, sErrs := loadFormatXLAll(storageDisks)
for i, sErr := range sErrs { for i, sErr := range sErrs {
if _, ok := formatCriticalErrors[sErr]; ok { if _, ok := formatCriticalErrors[sErr]; ok {
return fmt.Errorf("Disk %s: %s", endpoints[i], sErr) return fmt.Errorf("Disk %s: %w", endpoints[i], sErr)
} }
} }
@ -547,7 +547,7 @@ func formatXLFixLocalDeploymentID(endpoints Endpoints, storageDisks []StorageAPI
format.ID = refFormat.ID format.ID = refFormat.ID
if err := saveFormatXL(storageDisk, format); err != nil { if err := saveFormatXL(storageDisk, format); err != nil {
logger.LogIf(context.Background(), err) logger.LogIf(context.Background(), err)
return fmt.Errorf("Unable to save format.json, %s", err) return fmt.Errorf("Unable to save format.json, %w", err)
} }
} }
} }
@ -747,7 +747,7 @@ func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, driv
// Initialize meta volume, if volume already exists ignores it. // Initialize meta volume, if volume already exists ignores it.
if err := initFormatXLMetaVolume(storageDisks, formats); err != nil { if err := initFormatXLMetaVolume(storageDisks, formats); err != nil {
return format, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err) return format, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %w", err)
} }
// Save formats `format.json` across all disks. // Save formats `format.json` across all disks.

@ -237,8 +237,9 @@ func testPutObjectPartDiskNotFound(obj ObjectLayer, instanceType string, disks [
if err == nil { if err == nil {
t.Fatalf("Test %s: expected to fail but passed instead", instanceType) t.Fatalf("Test %s: expected to fail but passed instead", instanceType)
} }
// as majority of xl.json are not available, we expect uploadID to be not available. // as majority of xl.json are not available, we expect uploadID to be not available.
expectedErr1 := InsufficientReadQuorum{} expectedErr1 := BucketNotFound{Bucket: testCase.bucketName}
if err.Error() != expectedErr1.Error() { if err.Error() != expectedErr1.Error() {
t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr1, err) t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr1, err)
} }
@ -255,8 +256,8 @@ func testPutObjectPartDiskNotFound(obj ObjectLayer, instanceType string, disks [
} }
// As all disks at not available, bucket not found. // As all disks at not available, bucket not found.
expectedErr2 := errDiskNotFound expectedErr2 := BucketNotFound{Bucket: testCase.bucketName}
if err != errDiskNotFound { if err.Error() != expectedErr2.Error() {
t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr2, err) t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr2, err)
} }
} }

@ -139,7 +139,7 @@ func renameAll(srcFilePath, dstFilePath string) (err error) {
// directory" error message. Handle this specifically here. // directory" error message. Handle this specifically here.
return errFileAccessDenied return errFileAccessDenied
case isSysErrCrossDevice(err): case isSysErrCrossDevice(err):
return fmt.Errorf("%s (%s)->(%s)", errCrossDeviceLink, srcFilePath, dstFilePath) return fmt.Errorf("%w (%s)->(%s)", errCrossDeviceLink, srcFilePath, dstFilePath)
case os.IsNotExist(err): case os.IsNotExist(err):
return errFileNotFound return errFileNotFound
case os.IsExist(err): case os.IsExist(err):

@ -1351,7 +1351,7 @@ func TestPosixFormatFileChange(t *testing.T) {
} }
err = posixStorage.MakeVol(volume) err = posixStorage.MakeVol(volume)
if err != errDiskNotFound { if err != errVolumeExists {
t.Fatalf("MakeVol expected to fail with errDiskNotFound but failed with %s", err) t.Fatalf("MakeVol expected to fail with errDiskNotFound but failed with %s", err)
} }
} }

@ -67,7 +67,7 @@ func formatXLMigrateLocalEndpoints(endpoints Endpoints) error {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil return nil
} }
return fmt.Errorf("unable to access (%s) %s", formatPath, err) return fmt.Errorf("unable to access (%s) %w", formatPath, err)
} }
return formatXLMigrate(epPath) return formatXLMigrate(epPath)
}, index) }, index)
@ -96,11 +96,11 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil return nil
} }
return fmt.Errorf("unable to access (%s) %s", formatPath, err) return fmt.Errorf("unable to access (%s) %w", formatPath, err)
} }
if _, err := os.Stat(pathJoin(epPath, minioMetaTmpBucket+"-old")); err != nil { if _, err := os.Stat(pathJoin(epPath, minioMetaTmpBucket+"-old")); err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
return fmt.Errorf("unable to access (%s) %s", return fmt.Errorf("unable to access (%s) %w",
pathJoin(epPath, minioMetaTmpBucket+"-old"), pathJoin(epPath, minioMetaTmpBucket+"-old"),
err) err)
} }
@ -119,7 +119,7 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
tmpOld := pathJoin(epPath, minioMetaTmpBucket+"-old", mustGetUUID()) tmpOld := pathJoin(epPath, minioMetaTmpBucket+"-old", mustGetUUID())
if err := renameAll(pathJoin(epPath, minioMetaTmpBucket), if err := renameAll(pathJoin(epPath, minioMetaTmpBucket),
tmpOld); err != nil && err != errFileNotFound { tmpOld); err != nil && err != errFileNotFound {
return fmt.Errorf("unable to rename (%s -> %s) %s", return fmt.Errorf("unable to rename (%s -> %s) %w",
pathJoin(epPath, minioMetaTmpBucket), pathJoin(epPath, minioMetaTmpBucket),
tmpOld, tmpOld,
err) err)
@ -129,7 +129,7 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
go removeAll(pathJoin(epPath, minioMetaTmpBucket+"-old")) go removeAll(pathJoin(epPath, minioMetaTmpBucket+"-old"))
if err := mkdirAll(pathJoin(epPath, minioMetaTmpBucket), 0777); err != nil { if err := mkdirAll(pathJoin(epPath, minioMetaTmpBucket), 0777); err != nil {
return fmt.Errorf("unable to create (%s) %s", return fmt.Errorf("unable to create (%s) %w",
pathJoin(epPath, minioMetaTmpBucket), pathJoin(epPath, minioMetaTmpBucket),
err) err)
} }
@ -151,7 +151,7 @@ func validateXLFormats(format *formatXLV3, formats []*formatXLV3, endpoints Endp
continue continue
} }
if err := formatXLV3Check(format, formats[i]); err != nil { if err := formatXLV3Check(format, formats[i]); err != nil {
return fmt.Errorf("%s format error: %s", endpoints[i], err) return fmt.Errorf("%s format error: %w", endpoints[i], err)
} }
} }
if len(format.XL.Sets) != setCount { if len(format.XL.Sets) != setCount {
@ -189,7 +189,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
// Check if we have // Check if we have
for i, sErr := range sErrs { for i, sErr := range sErrs {
if _, ok := formatCriticalErrors[sErr]; ok { if _, ok := formatCriticalErrors[sErr]; ok {
return nil, fmt.Errorf("Disk %s: %s", endpoints[i], sErr) return nil, fmt.Errorf("Disk %s: %w", endpoints[i], sErr)
} }
} }

@ -234,7 +234,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
// Migrate all backend configs to encrypted backend, also handles rotation as well. // Migrate all backend configs to encrypted backend, also handles rotation as well.
if err = handleEncryptedConfigBackend(newObject, true); err != nil { if err = handleEncryptedConfigBackend(newObject, true); err != nil {
return fmt.Errorf("Unable to handle encrypted backend for config, iam and policies: %v", err) return fmt.Errorf("Unable to handle encrypted backend for config, iam and policies: %w", err)
} }
// **** WARNING **** // **** WARNING ****
@ -264,7 +264,7 @@ func initAllSubsystems(buckets []BucketInfo, newObject ObjectLayer) (err error)
// Migrating to encrypted backend on etcd should happen before initialization of // Migrating to encrypted backend on etcd should happen before initialization of
// IAM sub-systems, make sure that we do not move the above codeblock elsewhere. // IAM sub-systems, make sure that we do not move the above codeblock elsewhere.
if err = migrateIAMConfigsEtcdToEncrypted(globalEtcdClient); err != nil { if err = migrateIAMConfigsEtcdToEncrypted(globalEtcdClient); err != nil {
return fmt.Errorf("Unable to handle encrypted backend for iam and policies: %v", err) return fmt.Errorf("Unable to handle encrypted backend for iam and policies: %w", err)
} }
} }
@ -284,7 +284,7 @@ func initAllSubsystems(buckets []BucketInfo, newObject ObjectLayer) (err error)
// Initialize lifecycle system. // Initialize lifecycle system.
if err = globalLifecycleSys.Init(buckets, newObject); err != nil { if err = globalLifecycleSys.Init(buckets, newObject); err != nil {
return fmt.Errorf("Unable to initialize lifecycle system: %v", err) return fmt.Errorf("Unable to initialize lifecycle system: %w", err)
} }
return nil return nil

@ -476,11 +476,11 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
ldapConn, err := globalLDAPConfig.Connect() ldapConn, err := globalLDAPConfig.Connect()
if err != nil { if err != nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server connection failure: %v", err)) writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server connection failure: %w", err))
return return
} }
if ldapConn == nil { if ldapConn == nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server not configured: %v", err)) writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server not configured: %w", err))
return return
} }
@ -490,7 +490,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
usernameDN, _ := usernameSubs.Substitute(globalLDAPConfig.UsernameFormat) usernameDN, _ := usernameSubs.Substitute(globalLDAPConfig.UsernameFormat)
// Bind with user credentials to validate the password // Bind with user credentials to validate the password
if err = ldapConn.Bind(usernameDN, ldapPassword); err != nil { if err = ldapConn.Bind(usernameDN, ldapPassword); err != nil {
err = fmt.Errorf("LDAP authentication failure: %v", err) err = fmt.Errorf("LDAP authentication failure: %w", err)
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, err) writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, err)
return return
} }
@ -517,7 +517,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
sr, err := ldapConn.Search(searchRequest) sr, err := ldapConn.Search(searchRequest)
if err != nil { if err != nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP search failure: %v", err)) writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP search failure: %w", err))
return return
} }
for _, entry := range sr.Entries { for _, entry := range sr.Entries {

@ -2220,7 +2220,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
var err error var err error
priv, err = rsa.GenerateKey(crand.Reader, rsaBits) priv, err = rsa.GenerateKey(crand.Reader, rsaBits)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("failed to generate private key: %s", err) return nil, nil, fmt.Errorf("failed to generate private key: %w", err)
} }
notBefore := time.Now() notBefore := time.Now()
@ -2229,7 +2229,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := crand.Int(crand.Reader, serialNumberLimit) serialNumber, err := crand.Int(crand.Reader, serialNumberLimit)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("failed to generate serial number: %s", err) return nil, nil, fmt.Errorf("failed to generate serial number: %w", err)
} }
template := x509.Certificate{ template := x509.Certificate{
@ -2259,7 +2259,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
derBytes, err := x509.CreateCertificate(crand.Reader, &template, &template, publicKey(priv), priv) derBytes, err := x509.CreateCertificate(crand.Reader, &template, &template, publicKey(priv), priv)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("Failed to create certificate: %s", err) return nil, nil, fmt.Errorf("Failed to create certificate: %w", err)
} }
certOut := bytes.NewBuffer([]byte{}) certOut := bytes.NewBuffer([]byte{})

@ -95,14 +95,14 @@ func getModTime(path string) (t time.Time, err error) {
// Convert to absolute path // Convert to absolute path
absPath, err := filepath.Abs(path) absPath, err := filepath.Abs(path)
if err != nil { if err != nil {
return t, fmt.Errorf("Unable to get absolute path of %s. %s", path, err) return t, fmt.Errorf("Unable to get absolute path of %s. %w", path, err)
} }
// Version is minio non-standard, we will use minio binary's // Version is minio non-standard, we will use minio binary's
// ModTime as release time. // ModTime as release time.
fi, err := os.Stat(absPath) fi, err := os.Stat(absPath)
if err != nil { if err != nil {
return t, fmt.Errorf("Unable to get ModTime of %s. %s", absPath, err) return t, fmt.Errorf("Unable to get ModTime of %s. %w", absPath, err)
} }
// Return the ModTime // Return the ModTime
@ -385,7 +385,7 @@ func parseReleaseData(data string) (sha256Hex string, releaseTime time.Time, err
releaseTime, err = releaseTagToReleaseTime(nfields[1]) releaseTime, err = releaseTagToReleaseTime(nfields[1])
if err != nil { if err != nil {
err = fmt.Errorf("Unknown release tag format. %s", err) err = fmt.Errorf("Unknown release tag format. %w", err)
} }
return sha256Hex, releaseTime, err return sha256Hex, releaseTime, err

@ -1293,7 +1293,7 @@ func (s *xlSets) ReloadFormat(ctx context.Context, dryRun bool) (err error) {
// Look for acceptable heal errors, for any other // Look for acceptable heal errors, for any other
// errors we should simply quit and return. // errors we should simply quit and return.
if _, ok := formatHealErrors[sErr]; !ok { if _, ok := formatHealErrors[sErr]; !ok {
return fmt.Errorf("Disk %s: %s", s.endpoints[index], sErr) return fmt.Errorf("Disk %s: %w", s.endpoints[index], sErr)
} }
} }
} }
@ -1423,7 +1423,7 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe
// Look for acceptable heal errors, for any other // Look for acceptable heal errors, for any other
// errors we should simply quit and return. // errors we should simply quit and return.
if _, ok := formatHealErrors[sErr]; !ok { if _, ok := formatHealErrors[sErr]; !ok {
return res, fmt.Errorf("Disk %s: %s", s.endpoints[index], sErr) return res, fmt.Errorf("Disk %s: %w", s.endpoints[index], sErr)
} }
} }
} }
@ -1493,7 +1493,7 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe
// Initialize meta volume, if volume already exists ignores it, all disks which // Initialize meta volume, if volume already exists ignores it, all disks which
// are not found are ignored as well. // are not found are ignored as well.
if err = initFormatXLMetaVolume(storageDisks, tmpNewFormats); err != nil { if err = initFormatXLMetaVolume(storageDisks, tmpNewFormats); err != nil {
return madmin.HealResultItem{}, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err) return madmin.HealResultItem{}, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %w", err)
} }
// Save formats `format.json` across all disks. // Save formats `format.json` across all disks.

@ -85,7 +85,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data) serialized, err := json.Marshal(data)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
} }
return append(serialized, '\n'), nil return append(serialized, '\n'), nil
} }

@ -59,7 +59,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data) serialized, err := json.Marshal(data)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
} }
return append(serialized, '\n'), nil return append(serialized, '\n'), nil
} }

@ -219,7 +219,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data) serialized, err := json.Marshal(data)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
} }
return append(serialized, '\n'), nil return append(serialized, '\n'), nil
} }

@ -71,7 +71,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data) serialized, err := json.Marshal(data)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
} }
return append(serialized, '\n'), nil return append(serialized, '\n'), nil
} }

@ -229,7 +229,7 @@ func NewMQTTTarget(id string, args MQTTArgs, doneCh <-chan struct{}, loggerOnce
ok := token.WaitTimeout(reconnectInterval * time.Second) ok := token.WaitTimeout(reconnectInterval * time.Second)
if ok && token.Error() != nil { if ok && token.Error() != nil {
target.loggerOnce(context.Background(), target.loggerOnce(context.Background(),
fmt.Errorf("Previous connect failed with %s attempting a reconnect", fmt.Errorf("Previous connect failed with %w attempting a reconnect",
token.Error()), token.Error()),
target.ID()) target.ID())
time.Sleep(reconnectInterval * time.Second) time.Sleep(reconnectInterval * time.Second)

@ -70,7 +70,7 @@ func replayEvents(store Store, doneCh <-chan struct{}, loggerOnce func(ctx conte
case <-retryTicker.C: case <-retryTicker.C:
if err != nil { if err != nil {
loggerOnce(context.Background(), loggerOnce(context.Background(),
fmt.Errorf("store.List() failed '%v'", err), id) fmt.Errorf("store.List() failed '%w'", err), id)
} }
case <-doneCh: case <-doneCh:
return return
@ -110,7 +110,7 @@ func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan str
if err != errNotConnected && !IsConnResetErr(err) { if err != errNotConnected && !IsConnResetErr(err) {
loggerOnce(context.Background(), loggerOnce(context.Background(),
fmt.Errorf("target.Send() failed with '%v'", err), fmt.Errorf("target.Send() failed with '%w'", err),
target.ID()) target.ID())
continue continue
} }

@ -143,7 +143,7 @@ func saveFileConfigEtcd(filename string, clnt *etcd.Client, v interface{}) error
if err == context.DeadlineExceeded { if err == context.DeadlineExceeded {
return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints()) return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints())
} else if err != nil { } else if err != nil {
return fmt.Errorf("unexpected error %s returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints()) return fmt.Errorf("unexpected error %w returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
} }
return nil return nil
} }
@ -156,7 +156,7 @@ func loadFileConfigEtcd(filename string, clnt *etcd.Client, v interface{}) error
if err == context.DeadlineExceeded { if err == context.DeadlineExceeded {
return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints()) return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints())
} }
return fmt.Errorf("unexpected error %s returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints()) return fmt.Errorf("unexpected error %w returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
} }
if resp.Count == 0 { if resp.Count == 0 {
return os.ErrNotExist return os.ErrNotExist

@ -84,7 +84,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
if selectAST.Where != nil { if selectAST.Where != nil {
whereQProp := selectAST.Where.analyze(&selectAST) whereQProp := selectAST.Where.analyze(&selectAST)
if whereQProp.err != nil { if whereQProp.err != nil {
err = errQueryAnalysisFailure(fmt.Errorf("Where clause error: %v", whereQProp.err)) err = errQueryAnalysisFailure(fmt.Errorf("Where clause error: %w", whereQProp.err))
return return
} }

Loading…
Cancel
Save