server: We shouldn't exit the server in lazy init. (#2548)

Avoid fatalIf instead these are non-critical errors,
continue running the server.

 - initializing bucket notifications
 - initializing bucket policies.
 - migrating bucket policies failure.

Fixes #2547
master
Harshavardhana 8 years ago
parent 9605fde04d
commit fa6e9540a8
  1. 3
      cmd/bucket-policy.go
  2. 24
      cmd/event-notifier.go
  3. 8
      cmd/routers.go

@ -100,10 +100,13 @@ func initBucketPolicies(objAPI ObjectLayer) error {
return err return err
} }
// Populate global bucket collection.
globalBucketPolicies = &bucketPolicies{ globalBucketPolicies = &bucketPolicies{
rwMutex: &sync.RWMutex{}, rwMutex: &sync.RWMutex{},
bucketPolicyConfigs: policies, bucketPolicyConfigs: policies,
} }
// Success.
return nil return nil
} }

@ -20,6 +20,7 @@ import (
"bytes" "bytes"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"net"
"net/url" "net/url"
"path" "path"
"sync" "sync"
@ -308,6 +309,14 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
// Using accountID we can now initialize a new AMQP logrus instance. // Using accountID we can now initialize a new AMQP logrus instance.
amqpLog, err := newAMQPNotify(accountID) amqpLog, err := newAMQPNotify(accountID)
if err != nil { if err != nil {
// Encapsulate network error to be more informative.
if _, ok := err.(net.Error); ok {
return nil, &net.OpError{
Op: "Connecting to " + queueARN,
Net: "tcp",
Err: err,
}
}
return nil, err return nil, err
} }
queueTargets[queueARN] = amqpLog queueTargets[queueARN] = amqpLog
@ -327,6 +336,14 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
// Using accountID we can now initialize a new Redis logrus instance. // Using accountID we can now initialize a new Redis logrus instance.
redisLog, err := newRedisNotify(accountID) redisLog, err := newRedisNotify(accountID)
if err != nil { if err != nil {
// Encapsulate network error to be more informative.
if _, ok := err.(net.Error); ok {
return nil, &net.OpError{
Op: "Connecting to " + queueARN,
Net: "tcp",
Err: err,
}
}
return nil, err return nil, err
} }
queueTargets[queueARN] = redisLog queueTargets[queueARN] = redisLog
@ -345,6 +362,13 @@ func loadAllQueueTargets() (map[string]*logrus.Logger, error) {
// Using accountID we can now initialize a new ElasticSearch logrus instance. // Using accountID we can now initialize a new ElasticSearch logrus instance.
elasticLog, err := newElasticNotify(accountID) elasticLog, err := newElasticNotify(accountID)
if err != nil { if err != nil {
// Encapsulate network error to be more informative.
if _, ok := err.(net.Error); ok {
return nil, &net.OpError{
Op: "Connecting to " + queueARN, Net: "tcp",
Err: err,
}
}
return nil, err return nil, err
} }
queueTargets[queueARN] = elasticLog queueTargets[queueARN] = elasticLog

@ -61,10 +61,10 @@ func newObjectLayerFactory(disks, ignoredDisks []string) func() ObjectLayer {
} }
// Migrate bucket policy from configDir to .minio.sys/buckets/ // Migrate bucket policy from configDir to .minio.sys/buckets/
err = migrateBucketPolicyConfig(objAPI) err = migrateBucketPolicyConfig(objAPI)
fatalIf(err, "Unable to migrate bucket policy from config directory") errorIf(err, "Unable to migrate bucket policy from config directory")
err = cleanupOldBucketPolicyConfigs() err = cleanupOldBucketPolicyConfigs()
fatalIf(err, "Unable to clean up bucket policy from config directory.") errorIf(err, "Unable to clean up bucket policy from config directory.")
// Register the callback that should be called when the process shuts down. // Register the callback that should be called when the process shuts down.
globalShutdownCBs.AddObjectLayerCB(func() errCode { globalShutdownCBs.AddObjectLayerCB(func() errCode {
@ -76,11 +76,11 @@ func newObjectLayerFactory(disks, ignoredDisks []string) func() ObjectLayer {
// Initialize a new event notifier. // Initialize a new event notifier.
err = initEventNotifier(objAPI) err = initEventNotifier(objAPI)
fatalIf(err, "Unable to initialize event notification queue") errorIf(err, "Unable to initialize event notification.")
// Initialize and load bucket policies. // Initialize and load bucket policies.
err = initBucketPolicies(objAPI) err = initBucketPolicies(objAPI)
fatalIf(err, "Unable to load all bucket policies") errorIf(err, "Unable to load all bucket policies.")
// Success. // Success.
return objAPI return objAPI

Loading…
Cancel
Save