Skip to content

Commit

Permalink
Merge pull request AliyunContainerService#1238 from ZouRui89/info
Browse files Browse the repository at this point in the history
enhance: add more field in 'pouch info' command
  • Loading branch information
allencloud authored May 9, 2018
2 parents 77ab865 + 162c050 commit 819c4d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
7 changes: 7 additions & 0 deletions daemon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"sync"

"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/client"
"github.com/alibaba/pouch/cri"
"github.com/alibaba/pouch/network"
Expand Down Expand Up @@ -98,6 +99,12 @@ type Config struct {

// Pidfile keeps daemon pid
Pidfile string `json:"pidfile,omitempty"`

// Default log configuration
DefaultLogConfig types.HostConfigAO0LogConfig `json:"default-log-config, omitempty"`

// RegistryService
RegistryService types.RegistryServiceConfig `json:"registry-service, omitempty" `
}

// Validate validates the user input config.
Expand Down
38 changes: 23 additions & 15 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mgr

import (
"context"
"fmt"
"os"
"runtime"
Expand Down Expand Up @@ -33,16 +34,18 @@ type SystemManager struct {
name string
registry *registry.Client
config *config.Config
imageMgr ImageMgr

store *meta.Store
}

// NewSystemManager creates a brand new system manager.
func NewSystemManager(cfg *config.Config, store *meta.Store) (*SystemManager, error) {
func NewSystemManager(cfg *config.Config, store *meta.Store, imageManager ImageMgr) (*SystemManager, error) {
return &SystemManager{
name: "system_manager",
registry: &registry.Client{},
config: cfg,
imageMgr: imageManager,
store: store,
}, nil
}
Expand Down Expand Up @@ -96,8 +99,13 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
OSName = osName
}

images, err := mgr.imageMgr.ListImages(context.Background(), "")
if err != nil {
logrus.Warnf("failed to get image info: %v", err)
}

info := types.SystemInfo{
// architecture: ,
Architecture: runtime.GOARCH,
// CgroupDriver: ,
// ContainerdCommit: ,
Containers: cRunning + cPaused + cStopped,
Expand All @@ -109,25 +117,25 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
// FIXME: avoid hard code
Driver: "overlayfs",
// DriverStatus: ,
// ExperimentalBuild: ,
HTTPProxy: mgr.config.ImageProxy,
ExperimentalBuild: false,
HTTPProxy: mgr.config.ImageProxy,
// HTTPSProxy: ,
// ID: ,
// Images: ,
Images: int64(len(images)),
IndexServerAddress: "https://index.docker.io/v1/",
DefaultRegistry: mgr.config.DefaultRegistry,
KernelVersion: kernelVersion,
Labels: mgr.config.Labels,
// LiveRestoreEnabled: ,
// LoggingDriver: ,
LxcfsEnabled: mgr.config.IsLxcfsEnabled,
MemTotal: totalMem,
Name: hostname,
NCPU: int64(runtime.NumCPU()),
OperatingSystem: OSName,
OSType: runtime.GOOS,
PouchRootDir: mgr.config.HomeDir,
// RegistryConfig: ,
LiveRestoreEnabled: true,
LoggingDriver: mgr.config.DefaultLogConfig.Type,
LxcfsEnabled: mgr.config.IsLxcfsEnabled,
MemTotal: totalMem,
Name: hostname,
NCPU: int64(runtime.NumCPU()),
OperatingSystem: OSName,
OSType: runtime.GOOS,
PouchRootDir: mgr.config.HomeDir,
RegistryConfig: &mgr.config.RegistryService,
// RuncCommit: ,
// Runtimes: ,
// SecurityOptions: ,
Expand Down
2 changes: 1 addition & 1 deletion internal/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func GenContainerMgr(ctx context.Context, d DaemonProvider) (mgr.ContainerMgr, e

// GenSystemMgr generates a SystemMgr instance according to config cfg.
func GenSystemMgr(cfg *config.Config, d DaemonProvider) (mgr.SystemMgr, error) {
return mgr.NewSystemManager(cfg, d.MetaStore())
return mgr.NewSystemManager(cfg, d.MetaStore(), d.ImgMgr())
}

// GenImageMgr generates a ImageMgr instance according to config cfg.
Expand Down

0 comments on commit 819c4d3

Please sign in to comment.