diff --git a/daemon/config/config.go b/daemon/config/config.go index 25bd07655..bf7081b41 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -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" @@ -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" ` } // Validate validates the user input config. diff --git a/daemon/mgr/system.go b/daemon/mgr/system.go index 5268200e5..89fca3deb 100644 --- a/daemon/mgr/system.go +++ b/daemon/mgr/system.go @@ -1,6 +1,7 @@ package mgr import ( + "context" "fmt" "os" "runtime" @@ -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: ®istry.Client{}, config: cfg, + imageMgr: imageManager, store: store, }, nil } @@ -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, @@ -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: , diff --git a/internal/generator.go b/internal/generator.go index 4aeb7abb6..3d04883c5 100644 --- a/internal/generator.go +++ b/internal/generator.go @@ -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.