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

feature: add CriEnabled field in api and show this in cli #1918

Merged
merged 1 commit into from
Jul 30, 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 apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
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
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions test/api_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions test/z_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down