diff --git a/api/client/client_test.go b/api/client/client_test.go index f4bb43951..a3c239219 100644 --- a/api/client/client_test.go +++ b/api/client/client_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/libopenstorage/openstorage/api" - apiserver "github.com/libopenstorage/openstorage/api/server" + "github.com/libopenstorage/openstorage/api/server" "github.com/libopenstorage/openstorage/config" "github.com/libopenstorage/openstorage/volume" "github.com/libopenstorage/openstorage/volume/drivers/nfs" @@ -39,7 +39,7 @@ func TestAll(t *testing.T) { if err != nil { t.Fatalf("Failed to initialize Driver: %v", err) } - apiserver.StartServerAPI(nfs.Name, 9003, config.DriverAPIBase) + server.StartServerAPI(nfs.Name, 9003, config.DriverAPIBase) time.Sleep(time.Second * 2) c, err := NewDriverClient(nfs.Name) if err != nil { diff --git a/api/server/docker.go b/api/server/docker.go index 7192ac48e..670419f5a 100644 --- a/api/server/docker.go +++ b/api/server/docker.go @@ -9,7 +9,7 @@ import ( "path" "strconv" - types "github.com/libopenstorage/openstorage/api" + "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/config" "github.com/libopenstorage/openstorage/volume" ) @@ -42,7 +42,7 @@ type volumePathResponse struct { } type volumeInfo struct { - vol *types.Volume + vol *api.Volume } func newVolumePlugin(name string) restServer { @@ -90,11 +90,11 @@ func (d *driver) volFromName(name string) (*volumeInfo, error) { if err != nil { return nil, fmt.Errorf("Cannot locate volume driver for %s: %s", d.name, err.Error()) } - vols, err := v.Inspect([]types.VolumeID{types.VolumeID(name)}) + vols, err := v.Inspect([]api.VolumeID{api.VolumeID(name)}) if err == nil && len(vols) == 1 { return &volumeInfo{vol: &vols[0]}, nil } - vols, err = v.Enumerate(types.VolumeLocator{Name: name}, nil) + vols, err = v.Enumerate(api.VolumeLocator{Name: name}, nil) if err == nil && len(vols) == 1 { return &volumeInfo{vol: &vols[0]}, nil } @@ -128,28 +128,28 @@ func (d *driver) status(w http.ResponseWriter, r *http.Request) { io.WriteString(w, fmt.Sprintln("osd plugin", d.version)) } -func (d *driver) specFromOpts(Opts map[string]string) *types.VolumeSpec { - var spec types.VolumeSpec +func (d *driver) specFromOpts(Opts map[string]string) *api.VolumeSpec { + var spec api.VolumeSpec for k, v := range Opts { switch k { - case types.SpecEphemeral: + case api.SpecEphemeral: spec.Ephemeral, _ = strconv.ParseBool(v) - case types.SpecSize: + case api.SpecSize: spec.Size, _ = strconv.ParseUint(v, 10, 64) - case types.SpecFilesystem: - spec.Format = types.Filesystem(v) - case types.SpecBlockSize: + case api.SpecFilesystem: + spec.Format = api.Filesystem(v) + case api.SpecBlockSize: blockSize, _ := strconv.ParseInt(v, 10, 64) spec.BlockSize = int(blockSize) - case types.SpecHaLevel: + case api.SpecHaLevel: haLevel, _ := strconv.ParseInt(v, 10, 64) spec.HALevel = int(haLevel) - case types.SpecCos: + case api.SpecCos: cos, _ := strconv.ParseInt(v, 10, 64) - spec.Cos = types.VolumeCos(cos) - case types.SpecDedupe: + spec.Cos = api.VolumeCos(cos) + case api.SpecDedupe: spec.Dedupe, _ = strconv.ParseBool(v) - case types.SpecSnapshotInterval: + case api.SpecSnapshotInterval: snapshotInterval, _ := strconv.ParseInt(v, 10, 64) spec.SnapshotInterval = int(snapshotInterval) } @@ -175,7 +175,7 @@ func (d *driver) create(w http.ResponseWriter, r *http.Request) { return } spec := d.specFromOpts(request.Opts) - _, err = v.Create(types.VolumeLocator{Name: request.Name}, nil, spec) + _, err = v.Create(api.VolumeLocator{Name: request.Name}, nil, spec) if err != nil { json.NewEncoder(w).Encode(&volumeResponse{Err: err}) return @@ -232,7 +232,7 @@ func (d *driver) mount(w http.ResponseWriter, r *http.Request) { } // If this is a block driver, first attach the volume. - if v.Type()&types.Block != 0 { + if v.Type()&api.Block != 0 { attachPath, err := v.Attach(volInfo.vol.ID) if err != nil { d.logReq(method, request.Name).Warnf("Cannot attach volume: %v", err.Error()) @@ -321,7 +321,7 @@ func (d *driver) unmount(w http.ResponseWriter, r *http.Request) { return } - if v.Type()&types.Block != 0 { + if v.Type()&api.Block != 0 { _ = v.Detach(volInfo.vol.ID) } d.emptyResponse(w) diff --git a/cluster/database.go b/cluster/database.go index be03b1030..d4cc3429c 100644 --- a/cluster/database.go +++ b/cluster/database.go @@ -5,60 +5,48 @@ import ( "encoding/json" "strings" + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" - - log "github.com/Sirupsen/logrus" - - kv "github.com/portworx/kvdb" + "github.com/portworx/kvdb" ) func readDatabase() (Database, error) { - kvdb := kv.Instance() + kvdb := kvdb.Instance() db := Database{Status: api.StatusInit, NodeEntries: make(map[string]NodeEntry)} kv, err := kvdb.Get("cluster/database") if err != nil && !strings.Contains(err.Error(), "Key not found") { - log.Warn("Warning, could not read cluster database") - goto done + logrus.Warn("Warning, could not read cluster database") + return db, err } if kv == nil || bytes.Compare(kv.Value, []byte("{}")) == 0 { - log.Info("Cluster is uninitialized...") - err = nil - goto done - } else { - err = json.Unmarshal(kv.Value, &db) - if err != nil { - log.Warn("Fatal, Could not parse cluster database ", kv) - goto done - } + logrus.Info("Cluster is uninitialized...") + return db, nil + } + if err := json.Unmarshal(kv.Value, &db); err != nil { + logrus.Warn("Fatal, Could not parse cluster database ", kv) + return db, err } -done: - return db, err + return db, nil } func writeDatabase(db *Database) error { - kvdb := kv.Instance() + kvdb := kvdb.Instance() b, err := json.Marshal(db) if err != nil { - log.Warn("Fatal, Could not marshal cluster database to JSON") - goto done + logrus.Warnf("Fatal, Could not marshal cluster database to JSON: %v", err) + return err } - _, err = kvdb.Put("cluster/database", b, 0) - if err != nil { - log.Warn("Fatal, Could not marshal cluster database to JSON") - goto done + if _, err := kvdb.Put("cluster/database", b, 0); err != nil { + logrus.Warnf("Fatal, Could not marshal cluster database to JSON: %v", err) + return err } - log.Info("Cluster database updated.") - -done: - if err != nil { - log.Println(err) - } - return err + logrus.Info("Cluster database updated.") + return nil } diff --git a/cluster/manager.go b/cluster/manager.go index 969c8c8c8..08f8941da 100644 --- a/cluster/manager.go +++ b/cluster/manager.go @@ -10,14 +10,13 @@ import ( "net" "time" + "github.com/Sirupsen/logrus" "github.com/fsouza/go-dockerclient" "github.com/libopenstorage/gossip" - gossiptypes "github.com/libopenstorage/gossip/types" + "github.com/libopenstorage/gossip/types" "github.com/libopenstorage/openstorage/api" - log "github.com/Sirupsen/logrus" - - kv "github.com/portworx/kvdb" + "github.com/portworx/kvdb" "github.com/portworx/systemutils" ) @@ -28,7 +27,7 @@ const ( type ClusterManager struct { listeners *list.List config Config - kv kv.Kvdb + kv kvdb.Kvdb status api.Status nodeCache map[string]api.Node // Cached info on the nodes in the cluster. docker *docker.Client @@ -86,7 +85,7 @@ func (c *ClusterManager) LocateNode(nodeID string) (api.Node, error) { } func (c *ClusterManager) AddEventListener(listener ClusterListener) error { - log.Printf("Adding cluster event listener: %s", listener.String()) + logrus.Printf("Adding cluster event listener: %s", listener.String()) c.listeners.PushBack(listener) return nil } @@ -128,7 +127,7 @@ func (c *ClusterManager) initNode(db *Database) (*api.Node, bool) { db.NodeEntries[c.config.NodeId] = NodeEntry{Id: c.selfNode.Id, Ip: c.selfNode.Ip} - log.Infof("Node %s joining cluster... \n\tCluster ID: %s\n\tIP: %s", + logrus.Infof("Node %s joining cluster... \n\tCluster ID: %s\n\tIP: %s", c.config.NodeId, c.config.ClusterId, c.selfNode.Ip) return &c.selfNode, exists @@ -147,7 +146,7 @@ func (c *ClusterManager) joinCluster(db *Database, self *api.Node, exist bool) e for e := c.listeners.Front(); e != nil; e = e.Next() { err = e.Value.(ClusterListener).Init(self, db) if err != nil { - log.Warnf("Failed to initialize %s: %v", + logrus.Warnf("Failed to initialize %s: %v", e.Value.(ClusterListener).String(), err) goto done } @@ -158,7 +157,7 @@ found: for e := c.listeners.Front(); e != nil; e = e.Next() { err = e.Value.(ClusterListener).Join(self, db) if err != nil { - log.Warnf("Failed to initialize %s: %v", + logrus.Warnf("Failed to initialize %s: %v", e.Value.(ClusterListener).String(), err) goto done } @@ -168,11 +167,11 @@ found: if id != c.config.NodeId { // Check to see if the IP is the same. If it is, then we have a stale entry. if n.Ip == self.Ip { - log.Warnf("Warning, Detected node %s with the same IP %s in the database. Will not connect to this node.", + logrus.Warnf("Warning, Detected node %s with the same IP %s in the database. Will not connect to this node.", id, n.Ip) } else { // Gossip with this node. - log.Infof("Connecting to node %s with IP %s.", id, n.Ip) + logrus.Infof("Connecting to node %s with IP %s.", id, n.Ip) c.g.AddNode(n.Ip + ":9002") } } @@ -189,7 +188,7 @@ func (c *ClusterManager) initCluster(db *Database, self *api.Node, exist bool) e for e := c.listeners.Front(); e != nil; e = e.Next() { err = e.Value.(ClusterListener).ClusterInit(self, db) if err != nil { - log.Printf("Failed to initialize %s", + logrus.Printf("Failed to initialize %s", e.Value.(ClusterListener).String()) goto done } @@ -197,7 +196,7 @@ func (c *ClusterManager) initCluster(db *Database, self *api.Node, exist bool) e err = c.joinCluster(db, self, exist) if err != nil { - log.Printf("Failed to join new cluster") + logrus.Printf("Failed to join new cluster") goto done } @@ -210,16 +209,16 @@ func (c *ClusterManager) heartBeat() { node := c.getCurrentState() c.nodeCache[node.Id] = *node - c.g.UpdateSelf(gossiptypes.StoreKey(heartbeatKey+c.config.ClusterId), *node) + c.g.UpdateSelf(types.StoreKey(heartbeatKey+c.config.ClusterId), *node) // Process heartbeats from other nodes... - gossipValues := c.g.GetStoreKeyValue(gossiptypes.StoreKey(heartbeatKey + c.config.ClusterId)) + gossipValues := c.g.GetStoreKeyValue(types.StoreKey(heartbeatKey + c.config.ClusterId)) for _, nodeInfo := range gossipValues { n, ok := nodeInfo.Value.(api.Node) if !ok { - log.Warn("Received a bad broadcast packet: %v", nodeInfo.Value) + logrus.Warn("Received a bad broadcast packet: %v", nodeInfo.Value) continue } @@ -230,24 +229,24 @@ func (c *ClusterManager) heartBeat() { _, ok = c.nodeCache[n.Id] if ok { if n.Status != api.StatusOk { - log.Warn("Detected node ", n.Id, " to be unhealthy.") + logrus.Warn("Detected node ", n.Id, " to be unhealthy.") for e := c.listeners.Front(); e != nil && c.gEnabled; e = e.Next() { err := e.Value.(ClusterListener).Update(&n) if err != nil { - log.Warn("Failed to notify ", e.Value.(ClusterListener).String()) + logrus.Warn("Failed to notify ", e.Value.(ClusterListener).String()) } } delete(c.nodeCache, n.Id) - } else if nodeInfo.Status == gossiptypes.NODE_STATUS_DOWN { - log.Warn("Detected node ", n.Id, " to be offline due to inactivity.") + } else if nodeInfo.Status == types.NODE_STATUS_DOWN { + logrus.Warn("Detected node ", n.Id, " to be offline due to inactivity.") n.Status = api.StatusOffline for e := c.listeners.Front(); e != nil && c.gEnabled; e = e.Next() { err := e.Value.(ClusterListener).Update(&n) if err != nil { - log.Warn("Failed to notify ", e.Value.(ClusterListener).String()) + logrus.Warn("Failed to notify ", e.Value.(ClusterListener).String()) } } @@ -255,15 +254,15 @@ func (c *ClusterManager) heartBeat() { } else { c.nodeCache[n.Id] = n } - } else if nodeInfo.Status == gossiptypes.NODE_STATUS_UP { + } else if nodeInfo.Status == types.NODE_STATUS_UP { // A node discovered in the cluster. - log.Warn("Detected node ", n.Id, " to be in the cluster.") + logrus.Warn("Detected node ", n.Id, " to be in the cluster.") c.nodeCache[n.Id] = n for e := c.listeners.Front(); e != nil && c.gEnabled; e = e.Next() { err := e.Value.(ClusterListener).Add(&n) if err != nil { - log.Warn("Failed to notify ", e.Value.(ClusterListener).String()) + logrus.Warn("Failed to notify ", e.Value.(ClusterListener).String()) } } } @@ -274,23 +273,23 @@ func (c *ClusterManager) heartBeat() { } func (c *ClusterManager) DisableGossipUpdates() { - log.Warn("Disabling gossip updates") + logrus.Warn("Disabling gossip updates") c.gEnabled = false } func (c *ClusterManager) EnableGossipUpdates() { - log.Warn("Enabling gossip updates") + logrus.Warn("Enabling gossip updates") c.gEnabled = true } func (c *ClusterManager) Start() error { - log.Info("Cluster manager starting...") - kvdb := kv.Instance() + logrus.Info("Cluster manager starting...") + kvdb := kvdb.Instance() // Start the gossip protocol. // XXX Make the port configurable. gob.Register(api.Node{}) - c.g = gossip.New("0.0.0.0:9002", gossiptypes.NodeId(c.config.NodeId)) + c.g = gossip.New("0.0.0.0:9002", types.NodeId(c.config.NodeId)) c.g.SetGossipInterval(2 * time.Second) c.gEnabled = true c.selfNode = api.Node{} @@ -301,16 +300,16 @@ func (c *ClusterManager) Start() error { kvlock, err := kvdb.Lock("cluster/lock", 60) if err != nil { - log.Panic("Fatal, Unable to obtain cluster lock.", err) + logrus.Panic("Fatal, Unable to obtain cluster lock.", err) } db, err := readDatabase() if err != nil { - log.Panic(err) + logrus.Panic(err) } if db.Status == api.StatusInit { - log.Info("Will initialize a new cluster.") + logrus.Info("Will initialize a new cluster.") c.status = api.StatusOk db.Status = api.StatusOk @@ -319,23 +318,23 @@ func (c *ClusterManager) Start() error { err = c.initCluster(&db, self, false) if err != nil { kvdb.Unlock(kvlock) - log.Error("Failed to initialize the cluster.", err) - log.Panic(err) + logrus.Error("Failed to initialize the cluster.", err) + logrus.Panic(err) } // Update the new state of the cluster in the KV Database err = writeDatabase(&db) if err != nil { - log.Error("Failed to save the database.", err) - log.Panic(err) + logrus.Error("Failed to save the database.", err) + logrus.Panic(err) } err = kvdb.Unlock(kvlock) if err != nil { - log.Panic("Fatal, unable to unlock cluster... Did something take too long to initialize?", err) + logrus.Panic("Fatal, unable to unlock cluster... Did something take too long to initialize?", err) } } else if db.Status&api.StatusOk > 0 { - log.Info("Cluster state is OK... Joining the cluster.") + logrus.Info("Cluster state is OK... Joining the cluster.") c.status = api.StatusOk self, exist := c.initNode(&db) @@ -343,22 +342,22 @@ func (c *ClusterManager) Start() error { err = c.joinCluster(&db, self, exist) if err != nil { kvdb.Unlock(kvlock) - log.Panic(err) + logrus.Panic(err) } err = writeDatabase(&db) if err != nil { - log.Panic(err) + logrus.Panic(err) } err = kvdb.Unlock(kvlock) if err != nil { - log.Panic("Fatal, unable to unlock cluster... Did something take too long to initialize?", err) + logrus.Panic("Fatal, unable to unlock cluster... Did something take too long to initialize?", err) } } else { kvdb.Unlock(kvlock) err = errors.New("Fatal, Cluster is in an unexpected state.") - log.Panic(err) + logrus.Panic(err) } // Start heartbeating to other nodes. diff --git a/cmd/osd/main.go b/cmd/osd/main.go index 9da94c5d8..287f806f3 100644 --- a/cmd/osd/main.go +++ b/cmd/osd/main.go @@ -15,10 +15,10 @@ import ( "github.com/portworx/kvdb/etcd" "github.com/portworx/kvdb/mem" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" - apiserver "github.com/libopenstorage/openstorage/api/server" + "github.com/libopenstorage/openstorage/api/server" osdcli "github.com/libopenstorage/openstorage/cli" "github.com/libopenstorage/openstorage/cluster" "github.com/libopenstorage/openstorage/config" @@ -44,12 +44,12 @@ func start(c *cli.Context) { // We are in daemon mode. file := c.String("file") if file == "" { - log.Warn("OSD configuration file not specified. Visit openstorage.org for an example.") + logrus.Warn("OSD configuration file not specified. Visit openstorage.org for an example.") return } cfg, err := config.Parse(file) if err != nil { - log.Error(err) + logrus.Error(err) return } kvdbURL := c.String("kvdb") @@ -59,13 +59,13 @@ func start(c *cli.Context) { kv, err := kvdb.New(scheme, "openstorage", []string{u.String()}, nil) if err != nil { - log.Warnf("Failed to initialize KVDB: %v (%v)", scheme, err) - log.Warnf("Supported datastores: %v", datastores) + logrus.Warnf("Failed to initialize KVDB: %v (%v)", scheme, err) + logrus.Warnf("Supported datastores: %v", datastores) return } err = kvdb.SetInstance(kv) if err != nil { - log.Warnf("Failed to initialize KVDB: %v", err) + logrus.Warnf("Failed to initialize KVDB: %v", err) return } @@ -73,7 +73,7 @@ func start(c *cli.Context) { if cfg.Osd.ClusterConfig.NodeId != "" && cfg.Osd.ClusterConfig.ClusterId != "" { dockerClient, err := docker.NewClientFromEnv() if err != nil { - log.Warnf("Failed to initialize docker client: %v", err) + logrus.Warnf("Failed to initialize docker client: %v", err) return } cm = cluster.New(cfg.Osd.ClusterConfig, kv, dockerClient) @@ -81,30 +81,30 @@ func start(c *cli.Context) { // Start the volume drivers. for d, v := range cfg.Osd.Drivers { - log.Infof("Starting volume driver: %v", d) + logrus.Infof("Starting volume driver: %v", d) _, err := volume.New(d, v) if err != nil { - log.Warnf("Unable to start volume driver: %v, %v", d, err) + logrus.Warnf("Unable to start volume driver: %v, %v", d, err) return } - err = apiserver.StartServerAPI(d, 0, config.DriverAPIBase) + err = server.StartServerAPI(d, 0, config.DriverAPIBase) if err != nil { - log.Warnf("Unable to start volume driver: %v", err) + logrus.Warnf("Unable to start volume driver: %v", err) return } - err = apiserver.StartPluginAPI(d, config.PluginAPIBase) + err = server.StartPluginAPI(d, config.PluginAPIBase) if err != nil { - log.Warnf("Unable to start volume plugin: %v", err) + logrus.Warnf("Unable to start volume plugin: %v", err) return } } // Start the graph drivers. for d, _ := range cfg.Osd.GraphDrivers { - log.Infof("Starting graph driver: %v", d) - err = apiserver.StartGraphAPI(d, 0, config.PluginAPIBase) + logrus.Infof("Starting graph driver: %v", d) + err = server.StartGraphAPI(d, 0, config.PluginAPIBase) if err != nil { - log.Warnf("Unable to start graph plugin: %v", err) + logrus.Warnf("Unable to start graph plugin: %v", err) return } } @@ -112,7 +112,7 @@ func start(c *cli.Context) { if cm != nil { err = cm.Start() if err != nil { - log.Warnf("Unable to start cluster manager: %v", err) + logrus.Warnf("Unable to start cluster manager: %v", err) return } } diff --git a/graph/drivers/layer0/layer0.go b/graph/drivers/layer0/layer0.go index e1c280460..086251585 100644 --- a/graph/drivers/layer0/layer0.go +++ b/graph/drivers/layer0/layer0.go @@ -8,7 +8,7 @@ import ( "sync" "sync/atomic" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/overlay" "github.com/docker/docker/pkg/archive" @@ -77,7 +77,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, fmt.Errorf("Unknown option %s\n", key) } } - log.Infof("Layer0 volume driver: %v", volumeDriver) + logrus.Infof("Layer0 volume driver: %v", volumeDriver) volDriver, err := volume.Get(volumeDriver) if err != nil { return nil, err @@ -147,7 +147,7 @@ func (l *Layer0) create(id, parent string) (string, *Layer0Vol, error) { vol, ok := l.volumes[id] if !ok { - log.Warnf("Failed to find layer0 volume for id %v", id) + logrus.Warnf("Failed to find layer0 volume for id %v", id) return id, nil, nil } @@ -157,7 +157,7 @@ func (l *Layer0) create(id, parent string) (string, *Layer0Vol, error) { // If we don't find a volume configured for this image, // then don't track layer0 if err != nil || vols == nil { - log.Infof("Failed to find configured volume for id %v", vol.parent) + logrus.Infof("Failed to find configured volume for id %v", vol.parent) delete(l.volumes, id) return id, nil, nil } @@ -171,7 +171,7 @@ func (l *Layer0) create(id, parent string) (string, *Layer0Vol, error) { } } if index == -1 { - log.Infof("Failed to find free volume for id %v", vol.parent) + logrus.Infof("Failed to find free volume for id %v", vol.parent) delete(l.volumes, id) return id, nil, nil } @@ -183,14 +183,14 @@ func (l *Layer0) create(id, parent string) (string, *Layer0Vol, error) { if l.volDriver.Type()&api.Block != 0 { _, err := l.volDriver.Attach(vols[index].ID) if err != nil { - log.Errorf("Failed to attach volume %v", vols[index].ID) + logrus.Errorf("Failed to attach volume %v", vols[index].ID) delete(l.volumes, id) return id, nil, nil } } err = l.volDriver.Mount(vols[index].ID, mountPath) if err != nil { - log.Errorf("Failed to mount volume %v at path %v", + logrus.Errorf("Failed to mount volume %v at path %v", vols[index].ID, mountPath) delete(l.volumes, id) return id, nil, nil @@ -239,7 +239,7 @@ func (l *Layer0) Remove(id string) error { upperDir := path.Join(path.Join(l.home, l.realID(id)), "upper") err := os.Rename(upperDir, path.Join(v.path, "upper")) if err != nil { - log.Warnf("Failed in rename(%v): %v", id, err) + logrus.Warnf("Failed in rename(%v): %v", id, err) } l.Driver.Remove(l.realID(id)) err = l.volDriver.Unmount(v.volumeID, v.path) @@ -250,7 +250,7 @@ func (l *Layer0) Remove(id string) error { delete(l.volumes, v.id) } } else { - log.Warnf("Failed to find layer0 vol for id %v", id) + logrus.Warnf("Failed to find layer0 vol for id %v", id) } return err } diff --git a/graph/drivers/unionfs/unionfs.go b/graph/drivers/unionfs/unionfs.go index b84f17d2b..7c6247e59 100644 --- a/graph/drivers/unionfs/unionfs.go +++ b/graph/drivers/unionfs/unionfs.go @@ -20,13 +20,12 @@ import ( "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/graph" + "github.com/Sirupsen/logrus" "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/directory" "github.com/docker/docker/pkg/idtools" - - log "github.com/Sirupsen/logrus" ) const ( @@ -40,19 +39,19 @@ type Driver struct { } func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) { - log.Infof("Initializing Fuse Graph driver at home:%s and storage: %v...", home, virtPath) + logrus.Infof("Initializing Fuse Graph driver at home:%s and storage: %v...", home, virtPath) // In case it is mounted. syscall.Unmount(virtPath, 0) err := os.MkdirAll(virtPath, 0744) if err != nil { - log.Fatalf("Error while creating FUSE mount path: %v", err) + logrus.Fatalf("Error while creating FUSE mount path: %v", err) } err = os.MkdirAll(physPath, 0744) if err != nil { - log.Fatalf("Error while creating FUSE mount path: %v", err) + logrus.Fatalf("Error while creating FUSE mount path: %v", err) } cVirtPath := C.CString(virtPath) @@ -72,7 +71,7 @@ func (d *Driver) String() string { // held by the driver, e.g., unmounting all layered filesystems // known to this driver. func (d *Driver) Cleanup() error { - log.Infof("Cleaning up fuse %s", virtPath) + logrus.Infof("Cleaning up fuse %s", virtPath) // syscall.Unmount(virtPath, 0) return nil } @@ -90,7 +89,7 @@ func (d *Driver) linkParent(child, parent string) error { child = child + "/_parent" - log.Infof("Linking layer %s to parent layer %s", child, parent) + logrus.Infof("Linking layer %s to parent layer %s", child, parent) err := os.Symlink(parent, child) if err != nil { @@ -104,7 +103,7 @@ func (d *Driver) linkParent(child, parent string) error { // specified id and parent and mountLabel. Parent and mountLabel may be "". func (d *Driver) Create(id string, parent string) error { path := path.Join(physPath, id) - log.Infof("Creating layer %s", path) + logrus.Infof("Creating layer %s", path) err := os.MkdirAll(path, 0744) if err != nil { @@ -121,7 +120,7 @@ func (d *Driver) Create(id string, parent string) error { // Remove attempts to remove the filesystem layer with this id. func (d *Driver) Remove(id string) error { path := path.Join(physPath, id) - log.Infof("Removing layer %s", path) + logrus.Infof("Removing layer %s", path) // XXX FIXME os.RemoveAll(path) @@ -141,14 +140,14 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { layerPath := path.Join(physPath, id) // unionPath := path.Join(virtPath, id) - log.Infof("Unifying layer %s", layerPath) + logrus.Infof("Unifying layer %s", layerPath) cLayerPath := C.CString(layerPath) cID := C.CString(id) _, err := C.alloc_unionfs(cLayerPath, cID) - log.Infof("GOT %v\n", err) + logrus.Infof("GOT %v\n", err) // return unionPath, err return virtPath, err @@ -158,7 +157,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { // e.g, unmounting layered filesystem. func (d *Driver) Put(id string) error { unionPath := path.Join(virtPath, id) - log.Infof("Releasing union layer %s", unionPath) + logrus.Infof("Releasing union layer %s", unionPath) cID := C.CString(id) @@ -188,14 +187,14 @@ func (d *Driver) Exists(id string) bool { // The archive.Reader must be an uncompressed stream. func (d *Driver) ApplyDiff(id string, parent string, diff archive.Reader) (size int64, err error) { if parent != "" { - log.Infof("Applying diff %s on %s", id, parent) + logrus.Infof("Applying diff %s on %s", id, parent) } else { - log.Infof("Applying diff %s", id) + logrus.Infof("Applying diff %s", id) } dir := path.Join(physPath, id) if err := chrootarchive.UntarUncompressed(diff, dir, nil); err != nil { - log.Warnf("Error while applying diff to %s: %v", id, err) + logrus.Warnf("Error while applying diff to %s: %v", id, err) os.Exit(-1) return 0, err } @@ -203,7 +202,7 @@ func (d *Driver) ApplyDiff(id string, parent string, diff archive.Reader) (size // show invalid whiteouts warning. files, err := ioutil.ReadDir(path.Join(dir, archive.WhiteoutLinkDir)) if err == nil && len(files) > 0 { - log.Warnf("Archive contains aufs hardlink references that are not supported.") + logrus.Warnf("Archive contains aufs hardlink references that are not supported.") } return d.DiffSize(id, parent) diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index 00e4e9f4f..ef4e06aa0 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -8,7 +8,7 @@ import ( "sync" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) // Mangager defines the interface for keep track of volume driver mounts. @@ -133,7 +133,7 @@ func (m *Mounter) Mount(minor int, device, path, fs string, flags uintptr, data dev, ok := m.paths[path] if ok && dev != device { - log.Warnf("cannot mount %q, device %q is mounted at %q", device, dev, path) + logrus.Warnf("cannot mount %q, device %q is mounted at %q", device, dev, path) return ErrExist } info, ok := m.mounts[device] @@ -148,7 +148,7 @@ func (m *Mounter) Mount(minor int, device, path, fs string, flags uintptr, data // Validate input params if fs != info.Fs { - log.Warnf("%s Existing mountpoint has fs %q cannot change to %q", + logrus.Warnf("%s Existing mountpoint has fs %q cannot change to %q", device, info.Fs, fs) return ErrEinval } @@ -194,7 +194,7 @@ func (m *Mounter) Unmount(device, path string) error { if _, pathExists := m.paths[path]; pathExists { delete(m.paths, path) } else { - log.Warnf("Path %q for device %q does not exist in pathMap", path, device) + logrus.Warnf("Path %q for device %q does not exist in pathMap", path, device) } // Blow away this mountpoint. info.Mountpoint[i] = info.Mountpoint[len(info.Mountpoint)-1] diff --git a/volume/drivers/aws/aws.go b/volume/drivers/aws/aws.go index 5c73fec07..c03365626 100644 --- a/volume/drivers/aws/aws.go +++ b/volume/drivers/aws/aws.go @@ -10,19 +10,16 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" - + "github.com/Sirupsen/logrus" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/opsworks" - - "github.com/portworx/kvdb" - "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/pkg/chaos" "github.com/libopenstorage/openstorage/pkg/device" "github.com/libopenstorage/openstorage/volume" + "github.com/portworx/kvdb" ) const ( @@ -61,7 +58,7 @@ func Init(params volume.DriverParams) (volume.VolumeDriver, error) { if err != nil { return nil, err } - log.Infof("AWS instance %v zone %v", instance, zone) + logrus.Infof("AWS instance %v zone %v", instance, zone) accessKey, ok := params["AWS_ACCESS_KEY_ID"] if !ok { if accessKey = os.Getenv("AWS_ACCESS_KEY_ID"); accessKey == "" { @@ -250,7 +247,7 @@ func (d *Driver) Create( vol, err := d.ec2.CreateVolume(req) if err != nil { - log.Warnf("Failed in CreateVolumeRequest :%v", err) + logrus.Warnf("Failed in CreateVolumeRequest :%v", err) return api.BadVolumeID, err } v := &api.Volume{ @@ -530,7 +527,7 @@ func (d *Driver) volumeState(ec2VolState *string) api.VolumeState { case ec2.VolumeAttachmentStateAttaching, ec2.VolumeAttachmentStateDetaching: return api.VolumePending default: - log.Warnf("Failed to translate EC2 volume status %v", ec2VolState) + logrus.Warnf("Failed to translate EC2 volume status %v", ec2VolState) } return api.VolumeError } @@ -549,7 +546,7 @@ func (d *Driver) Format(volumeID api.VolumeID) error { cmd := "/sbin/mkfs." + string(v.Spec.Format) o, err := exec.Command(cmd, devicePath).Output() if err != nil { - log.Warnf("Failed to run command %v %v: %v", cmd, devicePath, o) + logrus.Warnf("Failed to run command %v %v: %v", cmd, devicePath, o) return err } v.Format = v.Spec.Format @@ -596,7 +593,7 @@ func (d *Driver) Unmount(volumeID api.VolumeID, mountpath string) error { } func (d *Driver) Shutdown() { - log.Printf("%s Shutting down", Name) + logrus.Printf("%s Shutting down", Name) } func (d *Driver) Set(volumeID api.VolumeID, locator *api.VolumeLocator, spec *api.VolumeSpec) error { diff --git a/volume/drivers/btrfs/btrfs.go b/volume/drivers/btrfs/btrfs.go index 5dac7e74c..b7b92c3f2 100644 --- a/volume/drivers/btrfs/btrfs.go +++ b/volume/drivers/btrfs/btrfs.go @@ -8,16 +8,14 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" - graph "github.com/docker/docker/daemon/graphdriver" + "github.com/Sirupsen/logrus" + "github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver/btrfs" - "github.com/pborman/uuid" - - "github.com/portworx/kvdb" - "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/pkg/chaos" "github.com/libopenstorage/openstorage/volume" + "github.com/pborman/uuid" + "github.com/portworx/kvdb" ) const ( @@ -36,7 +34,7 @@ type driver struct { *volume.IoNotSupported *volume.DefaultBlockDriver *volume.DefaultEnumerator - btrfs graph.Driver + btrfs graphdriver.Driver root string } @@ -114,7 +112,7 @@ func (d *driver) Create(locator api.VolumeLocator, func (d *driver) Delete(volumeID api.VolumeID) error { err := d.DeleteVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -129,7 +127,7 @@ func (d *driver) Delete(volumeID api.VolumeID) error { func (d *driver) Mount(volumeID api.VolumeID, mountpath string) error { v, err := d.GetVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } err = syscall.Mount(v.DevicePath, mountpath, string(v.Format), syscall.MS_BIND, "") diff --git a/volume/drivers/buse/buse.go b/volume/drivers/buse/buse.go index fd6c4355b..f7cebc473 100644 --- a/volume/drivers/buse/buse.go +++ b/volume/drivers/buse/buse.go @@ -10,14 +10,12 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" - "github.com/pborman/uuid" - - "github.com/portworx/kvdb" - + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/cluster" "github.com/libopenstorage/openstorage/volume" + "github.com/pborman/uuid" + "github.com/portworx/kvdb" ) const ( @@ -100,18 +98,18 @@ func Init(params volume.DriverParams) (volume.VolumeDriver, error) { } } } else { - log.Println("Could not enumerate Volumes, ", err) + logrus.Println("Could not enumerate Volumes, ", err) } c, err := cluster.Inst() if err != nil { - log.Println("BUSE initializing in single node mode") + logrus.Println("BUSE initializing in single node mode") } else { - log.Println("BUSE initializing in clustered mode") + logrus.Println("BUSE initializing in clustered mode") c.AddEventListener(inst) } - log.Println("BUSE initialized and driver mounted at: ", BuseMountPath) + logrus.Println("BUSE initialized and driver mounted at: ", BuseMountPath) return inst, nil } @@ -148,13 +146,13 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api buseFile := path.Join(BuseMountPath, string(volumeID)) f, err := os.Create(buseFile) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } err = f.Truncate(int64(spec.Size)) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } @@ -165,22 +163,22 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api nbd := Create(bd, int64(spec.Size)) bd.nbd = nbd - log.Infof("Connecting to NBD...") + logrus.Infof("Connecting to NBD...") dev, err := bd.nbd.Connect() if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } - log.Infof("Formatting %s with %v", dev, spec.Format) + logrus.Infof("Formatting %s with %v", dev, spec.Format) cmd := "/sbin/mkfs." + string(spec.Format) o, err := exec.Command(cmd, dev).Output() if err != nil { - log.Warnf("Failed to run command %v %v: %v", cmd, dev, o) + logrus.Warnf("Failed to run command %v %v: %v", cmd, dev, o) return api.BadVolumeID, err } - log.Infof("BUSE mapped NBD device %s (size=%v) to block file %s", dev, spec.Size, buseFile) + logrus.Infof("BUSE mapped NBD device %s (size=%v) to block file %s", dev, spec.Size, buseFile) v := &api.Volume{ ID: api.VolumeID(volumeID), @@ -207,14 +205,14 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api func (d *driver) Delete(volumeID api.VolumeID) error { v, err := d.GetVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } bd, ok := d.buseDevices[v.DevicePath] if !ok { err = fmt.Errorf("Cannot locate a BUSE device for %s", v.DevicePath) - log.Println(err) + logrus.Println(err) return err } @@ -223,11 +221,11 @@ func (d *driver) Delete(volumeID api.VolumeID) error { bd.f.Close() bd.nbd.Disconnect() - log.Infof("BUSE deleted volume %v at NBD device %s", volumeID, v.DevicePath) + logrus.Infof("BUSE deleted volume %v at NBD device %s", volumeID, v.DevicePath) err = d.DeleteVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -241,11 +239,11 @@ func (d *driver) Mount(volumeID api.VolumeID, mountpath string) error { } err = syscall.Mount(v.DevicePath, mountpath, string(v.Spec.Format), 0, "") if err != nil { - log.Errorf("Mounting %s on %s failed because of %v", v.DevicePath, mountpath, err) + logrus.Errorf("Mounting %s on %s failed because of %v", v.DevicePath, mountpath, err) return fmt.Errorf("Failed to mount %v at %v: %v", v.DevicePath, mountpath, err) } - log.Infof("BUSE mounted NBD device %s at %s", v.DevicePath, mountpath) + logrus.Infof("BUSE mounted NBD device %s at %s", v.DevicePath, mountpath) v.AttachPath = mountpath err = d.UpdateVol(v) @@ -328,7 +326,7 @@ func (d *driver) Alerts(volumeID api.VolumeID) (api.Alerts, error) { } func (d *driver) Shutdown() { - log.Printf("%s Shutting down", Name) + logrus.Printf("%s Shutting down", Name) syscall.Unmount(BuseMountPath, 0) } diff --git a/volume/drivers/buse/nbd.go b/volume/drivers/buse/nbd.go index b411330a6..6f697ac9c 100644 --- a/volume/drivers/buse/nbd.go +++ b/volume/drivers/buse/nbd.go @@ -13,7 +13,7 @@ import ( "sync" "syscall" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) const ( @@ -140,7 +140,7 @@ func (nbd *NBD) Connect() (dev string, err error) { continue // Busy. } - log.Infof("Attempting to open device %v", dev) + logrus.Infof("Attempting to open device %v", dev) if nbd.deviceFile, err = os.Open(dev); err == nil { // Possible candidate. ioctl(nbd.deviceFile.Fd(), BLKROSET, 0) @@ -190,7 +190,7 @@ func (nbd *NBD) connect() { // NBD_CONNECT does not return until disconnect. ioctl(nbd.deviceFile.Fd(), NBD_CONNECT, 0) - log.Infof("Closing device file %s", nbd.devicePath) + logrus.Infof("Closing device file %s", nbd.devicePath) } // Handle block requests. @@ -201,12 +201,12 @@ func (nbd *NBD) handle() { for { bytes, err := syscall.Read(nbd.socket, buf[0:28]) if nbd.deviceFile == nil { - log.Infof("Disconnecting device %s", nbd.devicePath) + logrus.Infof("Disconnecting device %s", nbd.devicePath) return } if bytes < 0 || err != nil { - log.Errorf("Error reading from device %s", nbd.devicePath) + logrus.Errorf("Error reading from device %s", nbd.devicePath) nbd.Disconnect() return } @@ -238,7 +238,7 @@ func (nbd *NBD) handle() { binary.BigEndian.PutUint32(buf[4:8], 0) syscall.Write(nbd.socket, buf[0:16]) case NBD_CMD_DISC: - log.Infof("Disconnecting device %s", nbd.devicePath) + logrus.Infof("Disconnecting device %s", nbd.devicePath) nbd.Disconnect() return case NBD_CMD_FLUSH: @@ -248,12 +248,12 @@ func (nbd *NBD) handle() { binary.BigEndian.PutUint32(buf[4:8], 1) syscall.Write(nbd.socket, buf[0:16]) default: - log.Errorf("Unknown command recieved on device %s", nbd.devicePath) + logrus.Errorf("Unknown command recieved on device %s", nbd.devicePath) nbd.Disconnect() return } default: - log.Errorf("Invalid packet command recieved on device %s", nbd.devicePath) + logrus.Errorf("Invalid packet command recieved on device %s", nbd.devicePath) nbd.Disconnect() return } diff --git a/volume/drivers/nfs/nfs.go b/volume/drivers/nfs/nfs.go index 2db6b0314..4fc574674 100644 --- a/volume/drivers/nfs/nfs.go +++ b/volume/drivers/nfs/nfs.go @@ -10,16 +10,14 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" - "github.com/pborman/uuid" - - "github.com/portworx/kvdb" - + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/config" "github.com/libopenstorage/openstorage/pkg/mount" "github.com/libopenstorage/openstorage/pkg/seed" "github.com/libopenstorage/openstorage/volume" + "github.com/pborman/uuid" + "github.com/portworx/kvdb" ) const ( @@ -116,15 +114,15 @@ func Init(params volume.DriverParams) (volume.VolumeDriver, error) { server, ok := params["server"] if !ok { - log.Printf("No NFS server provided, will attempt to bind mount %s", path) + logrus.Printf("No NFS server provided, will attempt to bind mount %s", path) } else { - log.Printf("NFS driver initializing with %s:%s ", server, path) + logrus.Printf("NFS driver initializing with %s:%s ", server, path) } // Create a mount manager for this NFS server. Blank sever is OK. mounter, err := mount.New(mount.NFSMount, server) if err != nil { - log.Warnf("Failed to create mount manager for server: %v (%v)", server, err) + logrus.Warnf("Failed to create mount manager for server: %v (%v)", server, err) return nil, err } @@ -157,7 +155,7 @@ func Init(params volume.DriverParams) (volume.VolumeDriver, error) { err = syscall.Mount(src, nfsMountPath, "", syscall.MS_BIND, "") } if err != nil { - log.Printf("Unable to mount %s:%s at %s (%+v)", inst.nfsServer, inst.nfsPath, nfsMountPath, err) + logrus.Printf("Unable to mount %s:%s at %s (%+v)", inst.nfsServer, inst.nfsPath, nfsMountPath, err) return nil, err } } @@ -171,10 +169,10 @@ func Init(params volume.DriverParams) (volume.VolumeDriver, error) { } } } else { - log.Println("Could not enumerate Volumes, ", err) + logrus.Println("Could not enumerate Volumes, ", err) } - log.Println("NFS initialized and driver mounted at: ", nfsMountPath) + logrus.Println("NFS initialized and driver mounted at: ", nfsMountPath) return inst, nil } @@ -203,20 +201,20 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api volPath := path.Join(nfsMountPath, volumeID) err := os.MkdirAll(volPath, 0744) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } if source != nil { if len(source.Seed) != 0 { seed, err := seed.New(source.Seed, spec.ConfigLabels) if err != nil { - log.Warnf("Failed to initailize seed from %q : %v", + logrus.Warnf("Failed to initailize seed from %q : %v", source.Seed, err) return api.BadVolumeID, err } err = seed.Load(path.Join(volPath, config.DataDir)) if err != nil { - log.Warnf("Failed to seed from %q to %q: %v", + logrus.Warnf("Failed to seed from %q to %q: %v", source.Seed, nfsMountPath, err) return api.BadVolumeID, err } @@ -225,14 +223,14 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api f, err := os.Create(path.Join(nfsMountPath, string(volumeID)+nfsBlockFile)) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } defer f.Close() err = f.Truncate(int64(spec.Size)) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } @@ -259,7 +257,7 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api func (d *driver) Delete(volumeID api.VolumeID) error { v, err := d.GetVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -271,7 +269,7 @@ func (d *driver) Delete(volumeID api.VolumeID) error { err = d.DeleteVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -281,7 +279,7 @@ func (d *driver) Delete(volumeID api.VolumeID) error { func (d *driver) Mount(volumeID api.VolumeID, mountpath string) error { v, err := d.GetVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -291,7 +289,7 @@ func (d *driver) Mount(volumeID api.VolumeID, mountpath string) error { d.mounter.Unmount(path.Join(nfsMountPath, string(volumeID)), mountpath) err = d.mounter.Mount(0, path.Join(nfsMountPath, string(volumeID)), mountpath, string(v.Spec.Format), syscall.MS_BIND, "") if err != nil { - log.Printf("Cannot mount %s at %s because %+v", + logrus.Printf("Cannot mount %s at %s because %+v", path.Join(nfsMountPath, string(volumeID)), mountpath, err) return err } @@ -375,7 +373,7 @@ func (d *driver) Alerts(volumeID api.VolumeID) (api.Alerts, error) { } func (d *driver) Shutdown() { - log.Printf("%s Shutting down", Name) + logrus.Printf("%s Shutting down", Name) syscall.Unmount(nfsMountPath, 0) } diff --git a/volume/drivers/test/driver.go b/volume/drivers/test/driver.go index 4ffec518c..08c096889 100644 --- a/volume/drivers/test/driver.go +++ b/volume/drivers/test/driver.go @@ -8,14 +8,12 @@ import ( "testing" "time" - log "github.com/Sirupsen/logrus" - "github.com/stretchr/testify/assert" - - "github.com/portworx/kvdb" - "github.com/portworx/kvdb/mem" - + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/volume" + "github.com/portworx/kvdb" + "github.com/portworx/kvdb/mem" + "github.com/stretchr/testify/assert" ) // Context maintains current device state. It gets passed into tests @@ -345,10 +343,10 @@ func snapDelete(t *testing.T, ctx *Context) { func init() { kv, err := kvdb.New(mem.Name, "driver_test", []string{}, nil) if err != nil { - log.Panicf("Failed to intialize KVDB") + logrus.Panicf("Failed to intialize KVDB") } err = kvdb.SetInstance(kv) if err != nil { - log.Panicf("Failed to set KVDB instance") + logrus.Panicf("Failed to set KVDB instance") } } diff --git a/volume/drivers/vfs/vfs.go b/volume/drivers/vfs/vfs.go index 965e56359..8095c26ad 100644 --- a/volume/drivers/vfs/vfs.go +++ b/volume/drivers/vfs/vfs.go @@ -8,7 +8,7 @@ import ( "syscall" "time" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" "github.com/libopenstorage/openstorage/api" "github.com/libopenstorage/openstorage/volume" "github.com/pborman/uuid" @@ -52,7 +52,7 @@ func (d *driver) Create(locator api.VolumeLocator, source *api.Source, spec *api // Create a directory on the Local machine with this UUID. err := os.MkdirAll(path.Join(volumeBase, string(volumeID)), 0744) if err != nil { - log.Println(err) + logrus.Println(err) return api.BadVolumeID, err } @@ -83,7 +83,7 @@ func (d *driver) Delete(volumeID api.VolumeID) error { // Check if volume exists _, err := d.GetVol(volumeID) if err != nil { - log.Println("Volume not found ", err) + logrus.Println("Volume not found ", err) return err } @@ -92,7 +92,7 @@ func (d *driver) Delete(volumeID api.VolumeID) error { err = d.DeleteVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } @@ -106,13 +106,13 @@ func (d *driver) Mount(volumeID api.VolumeID, mountpath string) error { v, err := d.GetVol(volumeID) if err != nil { - log.Println(err) + logrus.Println(err) return err } syscall.Unmount(mountpath, 0) err = syscall.Mount(path.Join(volumeBase, string(volumeID)), mountpath, string(v.Spec.Format), syscall.MS_BIND, "") if err != nil { - log.Printf("Cannot mount %s at %s because %+v", + logrus.Printf("Cannot mount %s at %s because %+v", path.Join(volumeBase, string(volumeID)), mountpath, err) return err } @@ -177,7 +177,7 @@ func (d *driver) Status() [][2]string { // Shutdown and cleanup. func (d *driver) Shutdown() { - log.Debugf("%s Shutting down", Name) + logrus.Debugf("%s Shutting down", Name) } func init() { diff --git a/volume/enumerator_test.go b/volume/enumerator_test.go index 81056f204..2fe65318b 100644 --- a/volume/enumerator_test.go +++ b/volume/enumerator_test.go @@ -3,13 +3,11 @@ package volume import ( "testing" - log "github.com/Sirupsen/logrus" - "github.com/stretchr/testify/assert" - + "github.com/Sirupsen/logrus" + "github.com/libopenstorage/openstorage/api" "github.com/portworx/kvdb" "github.com/portworx/kvdb/mem" - - "github.com/libopenstorage/openstorage/api" + "github.com/stretchr/testify/assert" ) var ( @@ -135,11 +133,11 @@ func TestSnapEnumerate(t *testing.T) { func init() { kv, err := kvdb.New(mem.Name, "driver_test", []string{}, nil) if err != nil { - log.Panicf("Failed to intialize KVDB") + logrus.Panicf("Failed to intialize KVDB") } err = kvdb.SetInstance(kv) if err != nil { - log.Panicf("Failed to set KVDB instance") + logrus.Panicf("Failed to set KVDB instance") } e = NewDefaultEnumerator("enumerator_test", kv)