CleanUp problems found my make lint.
Remove or comment out unused functions. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #145 Approved by: umohnani8
This commit is contained in:
parent
f2f9fdf126
commit
de3468e120
|
|
@ -6,7 +6,6 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
is "github.com/containers/image/storage"
|
||||
"github.com/containers/storage"
|
||||
"github.com/fatih/camelcase"
|
||||
"github.com/pkg/errors"
|
||||
|
|
@ -21,22 +20,6 @@ var (
|
|||
|
||||
const crioConfigPath = "/etc/crio/crio.conf"
|
||||
|
||||
func getStore(c *libkpod.Config) (storage.Store, error) {
|
||||
options := storage.DefaultStoreOptions
|
||||
options.GraphRoot = c.Root
|
||||
options.RunRoot = c.RunRoot
|
||||
options.GraphDriverName = c.Storage
|
||||
options.GraphDriverOptions = c.StorageOptions
|
||||
|
||||
store, err := storage.GetStore(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
is.Transport.SetStore(store)
|
||||
stores[store] = struct{}{}
|
||||
return store, nil
|
||||
}
|
||||
|
||||
func getRuntime(c *cli.Context) (*libpod.Runtime, error) {
|
||||
|
||||
config, err := getConfig(c)
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ var (
|
|||
type createResourceConfig struct {
|
||||
BlkioWeight uint16 // blkio-weight
|
||||
BlkioWeightDevice []string // blkio-weight-device
|
||||
CpuPeriod uint64 // cpu-period
|
||||
CpuQuota int64 // cpu-quota
|
||||
CpuRtPeriod uint64 // cpu-rt-period
|
||||
CpuRtRuntime int64 // cpu-rt-runtime
|
||||
CpuShares uint64 // cpu-shares
|
||||
Cpus string // cpus
|
||||
CpusetCpus string
|
||||
CpusetMems string // cpuset-mems
|
||||
CPUPeriod uint64 // cpu-period
|
||||
CPUQuota int64 // cpu-quota
|
||||
CPURtPeriod uint64 // cpu-rt-period
|
||||
CPURtRuntime int64 // cpu-rt-runtime
|
||||
CPUShares uint64 // cpu-shares
|
||||
CPUs string // cpus
|
||||
CPUsetCPUs string
|
||||
CPUsetMems string // cpuset-mems
|
||||
DeviceReadBps []string // device-read-bps
|
||||
DeviceReadIOps []string // device-read-iops
|
||||
DeviceWriteBps []string // device-write-bps
|
||||
|
|
@ -73,9 +73,9 @@ type createConfig struct {
|
|||
Command []string
|
||||
Detach bool // detach
|
||||
Devices []*pb.Device // device
|
||||
DnsOpt []string //dns-opt
|
||||
DnsSearch []string //dns-search
|
||||
DnsServers []string //dns
|
||||
DNSOpt []string //dns-opt
|
||||
DNSSearch []string //dns-search
|
||||
DNSServers []string //dns
|
||||
Entrypoint string //entrypoint
|
||||
Env map[string]string //env
|
||||
Expose []string //expose
|
||||
|
|
@ -84,8 +84,8 @@ type createConfig struct {
|
|||
Image string
|
||||
Interactive bool //interactive
|
||||
IpcMode container.IpcMode //ipc
|
||||
Ip6Address string //ipv6
|
||||
IpAddress string //ip
|
||||
IP6Address string //ipv6
|
||||
IPAddress string //ip
|
||||
Labels map[string]string //label
|
||||
LinkLocalIP []string // link-local-ip
|
||||
LogDriver string // log-driver
|
||||
|
|
@ -419,9 +419,9 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
|
|||
CgroupParent: c.String("cgroup-parent"),
|
||||
Command: command,
|
||||
Detach: c.Bool("detach"),
|
||||
DnsOpt: c.StringSlice("dns-opt"),
|
||||
DnsSearch: c.StringSlice("dns-search"),
|
||||
DnsServers: c.StringSlice("dns"),
|
||||
DNSOpt: c.StringSlice("dns-opt"),
|
||||
DNSSearch: c.StringSlice("dns-search"),
|
||||
DNSServers: c.StringSlice("dns"),
|
||||
Entrypoint: c.String("entrypoint"),
|
||||
Env: env,
|
||||
Expose: c.StringSlice("expose"),
|
||||
|
|
@ -429,8 +429,8 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
|
|||
Hostname: c.String("hostname"),
|
||||
Image: image,
|
||||
Interactive: c.Bool("interactive"),
|
||||
Ip6Address: c.String("ipv6"),
|
||||
IpAddress: c.String("ip"),
|
||||
IP6Address: c.String("ipv6"),
|
||||
IPAddress: c.String("ip"),
|
||||
Labels: labels,
|
||||
LinkLocalIP: c.StringSlice("link-local-ip"),
|
||||
LogDriver: c.String("log-driver"),
|
||||
|
|
@ -451,14 +451,14 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
|
|||
Resources: createResourceConfig{
|
||||
BlkioWeight: blkioWeight,
|
||||
BlkioWeightDevice: c.StringSlice("blkio-weight-device"),
|
||||
CpuShares: c.Uint64("cpu-shares"),
|
||||
CpuPeriod: c.Uint64("cpu-period"),
|
||||
CpusetCpus: c.String("cpu-period"),
|
||||
CpusetMems: c.String("cpuset-mems"),
|
||||
CpuQuota: c.Int64("cpu-quota"),
|
||||
CpuRtPeriod: c.Uint64("cpu-rt-period"),
|
||||
CpuRtRuntime: c.Int64("cpu-rt-runtime"),
|
||||
Cpus: c.String("cpus"),
|
||||
CPUShares: c.Uint64("cpu-shares"),
|
||||
CPUPeriod: c.Uint64("cpu-period"),
|
||||
CPUsetCPUs: c.String("cpu-period"),
|
||||
CPUsetMems: c.String("cpuset-mems"),
|
||||
CPUQuota: c.Int64("cpu-quota"),
|
||||
CPURtPeriod: c.Uint64("cpu-rt-period"),
|
||||
CPURtRuntime: c.Int64("cpu-rt-runtime"),
|
||||
CPUs: c.String("cpus"),
|
||||
DeviceReadBps: c.StringSlice("device-read-bps"),
|
||||
DeviceReadIOps: c.StringSlice("device-read-iops"),
|
||||
DeviceWriteBps: c.StringSlice("device-write-bps"),
|
||||
|
|
|
|||
|
|
@ -170,43 +170,43 @@ func verifyContainerResources(config *createConfig, update bool) ([]string, erro
|
|||
config.Resources.PidsLimit = 0
|
||||
}
|
||||
|
||||
if config.Resources.CpuShares > 0 && !sysInfo.CPUShares {
|
||||
if config.Resources.CPUShares > 0 && !sysInfo.CPUShares {
|
||||
warnings = addWarning(warnings, "Your kernel does not support CPU shares or the cgroup is not mounted. Shares discarded.")
|
||||
config.Resources.CpuShares = 0
|
||||
config.Resources.CPUShares = 0
|
||||
}
|
||||
if config.Resources.CpuPeriod > 0 && !sysInfo.CPUCfsPeriod {
|
||||
if config.Resources.CPUPeriod > 0 && !sysInfo.CPUCfsPeriod {
|
||||
warnings = addWarning(warnings, "Your kernel does not support CPU cfs period or the cgroup is not mounted. Period discarded.")
|
||||
config.Resources.CpuPeriod = 0
|
||||
config.Resources.CPUPeriod = 0
|
||||
}
|
||||
if config.Resources.CpuPeriod != 0 && (config.Resources.CpuPeriod < 1000 || config.Resources.CpuPeriod > 1000000) {
|
||||
if config.Resources.CPUPeriod != 0 && (config.Resources.CPUPeriod < 1000 || config.Resources.CPUPeriod > 1000000) {
|
||||
return warnings, fmt.Errorf("CPU cfs period can not be less than 1ms (i.e. 1000) or larger than 1s (i.e. 1000000)")
|
||||
}
|
||||
if config.Resources.CpuQuota > 0 && !sysInfo.CPUCfsQuota {
|
||||
if config.Resources.CPUQuota > 0 && !sysInfo.CPUCfsQuota {
|
||||
warnings = addWarning(warnings, "Your kernel does not support CPU cfs quota or the cgroup is not mounted. Quota discarded.")
|
||||
config.Resources.CpuQuota = 0
|
||||
config.Resources.CPUQuota = 0
|
||||
}
|
||||
if config.Resources.CpuQuota > 0 && config.Resources.CpuQuota < 1000 {
|
||||
if config.Resources.CPUQuota > 0 && config.Resources.CPUQuota < 1000 {
|
||||
return warnings, fmt.Errorf("CPU cfs quota can not be less than 1ms (i.e. 1000)")
|
||||
}
|
||||
// cpuset subsystem checks and adjustments
|
||||
if (config.Resources.CpusetCpus != "" || config.Resources.CpusetMems != "") && !sysInfo.Cpuset {
|
||||
warnings = addWarning(warnings, "Your kernel does not support cpuset or the cgroup is not mounted. Cpuset discarded.")
|
||||
config.Resources.CpusetCpus = ""
|
||||
config.Resources.CpusetMems = ""
|
||||
if (config.Resources.CPUsetCPUs != "" || config.Resources.CPUsetMems != "") && !sysInfo.Cpuset {
|
||||
warnings = addWarning(warnings, "Your kernel does not support cpuset or the cgroup is not mounted. CPUset discarded.")
|
||||
config.Resources.CPUsetCPUs = ""
|
||||
config.Resources.CPUsetMems = ""
|
||||
}
|
||||
cpusAvailable, err := sysInfo.IsCpusetCpusAvailable(config.Resources.CpusetCpus)
|
||||
cpusAvailable, err := sysInfo.IsCpusetCpusAvailable(config.Resources.CPUsetCPUs)
|
||||
if err != nil {
|
||||
return warnings, fmt.Errorf("invalid value %s for cpuset cpus", config.Resources.CpusetCpus)
|
||||
return warnings, fmt.Errorf("invalid value %s for cpuset cpus", config.Resources.CPUsetCPUs)
|
||||
}
|
||||
if !cpusAvailable {
|
||||
return warnings, fmt.Errorf("requested CPUs are not available - requested %s, available: %s", config.Resources.CpusetCpus, sysInfo.Cpus)
|
||||
return warnings, fmt.Errorf("requested CPUs are not available - requested %s, available: %s", config.Resources.CPUsetCPUs, sysInfo.Cpus)
|
||||
}
|
||||
memsAvailable, err := sysInfo.IsCpusetMemsAvailable(config.Resources.CpusetMems)
|
||||
memsAvailable, err := sysInfo.IsCpusetMemsAvailable(config.Resources.CPUsetMems)
|
||||
if err != nil {
|
||||
return warnings, fmt.Errorf("invalid value %s for cpuset mems", config.Resources.CpusetMems)
|
||||
return warnings, fmt.Errorf("invalid value %s for cpuset mems", config.Resources.CPUsetMems)
|
||||
}
|
||||
if !memsAvailable {
|
||||
return warnings, fmt.Errorf("requested memory nodes are not available - requested %s, available: %s", config.Resources.CpusetMems, sysInfo.Mems)
|
||||
return warnings, fmt.Errorf("requested memory nodes are not available - requested %s, available: %s", config.Resources.CPUsetMems, sysInfo.Mems)
|
||||
}
|
||||
|
||||
// blkio subsystem checks and adjustments
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *libpod.ContainerIn
|
|||
CPUQuota: quota,
|
||||
CPURealtimePeriod: realtimePeriod,
|
||||
CPURealtimeRuntime: realtimeRuntime,
|
||||
CPUSetCpus: cpus,
|
||||
CPUSetCPUs: cpus,
|
||||
CPUSetMems: mems,
|
||||
Devices: spec.Linux.Devices,
|
||||
KernelMemory: memKernel,
|
||||
|
|
@ -187,9 +187,9 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *libpod.ContainerIn
|
|||
AutoRemove: createArtifact.Rm,
|
||||
CapAdd: createArtifact.CapAdd,
|
||||
CapDrop: createArtifact.CapDrop,
|
||||
DNS: createArtifact.DnsServers,
|
||||
DNSOptions: createArtifact.DnsOpt,
|
||||
DNSSearch: createArtifact.DnsSearch,
|
||||
DNS: createArtifact.DNSServers,
|
||||
DNSOptions: createArtifact.DNSOpt,
|
||||
DNSSearch: createArtifact.DNSSearch,
|
||||
PidMode: string(createArtifact.PidMode),
|
||||
CgroupParent: createArtifact.CgroupParent,
|
||||
ShmSize: createArtifact.Resources.ShmSize,
|
||||
|
|
@ -312,7 +312,7 @@ type HostConfig struct {
|
|||
Isolation string `json:"Isolation"` //TODO
|
||||
CPUShares *uint64 `json:"CPUSShares"`
|
||||
Memory int64 `json:"Memory"`
|
||||
NanoCpus int `json:"NanoCpus"` //check type, TODO
|
||||
NanoCPUs int `json:"NanoCPUs"` //check type, TODO
|
||||
CgroupParent string `json:"CgroupParent"`
|
||||
BlkioWeight *uint16 `json:"BlkioWeight"`
|
||||
BlkioWeightDevice []specs.LinuxWeightDevice `json:"BlkioWeightDevice"`
|
||||
|
|
@ -324,7 +324,7 @@ type HostConfig struct {
|
|||
CPUQuota *int64 `json:"CPUQuota"`
|
||||
CPURealtimePeriod *uint64 `json:"CPURealtimePeriod"`
|
||||
CPURealtimeRuntime *int64 `json:"CPURealtimeRuntime"`
|
||||
CPUSetCpus string `json:"CPUSetCpus"`
|
||||
CPUSetCPUs string `json:"CPUSetCPUs"`
|
||||
CPUSetMems string `json:"CPUSetMems"`
|
||||
Devices []specs.LinuxDevice `json:"Devices"`
|
||||
DiskQuota int `json:"DiskQuota"` //check type, TODO
|
||||
|
|
|
|||
|
|
@ -557,17 +557,6 @@ func getStrFromSquareBrackets(cmd string) string {
|
|||
return strings.Join(arr, ",")
|
||||
}
|
||||
|
||||
// getImageName shortens the image name
|
||||
func getImageName(img string) string {
|
||||
arr := strings.Split(img, "/")
|
||||
if arr[0] == "docker.io" && arr[1] == "library" {
|
||||
img = strings.Join(arr[2:], "/")
|
||||
} else if arr[0] == "docker.io" {
|
||||
img = strings.Join(arr[1:], "/")
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
// getLabels converts the labels to a string of the form "key=value, key2=value2"
|
||||
func formatLabels(labels map[string]string) string {
|
||||
var arr []string
|
||||
|
|
@ -581,6 +570,7 @@ func formatLabels(labels map[string]string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
/*
|
||||
// getMounts converts the volumes mounted to a string of the form "mount1, mount2"
|
||||
// it truncates it if noTrunc is false
|
||||
func getMounts(mounts []specs.Mount, noTrunc bool) string {
|
||||
|
|
@ -602,7 +592,6 @@ func getMounts(mounts []specs.Mount, noTrunc bool) string {
|
|||
}
|
||||
return strings.Join(arr, ",")
|
||||
}
|
||||
|
||||
// getPorts converts the ports used to a string of the from "port1, port2"
|
||||
func getPorts(ports map[string]struct{}) string {
|
||||
var arr []string
|
||||
|
|
@ -614,71 +603,4 @@ func getPorts(ports map[string]struct{}) string {
|
|||
}
|
||||
return strings.Join(arr, ",")
|
||||
}
|
||||
|
||||
// FilterParamsPS contains the filter options for ps
|
||||
type FilterParamsPS struct {
|
||||
id string
|
||||
label string
|
||||
name string
|
||||
exited int32
|
||||
status string
|
||||
ancestor string
|
||||
before time.Time
|
||||
since time.Time
|
||||
volume string
|
||||
}
|
||||
|
||||
// parseFilter takes a filter string and a list of containers and filters it
|
||||
func parseFilter(filter string, containers []*libpod.Container) (*FilterParamsPS, error) {
|
||||
params := new(FilterParamsPS)
|
||||
allFilters := strings.Split(filter, ",")
|
||||
|
||||
for _, param := range allFilters {
|
||||
pair := strings.SplitN(param, "=", 2)
|
||||
switch strings.TrimSpace(pair[0]) {
|
||||
case "id":
|
||||
params.id = pair[1]
|
||||
case "label":
|
||||
params.label = pair[1]
|
||||
case "name":
|
||||
params.name = pair[1]
|
||||
case "exited":
|
||||
exitedCode, err := strconv.ParseInt(pair[1], 10, 32)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("exited code out of range %q", pair[1])
|
||||
}
|
||||
params.exited = int32(exitedCode)
|
||||
case "status":
|
||||
params.status = pair[1]
|
||||
case "ancestor":
|
||||
params.ancestor = pair[1]
|
||||
case "before":
|
||||
if ctr, err := findContainer(containers, pair[1]); err == nil {
|
||||
params.before = ctr.Config().CreatedTime
|
||||
} else {
|
||||
return nil, errors.Wrapf(err, "no such container %q", pair[1])
|
||||
}
|
||||
case "since":
|
||||
if ctr, err := findContainer(containers, pair[1]); err == nil {
|
||||
params.before = ctr.Config().CreatedTime
|
||||
} else {
|
||||
return nil, errors.Wrapf(err, "no such container %q", pair[1])
|
||||
}
|
||||
case "volume":
|
||||
params.volume = pair[1]
|
||||
default:
|
||||
return nil, errors.Errorf("invalid filter %q", pair[0])
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// findContainer finds a container with a specific name or id from a list of containers
|
||||
func findContainer(containers []*libpod.Container, ref string) (*libpod.Container, error) {
|
||||
for _, ctr := range containers {
|
||||
if strings.HasPrefix(ctr.ID(), ref) || ctr.Name() == ref {
|
||||
return ctr, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Errorf("could not find container")
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -211,26 +211,26 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
|
|||
|
||||
// RESOURCES - CPU
|
||||
|
||||
if config.Resources.CpuShares != 0 {
|
||||
g.SetLinuxResourcesCPUShares(config.Resources.CpuShares)
|
||||
if config.Resources.CPUShares != 0 {
|
||||
g.SetLinuxResourcesCPUShares(config.Resources.CPUShares)
|
||||
}
|
||||
if config.Resources.CpuQuota != 0 {
|
||||
g.SetLinuxResourcesCPUQuota(config.Resources.CpuQuota)
|
||||
if config.Resources.CPUQuota != 0 {
|
||||
g.SetLinuxResourcesCPUQuota(config.Resources.CPUQuota)
|
||||
}
|
||||
if config.Resources.CpuPeriod != 0 {
|
||||
g.SetLinuxResourcesCPUPeriod(config.Resources.CpuPeriod)
|
||||
if config.Resources.CPUPeriod != 0 {
|
||||
g.SetLinuxResourcesCPUPeriod(config.Resources.CPUPeriod)
|
||||
}
|
||||
if config.Resources.CpuRtRuntime != 0 {
|
||||
g.SetLinuxResourcesCPURealtimeRuntime(config.Resources.CpuRtRuntime)
|
||||
if config.Resources.CPURtRuntime != 0 {
|
||||
g.SetLinuxResourcesCPURealtimeRuntime(config.Resources.CPURtRuntime)
|
||||
}
|
||||
if config.Resources.CpuRtPeriod != 0 {
|
||||
g.SetLinuxResourcesCPURealtimePeriod(config.Resources.CpuRtPeriod)
|
||||
if config.Resources.CPURtPeriod != 0 {
|
||||
g.SetLinuxResourcesCPURealtimePeriod(config.Resources.CPURtPeriod)
|
||||
}
|
||||
if config.Resources.Cpus != "" {
|
||||
g.SetLinuxResourcesCPUCpus(config.Resources.Cpus)
|
||||
if config.Resources.CPUs != "" {
|
||||
g.SetLinuxResourcesCPUCpus(config.Resources.CPUs)
|
||||
}
|
||||
if config.Resources.CpusetMems != "" {
|
||||
g.SetLinuxResourcesCPUMems(config.Resources.CpusetMems)
|
||||
if config.Resources.CPUsetMems != "" {
|
||||
g.SetLinuxResourcesCPUMems(config.Resources.CPUsetMems)
|
||||
}
|
||||
|
||||
// SECURITY OPTS
|
||||
|
|
|
|||
|
|
@ -164,8 +164,8 @@ func psDataToPSParams(data []string, headers []string) ([]PSParams, error) {
|
|||
|
||||
//PSParams is a list of options that the command line ps recognizes
|
||||
type PSParams struct {
|
||||
CPU string `json: "%CPU"`
|
||||
MEM string `json: "%MEM"`
|
||||
CPU string
|
||||
MEM string
|
||||
COMMAND string
|
||||
BLOCKED string
|
||||
START string
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ const (
|
|||
cniConfigDir = "/etc/cni/net.d/"
|
||||
cniBinDir = "/usr/libexec/cni/"
|
||||
cgroupManager = "" //oci.CgroupfsCgroupsManager
|
||||
lockPath = "/run/crio.lock"
|
||||
containerExitsDir = "" //oci.ContainerExitsDir
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ type HookParams struct {
|
|||
HasBindMounts bool `json:"hasbindmounts"`
|
||||
}
|
||||
|
||||
/*
|
||||
// readHook reads hooks json files, verifies it and returns the json config
|
||||
func readHook(hookPath string) (HookParams, error) {
|
||||
var hook HookParams
|
||||
|
|
@ -96,3 +97,4 @@ func readHooks(hooksPath string, hooks map[string]HookParams) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue