Skip to content

Commit

Permalink
feature: add CriEnabled field in api and show this in cli
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Sun <allensun.shl@alibaba-inc.com>
allencloud committed Jul 30, 2018

Verified

This commit was signed with the committer’s verified signature.
gregorjerse Gregor Jerše
1 parent e42ceba commit b135c2f
Showing 6 changed files with 64 additions and 35 deletions.
7 changes: 7 additions & 0 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
@@ -1524,6 +1524,13 @@ definitions:
x-nullable: false
default: false
example: false
CriEnabled:
description: |
Indicates if pouchd has accepted flag --enable-cri and enables cri part.
type: "boolean"
x-nullable: false
default: false
example: false
ContainerdCommit:
$ref: "#/definitions/Commit"
RuncCommit:
6 changes: 6 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.

71 changes: 36 additions & 35 deletions cli/info.go
Original file line number Diff line number Diff line change
@@ -55,56 +55,57 @@ func (v *InfoCommand) runInfo() error {
}

func prettyPrintInfo(cli *Cli, info *types.SystemInfo) error {
fmt.Fprintln(os.Stdout, "Containers:", info.Containers)
fmt.Fprintln(os.Stdout, " Running:", info.ContainersRunning)
fmt.Fprintln(os.Stdout, " Paused:", info.ContainersPaused)
fmt.Fprintln(os.Stdout, " Stopped:", info.ContainersStopped)
fmt.Fprintln(os.Stdout, "Containers: ", info.Containers)
fmt.Fprintln(os.Stdout, " Running: ", info.ContainersRunning)
fmt.Fprintln(os.Stdout, " Paused: ", info.ContainersPaused)
fmt.Fprintln(os.Stdout, " Stopped: ", info.ContainersStopped)
fmt.Fprintln(os.Stdout, "Images: ", info.Images)
fmt.Fprintln(os.Stdout, "ID:", info.ID)
fmt.Fprintln(os.Stdout, "Name:", info.Name)
fmt.Fprintln(os.Stdout, "Server Version:", info.ServerVersion)
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)
fmt.Fprintln(os.Stdout, "Default Runtime:", info.DefaultRuntime)
fmt.Fprintln(os.Stdout, "ID: ", info.ID)
fmt.Fprintln(os.Stdout, "Name: ", info.Name)
fmt.Fprintln(os.Stdout, "Server Version: ", info.ServerVersion)
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)
fmt.Fprintln(os.Stdout, "Default Runtime: ", info.DefaultRuntime)
if len(info.Runtimes) > 0 {
fmt.Fprintf(os.Stdout, "Runtimes:")
fmt.Fprintf(os.Stdout, "Runtimes: ")
for name := range info.Runtimes {
fmt.Fprintf(os.Stdout, " %s", name)
}
fmt.Fprint(os.Stdout, "\n")
}
fmt.Fprintln(os.Stdout, "runc:", info.RuncCommit)
fmt.Fprintln(os.Stdout, "containerd:", info.ContainerdCommit)
fmt.Fprintln(os.Stdout, "runc: ", info.RuncCommit)
fmt.Fprintln(os.Stdout, "containerd: ", info.ContainerdCommit)

// Kernel info
fmt.Fprintln(os.Stdout, "Security Options:", info.SecurityOptions)
fmt.Fprintln(os.Stdout, "Kernel Version:", info.KernelVersion)
fmt.Fprintln(os.Stdout, "Operating System:", info.OperatingSystem)
fmt.Fprintln(os.Stdout, "OSType:", info.OSType)
fmt.Fprintln(os.Stdout, "Architecture:", info.Architecture)

fmt.Fprintln(os.Stdout, "HTTP Proxy:", info.HTTPProxy)
fmt.Fprintln(os.Stdout, "HTTPS Proxy:", info.HTTPSProxy)
fmt.Fprintln(os.Stdout, "Registry:", info.IndexServerAddress)
fmt.Fprintln(os.Stdout, "Experimental:", info.ExperimentalBuild)
fmt.Fprintln(os.Stdout, "Debug:", info.Debug)
fmt.Fprintln(os.Stdout, "Security Options: ", info.SecurityOptions)
fmt.Fprintln(os.Stdout, "Kernel Version: ", info.KernelVersion)
fmt.Fprintln(os.Stdout, "Operating System: ", info.OperatingSystem)
fmt.Fprintln(os.Stdout, "OSType: ", info.OSType)
fmt.Fprintln(os.Stdout, "Architecture: ", info.Architecture)

fmt.Fprintln(os.Stdout, "HTTP Proxy: ", info.HTTPProxy)
fmt.Fprintln(os.Stdout, "HTTPS Proxy: ", info.HTTPSProxy)
fmt.Fprintln(os.Stdout, "Registry: ", info.IndexServerAddress)
fmt.Fprintln(os.Stdout, "Experimental: ", info.ExperimentalBuild)
fmt.Fprintln(os.Stdout, "Debug: ", info.Debug)
if len(info.Labels) != 0 {
fmt.Fprintln(os.Stdout, "Labels:")
fmt.Fprintln(os.Stdout, "Labels: ")
for _, label := range info.Labels {
fmt.Fprintf(os.Stdout, " %s\n", label)
}
}

fmt.Fprintln(os.Stdout, "CPUs:", info.NCPU)
fmt.Fprintln(os.Stdout, "CPUs: ", info.NCPU)
fmt.Fprintln(os.Stdout, "Total Memory: "+units.BytesSize(float64(info.MemTotal)))
fmt.Fprintln(os.Stdout, "Pouch Root Dir:", info.PouchRootDir)
fmt.Fprintln(os.Stdout, "LiveRestoreEnabled:", info.LiveRestoreEnabled)
fmt.Fprintln(os.Stdout, "LxcfsEnabled:", info.LxcfsEnabled)
fmt.Fprintln(os.Stdout, "Pouch Root Dir: ", info.PouchRootDir)
fmt.Fprintln(os.Stdout, "LiveRestoreEnabled: ", info.LiveRestoreEnabled)
fmt.Fprintln(os.Stdout, "LxcfsEnabled: ", info.LxcfsEnabled)
fmt.Fprintln(os.Stdout, "CriEnabled: ", info.CriEnabled)
if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
fmt.Fprintln(os.Stdout, "Insecure Registries:")
fmt.Fprintln(os.Stdout, "Insecure Registries: ")
for _, registry := range info.RegistryConfig.IndexConfigs {
if !registry.Secure {
fmt.Fprintln(os.Stdout, " "+registry.Name)
@@ -117,13 +118,13 @@ func prettyPrintInfo(cli *Cli, info *types.SystemInfo) error {
}

if info.RegistryConfig != nil && len(info.RegistryConfig.Mirrors) > 0 {
fmt.Fprintln(os.Stdout, "Registry Mirrors:")
fmt.Fprintln(os.Stdout, "Registry Mirrors: ")
for _, mirror := range info.RegistryConfig.Mirrors {
fmt.Fprintln(os.Stdout, " "+mirror)
}
}

fmt.Fprintln(os.Stdout, "Daemon Listen Addresses:", info.ListenAddresses)
fmt.Fprintln(os.Stdout, "Daemon Listen Addresses: ", info.ListenAddresses)

return nil
}
1 change: 1 addition & 0 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
LoggingDriver: mgr.config.DefaultLogConfig.LogDriver,
VolumeDrivers: volumeDrivers,
LxcfsEnabled: mgr.config.IsLxcfsEnabled,
CriEnabled: mgr.config.IsCriEnabled,
MemTotal: totalMem,
Name: hostname,
NCPU: int64(runtime.NumCPU()),
1 change: 1 addition & 0 deletions test/api_system_test.go
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ 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()))
c.Assert(got.CriEnabled, check.Equals, false)

// Check the volume drivers
c.Assert(len(got.VolumeDrivers), check.Equals, 3)
13 changes: 13 additions & 0 deletions test/z_cli_daemon_test.go
Original file line number Diff line number Diff line change
@@ -389,6 +389,19 @@ func (suite *PouchDaemonSuite) TestDaemonDefaultRegistry(c *check.C) {
defer dcfg.KillDaemon()
}

// TestDaemonCriEnbaled tests enabling cri part in pouchd.
func (suite *PouchDaemonSuite) TestDaemonCriEnbaled(c *check.C) {
dcfg, err := StartDefaultDaemonDebug(
"--enable-cri")
c.Assert(err, check.IsNil)

result := RunWithSpecifiedDaemon(dcfg, "info")
err = util.PartialEqual(result.Combined(), "CriEnabled: true")
c.Assert(err, check.IsNil)

defer dcfg.KillDaemon()
}

// TestDaemonTlsVerify tests start daemon with TLS verification enabled.
func (suite *PouchDaemonSuite) TestDaemonTlsVerify(c *check.C) {
SkipIfFalse(c, IsTLSExist)

0 comments on commit b135c2f

Please sign in to comment.