mirror of https://github.com/containers/podman.git
compat: Add DefaultAddressPools field to GET /info
Signed-off-by: Nicola Sella <nsella@redhat.com>
This commit is contained in:
parent
ee283c7514
commit
7c0262db3d
|
@ -55,53 +55,54 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
// liveRestoreEnabled := criu.CheckForCriu() && configInfo.RuntimeSupportsCheckpoint()
|
// liveRestoreEnabled := criu.CheckForCriu() && configInfo.RuntimeSupportsCheckpoint()
|
||||||
info := &handlers.Info{
|
info := &handlers.Info{
|
||||||
Info: dockerSystem.Info{
|
Info: dockerSystem.Info{
|
||||||
Architecture: goRuntime.GOARCH,
|
Architecture: goRuntime.GOARCH,
|
||||||
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
||||||
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
||||||
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
||||||
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
||||||
CPUSet: sysInfo.Cpuset,
|
CPUSet: sysInfo.Cpuset,
|
||||||
CPUShares: sysInfo.CPUShares,
|
CPUShares: sysInfo.CPUShares,
|
||||||
CgroupDriver: configInfo.Engine.CgroupManager,
|
CgroupDriver: configInfo.Engine.CgroupManager,
|
||||||
ContainerdCommit: dockerSystem.Commit{},
|
ContainerdCommit: dockerSystem.Commit{},
|
||||||
Containers: infoData.Store.ContainerStore.Number,
|
Containers: infoData.Store.ContainerStore.Number,
|
||||||
ContainersPaused: stateInfo[define.ContainerStatePaused],
|
ContainersPaused: stateInfo[define.ContainerStatePaused],
|
||||||
ContainersRunning: stateInfo[define.ContainerStateRunning],
|
ContainersRunning: stateInfo[define.ContainerStateRunning],
|
||||||
ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited],
|
ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited],
|
||||||
Debug: log.IsLevelEnabled(log.DebugLevel),
|
Debug: log.IsLevelEnabled(log.DebugLevel),
|
||||||
DefaultRuntime: configInfo.Engine.OCIRuntime,
|
DefaultAddressPools: getDefaultAddressPools(configInfo),
|
||||||
DockerRootDir: infoData.Store.GraphRoot,
|
DefaultRuntime: configInfo.Engine.OCIRuntime,
|
||||||
Driver: infoData.Store.GraphDriverName,
|
DockerRootDir: infoData.Store.GraphRoot,
|
||||||
DriverStatus: getGraphStatus(infoData.Store.GraphStatus),
|
Driver: infoData.Store.GraphDriverName,
|
||||||
ExperimentalBuild: true,
|
DriverStatus: getGraphStatus(infoData.Store.GraphStatus),
|
||||||
GenericResources: nil,
|
ExperimentalBuild: true,
|
||||||
HTTPProxy: getEnv("http_proxy"),
|
GenericResources: nil,
|
||||||
HTTPSProxy: getEnv("https_proxy"),
|
HTTPProxy: getEnv("http_proxy"),
|
||||||
ID: uuid.New().String(),
|
HTTPSProxy: getEnv("https_proxy"),
|
||||||
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
ID: uuid.New().String(),
|
||||||
Images: infoData.Store.ImageStore.Number,
|
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
||||||
IndexServerAddress: "",
|
Images: infoData.Store.ImageStore.Number,
|
||||||
InitBinary: "",
|
IndexServerAddress: "",
|
||||||
InitCommit: dockerSystem.Commit{},
|
InitBinary: "",
|
||||||
Isolation: "",
|
InitCommit: dockerSystem.Commit{},
|
||||||
KernelMemoryTCP: false,
|
Isolation: "",
|
||||||
KernelVersion: infoData.Host.Kernel,
|
KernelMemoryTCP: false,
|
||||||
Labels: nil,
|
KernelVersion: infoData.Host.Kernel,
|
||||||
LiveRestoreEnabled: false,
|
Labels: nil,
|
||||||
LoggingDriver: "",
|
LiveRestoreEnabled: false,
|
||||||
MemTotal: infoData.Host.MemTotal,
|
LoggingDriver: "",
|
||||||
MemoryLimit: sysInfo.MemoryLimit,
|
MemTotal: infoData.Host.MemTotal,
|
||||||
NCPU: goRuntime.NumCPU(),
|
MemoryLimit: sysInfo.MemoryLimit,
|
||||||
NEventsListener: 0,
|
NCPU: goRuntime.NumCPU(),
|
||||||
NFd: getFdCount(),
|
NEventsListener: 0,
|
||||||
NGoroutines: goRuntime.NumGoroutine(),
|
NFd: getFdCount(),
|
||||||
Name: infoData.Host.Hostname,
|
NGoroutines: goRuntime.NumGoroutine(),
|
||||||
NoProxy: getEnv("no_proxy"),
|
Name: infoData.Host.Hostname,
|
||||||
OSType: goRuntime.GOOS,
|
NoProxy: getEnv("no_proxy"),
|
||||||
OSVersion: infoData.Host.Distribution.Version,
|
OSType: goRuntime.GOOS,
|
||||||
OomKillDisable: sysInfo.OomKillDisable,
|
OSVersion: infoData.Host.Distribution.Version,
|
||||||
OperatingSystem: infoData.Host.Distribution.Distribution,
|
OomKillDisable: sysInfo.OomKillDisable,
|
||||||
PidsLimit: sysInfo.PidsLimit,
|
OperatingSystem: infoData.Host.Distribution.Distribution,
|
||||||
|
PidsLimit: sysInfo.PidsLimit,
|
||||||
Plugins: dockerSystem.PluginsInfo{
|
Plugins: dockerSystem.PluginsInfo{
|
||||||
Volume: infoData.Plugins.Volume,
|
Volume: infoData.Plugins.Volume,
|
||||||
Network: infoData.Plugins.Network,
|
Network: infoData.Plugins.Network,
|
||||||
|
@ -237,3 +238,24 @@ func getEnv(value string) string {
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDefaultAddressPools(configInfo *config.Config) []dockerSystem.NetworkAddressPool {
|
||||||
|
// Convert DefaultSubnetPools to DefaultAddressPools
|
||||||
|
if len(configInfo.Network.DefaultSubnetPools) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pools := make([]dockerSystem.NetworkAddressPool, 0, len(configInfo.Network.DefaultSubnetPools))
|
||||||
|
for _, pool := range configInfo.Network.DefaultSubnetPools {
|
||||||
|
if pool.Base == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pools = append(pools, dockerSystem.NetworkAddressPool{
|
||||||
|
Base: pool.Base.String(),
|
||||||
|
Size: pool.Size,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return pools
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
# -*- sh -*-
|
||||||
|
#
|
||||||
|
# subnet pools conversion tests
|
||||||
|
#
|
||||||
|
|
||||||
|
# Create a temporary containers.conf with custom DefaultSubnetPools
|
||||||
|
testdir=$(mktemp -d)
|
||||||
|
cat > $testdir/containers.default_subnet_pools.conf <<EOF
|
||||||
|
[network]
|
||||||
|
default_subnet_pools = [
|
||||||
|
{ "base" = "10.89.0.0/16", "size" = 24 },
|
||||||
|
{ "base" = "10.90.0.0/15", "size" = 26 }
|
||||||
|
]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Restart podman with custom config
|
||||||
|
stop_service
|
||||||
|
CONTAINERS_CONF=$testdir/containers.default_subnet_pools.conf start_service
|
||||||
|
|
||||||
|
# Test the Docker-compatible API endpoints
|
||||||
|
t GET info 200 \
|
||||||
|
'.DefaultAddressPools | length=2' \
|
||||||
|
'.DefaultAddressPools[0].Base=10.89.0.0/16' \
|
||||||
|
'.DefaultAddressPools[0].Size=24' \
|
||||||
|
'.DefaultAddressPools[1].Base=10.90.0.0/15' \
|
||||||
|
'.DefaultAddressPools[1].Size=26'
|
||||||
|
|
||||||
|
# Restart with the default containers.conf for next tests.
|
||||||
|
rm -rf $testdir
|
||||||
|
stop_service
|
||||||
|
start_service
|
Loading…
Reference in New Issue