Skip to content

Commit

Permalink
Merge pull request #1352 from shaloulcy/pouch_info_volume_driver
Browse files Browse the repository at this point in the history
feature: add volume drivers info for system info
  • Loading branch information
rudyfly authored May 20, 2018
2 parents 33e585d + 480f054 commit 705dc49
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,13 @@ definitions:
description: |
The logging driver to use as a default for new containers.
type: "string"
VolumeDrivers:
description: |
The list of volume drivers which the pouchd supports
type: "array"
items:
type: "string"
example: ["local", "tmpfs"]
CgroupDriver:
description: |
The driver to use for managing cgroups.
Expand Down
20 changes: 20 additions & 0 deletions apis/types/system_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func prettyPrintInfo(cli *Cli, info *types.SystemInfo) error {
fmt.Fprintln(os.Stdout, "Storage Driver:", info.Driver)
fmt.Fprintln(os.Stdout, "Driver Status:", info.DriverStatus)
fmt.Fprintln(os.Stdout, "Logging Driver:", info.LoggingDriver)
fmt.Fprintln(os.Stdout, "Volume Drivers:", info.VolumeDrivers)
fmt.Fprintln(os.Stdout, "Cgroup Driver:", info.CgroupDriver)
if len(info.Runtimes) > 0 {
fmt.Fprintln(os.Stdout, "Runtimes:")
Expand Down
3 changes: 3 additions & 0 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/alibaba/pouch/pkg/meta"
"github.com/alibaba/pouch/pkg/system"
"github.com/alibaba/pouch/registry"
volumedriver "github.com/alibaba/pouch/storage/volume/driver"
"github.com/alibaba/pouch/version"

"github.com/pkg/errors"
Expand Down Expand Up @@ -103,6 +104,7 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
if err != nil {
logrus.Warnf("failed to get image info: %v", err)
}
volumeDrivers := volumedriver.AllDriversName()

info := types.SystemInfo{
Architecture: runtime.GOARCH,
Expand All @@ -128,6 +130,7 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
Labels: mgr.config.Labels,
LiveRestoreEnabled: true,
LoggingDriver: mgr.config.DefaultLogConfig.LogDriver,
VolumeDrivers: volumeDrivers,
LxcfsEnabled: mgr.config.IsLxcfsEnabled,
MemTotal: totalMem,
Name: hostname,
Expand Down
7 changes: 7 additions & 0 deletions storage/volume/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package driver
import (
"fmt"
"regexp"
"sort"
"sync"

"github.com/alibaba/pouch/plugins"
Expand Down Expand Up @@ -220,6 +221,9 @@ func Exist(name string) bool {

// AllDriversName return all registered backend driver's name.
func AllDriversName() []string {
// probing all volume plugins.
backendDrivers.GetAll()

backendDrivers.Lock()
defer backendDrivers.Unlock()

Expand All @@ -228,6 +232,9 @@ func AllDriversName() []string {
names = append(names, n)
}

// sort the names.
sort.Strings(names)

return names
}

Expand Down
6 changes: 6 additions & 0 deletions test/api_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ func (suite *APISystemSuite) TestInfo(c *check.C) {
c.Assert(got.ServerVersion, check.Equals, version.Version)
c.Assert(got.Driver, check.Equals, "overlayfs")
c.Assert(got.NCPU, check.Equals, int64(runtime.NumCPU()))

// Check the volume drivers
c.Assert(len(got.VolumeDrivers), check.Equals, 3)
c.Assert(got.VolumeDrivers[0], check.Equals, "ceph")
c.Assert(got.VolumeDrivers[1], check.Equals, "local")
c.Assert(got.VolumeDrivers[2], check.Equals, "tmpfs")
}

// TestVersion tests /version API.
Expand Down

0 comments on commit 705dc49

Please sign in to comment.