Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
CreateNamespace: do not hide error from lower call
Browse files Browse the repository at this point in the history
  • Loading branch information
okartau committed Jan 10, 2019
1 parent f271816 commit df19ed0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/ndctl/ndctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ package ndctl
//#include <ndctl/libndctl.h>
//#include <ndctl/ndctl.h>
import "C"
import "fmt"

import (
"fmt"
"github.com/pkg/errors"
"k8s.io/klog/glog"
)

const (
kib uint64 = 1024
Expand Down Expand Up @@ -62,14 +67,19 @@ func (ctx *Context) GetBuses() []*Bus {

//CreateNamespace create new namespace with given opts
func (ctx *Context) CreateNamespace(opts CreateNamespaceOpts) (*Namespace, error) {
var err error
var ns *Namespace
for _, bus := range ctx.GetBuses() {
for _, r := range bus.ActiveRegions() {
if ns, err := r.CreateNamespace(opts); err == nil {
if ns, err = r.CreateNamespace(opts); err == nil {
glog.Infof("Namespace %s created in %s", ns.Name(), r.DeviceName())
return ns, nil
} else {
glog.Errorf("Namespace creation failure in %s: %s", r.DeviceName(), err.Error())
}
}
}
return nil, fmt.Errorf("Failed to create namespace")
return nil, errors.Wrap(err, "failed to create namespace")
}

//DestroyNamespaceByName deletes namespace with given name
Expand Down

0 comments on commit df19ed0

Please sign in to comment.