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 7, 2019
1 parent 0189627 commit 2f8600b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/ndctl/ndctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ package ndctl
//#include <ndctl/libndctl.h>
//#include <ndctl/ndctl.h>
import "C"
import "fmt"

import (
"fmt"
"github.com/pkg/errors"
)

const (
kib uint64 = 1024
Expand Down Expand Up @@ -62,14 +66,18 @@ 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 {
return ns, nil
} else {
err = errors.Wrap(err, "")
}
}
}
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 2f8600b

Please sign in to comment.