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

enhance: add more field in 'pouch info' command #1238

Merged
merged 1 commit into from
May 9, 2018
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
7 changes: 7 additions & 0 deletions daemon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -97,6 +98,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" `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We add this field in the code, however I am afraid we have not add this field's assignment in manager's code, right? Do we have a plan to add this field assignment? @ZouRui89

}

// 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