Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling of RBD modprobe #576

Merged
merged 1 commit into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .docs/user-guide/storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,18 @@ example see the [Examples](./storage-providers.md#ceph-rbd-examples) section.
```yaml
rbd:
defaultPool: rbd
testModule: true
```

##### Configuration Notes

* The `defaultPool` parameter is optional, and defaults to "rbd". When set, all
volume requests that do not reference a specific pool will use the
`defaultPool` value as the destination storage pool.
* The `testModule` parameter is optional, and defaults to "true". This setting
indicates whether the libStorage client should test if the `rbd` kernel module
is loaded, with the side-effect of loading it if is not already loaded. This
setting should be disabled when the driver is executing inside of a container.

#### Runtime behavior

Expand Down
12 changes: 8 additions & 4 deletions drivers/storage/rbd/executor/rbd_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
)

type driver struct {
config gofig.Config
config gofig.Config
doModprobe bool
}

func init() {
Expand All @@ -34,6 +35,7 @@ func newdriver() types.StorageExecutor {

func (d *driver) Init(context types.Context, config gofig.Config) error {
d.config = config
d.doModprobe = config.GetBool(rbd.ConfigTestModule)
return nil
}

Expand All @@ -57,9 +59,11 @@ func (d *driver) Supported(
return false, nil
}

cmd := exec.Command("modprobe", "rbd")
if _, _, err := utils.RunCommand(ctx, cmd); err != nil {
return false, nil
if d.doModprobe {
cmd := exec.Command("modprobe", "rbd")
if _, _, err := utils.RunCommand(ctx, cmd); err != nil {
return false, nil
}
}

return true, nil
Expand Down
9 changes: 8 additions & 1 deletion drivers/storage/rbd/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
const (
// Name is the name of the storage driver
Name = "rbd"

// ConfigDefaultPool is the config key for default pool
ConfigDefaultPool = Name + ".defaultPool"

// ConfigTestModule is the config key for testing kernel module presence
ConfigTestModule = Name + ".testModule"
)

func init() {
Expand All @@ -18,6 +24,7 @@ func init() {

func registerConfig() {
r := gofigCore.NewRegistration("RBD")
r.Key(gofig.String, "", "rbd", "", "rbd.defaultPool")
r.Key(gofig.String, "", "rbd", "", ConfigDefaultPool)
r.Key(gofig.Bool, "", true, "", ConfigTestModule)
gofigCore.Register(r)
}
2 changes: 1 addition & 1 deletion drivers/storage/rbd/storage/rbd_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (d *driver) SnapshotRemove(
}

func (d *driver) defaultPool() string {
return d.config.GetString("rbd.defaultPool")
return d.config.GetString(rbd.ConfigDefaultPool)
}

func (d *driver) toTypeVolumes(
Expand Down