diff --git a/apis/swagger.yml b/apis/swagger.yml index 651ccb9bac..a2ea6de30a 100644 --- a/apis/swagger.yml +++ b/apis/swagger.yml @@ -2237,19 +2237,17 @@ definitions: Resources: description: "A container's resources (cgroups config, ulimits, etc)" type: "object" + required: [CpuShares, Memory, CgroupParent, BlkioWeight, CpuPeriod, CpuQuota, CpuRealtimePeriod, + CpuRealtimeRuntime, CpusetCpus, CpusetMems, DeviceCgroupRules, KernelMemory, MemoryReservation, + MemorySwap, MemorySwappiness, NanoCPUs, OomKillDisable, PidsLimit, CpuCount, CpuPercent, + IOMaximumIOps, IOMaximumBandwidth, IntelRdtL3Cbm, ScheLatSwitch, MemoryWmarkRatio, MemoryExtra, + MemoryForceEmptyCtl] properties: - # Applicable to all platforms - CpuShares: - description: "An integer value representing this container's relative CPU weight versus other containers." - type: "integer" - Memory: - description: "Memory limit in bytes." - type: "integer" - default: 0 # Applicable to UNIX platforms CgroupParent: description: "Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist." type: "string" + x-nullable: false BlkioWeight: description: "Block IO weight (relative weight), need CFQ IO Scheduler enable." type: "integer" @@ -2287,6 +2285,10 @@ definitions: type: "array" items: $ref: "#/definitions/ThrottleDevice" + CpuShares: + description: "An integer value representing this container's relative CPU weight versus other containers." + type: "integer" + x-nullabel: false CpuPeriod: description: | CPU CFS (Completely Fair Scheduler) period. @@ -2295,6 +2297,7 @@ definitions: format: "int64" minimum: 1000 maximum: 1000000 + x-nullable: false CpuQuota: description: | CPU CFS (Completely Fair Scheduler) quota. @@ -2302,21 +2305,26 @@ definitions: type: "integer" format: "int64" minimum: 1000 + x-nullable: false CpuRealtimePeriod: description: "The length of a CPU real-time period in microseconds. Set to 0 to allocate no time allocated to real-time tasks." type: "integer" format: "int64" + x-nullable: false CpuRealtimeRuntime: description: "The length of a CPU real-time runtime in microseconds. Set to 0 to allocate no time allocated to real-time tasks." type: "integer" format: "int64" + x-nullable: false CpusetCpus: description: "CPUs in which to allow execution (e.g., `0-3`, `0,1`)" type: "string" example: "0-3" + x-nullable: false CpusetMems: description: "Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems." type: "string" + x-nullable: false Devices: description: "A list of devices to add to the container." type: "array" @@ -2332,14 +2340,21 @@ definitions: description: "Kernel memory limit in bytes." type: "integer" format: "int64" + Memory: + description: "Memory limit in bytes." + type: "integer" + default: 0 + x-nullable: false MemoryReservation: description: "Memory soft limit in bytes." type: "integer" format: "int64" + x-nullable: false MemorySwap: description: "Total memory limit (memory + swap). Set as `-1` to enable unlimited swap." type: "integer" format: "int64" + x-nullable: false MemorySwappiness: description: "Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100." type: "integer" @@ -2350,6 +2365,7 @@ definitions: description: "CPU quota in units of 10-9 CPUs." type: "integer" format: "int64" + x-nullable: false OomKillDisable: description: "Disable OOM Killer for the container." type: "boolean" @@ -2372,23 +2388,28 @@ definitions: On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is `CPUCount` first, then `CPUShares`, and `CPUPercent` last. type: "integer" format: "int64" + x-nullable: false CpuPercent: description: | The usable percentage of the available CPUs (Windows only). On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is `CPUCount` first, then `CPUShares`, and `CPUPercent` last. type: "integer" format: "int64" + x-nullable: false IOMaximumIOps: description: "Maximum IOps for the container system drive (Windows only)" type: "integer" format: "uint64" + x-nullable: false IOMaximumBandwidth: description: "Maximum IO in bytes per second for the container system drive (Windows only)" type: "integer" format: "uint64" + x-nullable: false IntelRdtL3Cbm: description: "IntelRdtL3Cbm specifies settings for Intel RDT/CAT group that the container is placed into to limit the resources (e.g., L3 cache) the container has available." type: "string" + x-nullable: false # applicable to AliKenerl 4.9 ScheLatSwitch: @@ -2398,6 +2419,7 @@ definitions: x-nullable: false minimum: 0 maximum: 1 + x-nullable: false MemoryWmarkRatio: description: | MemoryWmarkRatio is an integer value representing this container's memory low water mark percentage. diff --git a/apis/types/resources.go b/apis/types/resources.go index b608525346..6a38b0b1b0 100644 --- a/apis/types/resources.go +++ b/apis/types/resources.go @@ -37,120 +37,147 @@ type Resources struct { BlkioDeviceWriteIOps []*ThrottleDevice `json:"BlkioDeviceWriteIOps"` // Block IO weight (relative weight), need CFQ IO Scheduler enable. + // Required: true // Maximum: 1000 // Minimum: 0 - BlkioWeight uint16 `json:"BlkioWeight,omitempty"` + BlkioWeight uint16 `json:"BlkioWeight"` // Block IO weight (relative device weight) in the form `[{"Path": "device_path", "Weight": weight}]`. // BlkioWeightDevice []*WeightDevice `json:"BlkioWeightDevice"` // Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist. - CgroupParent string `json:"CgroupParent,omitempty"` + // Required: true + CgroupParent string `json:"CgroupParent"` // The number of usable CPUs (Windows only). // On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is `CPUCount` first, then `CPUShares`, and `CPUPercent` last. // - CPUCount int64 `json:"CpuCount,omitempty"` + // Required: true + CPUCount int64 `json:"CpuCount"` // The usable percentage of the available CPUs (Windows only). // On Windows Server containers, the processor resource controls are mutually exclusive. The order of precedence is `CPUCount` first, then `CPUShares`, and `CPUPercent` last. // - CPUPercent int64 `json:"CpuPercent,omitempty"` + // Required: true + CPUPercent int64 `json:"CpuPercent"` // CPU CFS (Completely Fair Scheduler) period. // The length of a CPU period in microseconds. // + // Required: true // Maximum: 1e+06 // Minimum: 1000 - CPUPeriod int64 `json:"CpuPeriod,omitempty"` + CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) quota. // Microseconds of CPU time that the container can get in a CPU period." // + // Required: true // Minimum: 1000 - CPUQuota int64 `json:"CpuQuota,omitempty"` + CPUQuota int64 `json:"CpuQuota"` // The length of a CPU real-time period in microseconds. Set to 0 to allocate no time allocated to real-time tasks. - CPURealtimePeriod int64 `json:"CpuRealtimePeriod,omitempty"` + // Required: true + CPURealtimePeriod int64 `json:"CpuRealtimePeriod"` // The length of a CPU real-time runtime in microseconds. Set to 0 to allocate no time allocated to real-time tasks. - CPURealtimeRuntime int64 `json:"CpuRealtimeRuntime,omitempty"` + // Required: true + CPURealtimeRuntime int64 `json:"CpuRealtimeRuntime"` // An integer value representing this container's relative CPU weight versus other containers. - CPUShares int64 `json:"CpuShares,omitempty"` + // Required: true + CPUShares *int64 `json:"CpuShares"` // CPUs in which to allow execution (e.g., `0-3`, `0,1`) - CpusetCpus string `json:"CpusetCpus,omitempty"` + // Required: true + CpusetCpus string `json:"CpusetCpus"` // Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. - CpusetMems string `json:"CpusetMems,omitempty"` + // Required: true + CpusetMems string `json:"CpusetMems"` // a list of cgroup rules to apply to the container + // Required: true DeviceCgroupRules []string `json:"DeviceCgroupRules"` // A list of devices to add to the container. Devices []*DeviceMapping `json:"Devices"` // Maximum IO in bytes per second for the container system drive (Windows only) - IOMaximumBandwidth uint64 `json:"IOMaximumBandwidth,omitempty"` + // Required: true + IOMaximumBandwidth uint64 `json:"IOMaximumBandwidth"` // Maximum IOps for the container system drive (Windows only) - IOMaximumIOps uint64 `json:"IOMaximumIOps,omitempty"` + // Required: true + IOMaximumIOps uint64 `json:"IOMaximumIOps"` // IntelRdtL3Cbm specifies settings for Intel RDT/CAT group that the container is placed into to limit the resources (e.g., L3 cache) the container has available. - IntelRdtL3Cbm string `json:"IntelRdtL3Cbm,omitempty"` + // Required: true + IntelRdtL3Cbm string `json:"IntelRdtL3Cbm"` // Kernel memory limit in bytes. - KernelMemory int64 `json:"KernelMemory,omitempty"` + // Required: true + KernelMemory *int64 `json:"KernelMemory"` // Memory limit in bytes. - Memory int64 `json:"Memory,omitempty"` + // Required: true + Memory int64 `json:"Memory"` // MemoryExtra is an integer value representing this container's memory high water mark percentage. // The range is in [0, 100]. // + // Required: true // Maximum: 100 // Minimum: 0 - MemoryExtra *int64 `json:"MemoryExtra,omitempty"` + MemoryExtra *int64 `json:"MemoryExtra"` // MemoryForceEmptyCtl represents whether to reclaim the page cache when deleting cgroup. + // Required: true // Maximum: 1 // Minimum: 0 - MemoryForceEmptyCtl int64 `json:"MemoryForceEmptyCtl,omitempty"` + MemoryForceEmptyCtl int64 `json:"MemoryForceEmptyCtl"` // Memory soft limit in bytes. - MemoryReservation int64 `json:"MemoryReservation,omitempty"` + // Required: true + MemoryReservation int64 `json:"MemoryReservation"` // Total memory limit (memory + swap). Set as `-1` to enable unlimited swap. - MemorySwap int64 `json:"MemorySwap,omitempty"` + // Required: true + MemorySwap int64 `json:"MemorySwap"` // Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. + // Required: true // Maximum: 100 // Minimum: -1 - MemorySwappiness *int64 `json:"MemorySwappiness,omitempty"` + MemorySwappiness *int64 `json:"MemorySwappiness"` // MemoryWmarkRatio is an integer value representing this container's memory low water mark percentage. // The value of memory low water mark is memory.limit_in_bytes * MemoryWmarkRatio. The range is in [0, 100]. // + // Required: true // Maximum: 100 // Minimum: 0 - MemoryWmarkRatio *int64 `json:"MemoryWmarkRatio,omitempty"` + MemoryWmarkRatio *int64 `json:"MemoryWmarkRatio"` // CPU quota in units of 10-9 CPUs. - NanoCpus int64 `json:"NanoCPUs,omitempty"` + // Required: true + NanoCpus int64 `json:"NanoCPUs"` // Disable OOM Killer for the container. - OomKillDisable *bool `json:"OomKillDisable,omitempty"` + // Required: true + OomKillDisable *bool `json:"OomKillDisable"` // Tune a container's pids limit. Set -1 for unlimited. Only on Linux 4.4 does this parameter support. // - PidsLimit int64 `json:"PidsLimit,omitempty"` + // Required: true + PidsLimit *int64 `json:"PidsLimit"` // ScheLatSwitch enables scheduler latency count in cpuacct + // Required: true // Maximum: 1 // Minimum: 0 - ScheLatSwitch int64 `json:"ScheLatSwitch,omitempty"` + ScheLatSwitch int64 `json:"ScheLatSwitch"` // A list of resource limits to set in the container. For example: `{"Name": "nofile", "Soft": 1024, "Hard": 2048}`" // @@ -259,6 +286,21 @@ func (m *Resources) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCgroupParent(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCPUCount(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCPUPercent(formats); err != nil { + // prop + res = append(res, err) + } + if err := m.validateCPUPeriod(formats); err != nil { // prop res = append(res, err) @@ -269,6 +311,31 @@ func (m *Resources) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateCPURealtimePeriod(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCPURealtimeRuntime(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCPUShares(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCpusetCpus(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateCpusetMems(formats); err != nil { + // prop + res = append(res, err) + } + if err := m.validateDeviceCgroupRules(formats); err != nil { // prop res = append(res, err) @@ -279,6 +346,31 @@ func (m *Resources) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIOMaximumBandwidth(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateIOMaximumIOps(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateIntelRdtL3Cbm(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateKernelMemory(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateMemory(formats); err != nil { + // prop + res = append(res, err) + } + if err := m.validateMemoryExtra(formats); err != nil { // prop res = append(res, err) @@ -289,6 +381,16 @@ func (m *Resources) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateMemoryReservation(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateMemorySwap(formats); err != nil { + // prop + res = append(res, err) + } + if err := m.validateMemorySwappiness(formats); err != nil { // prop res = append(res, err) @@ -299,6 +401,21 @@ func (m *Resources) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateNanoCpus(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validateOomKillDisable(formats); err != nil { + // prop + res = append(res, err) + } + + if err := m.validatePidsLimit(formats); err != nil { + // prop + res = append(res, err) + } + if err := m.validateScheLatSwitch(formats); err != nil { // prop res = append(res, err) @@ -425,8 +542,8 @@ func (m *Resources) validateBlkioDeviceWriteIOps(formats strfmt.Registry) error func (m *Resources) validateBlkioWeight(formats strfmt.Registry) error { - if swag.IsZero(m.BlkioWeight) { // not required - return nil + if err := validate.Required("BlkioWeight", "body", uint16(m.BlkioWeight)); err != nil { + return err } if err := validate.MinimumInt("BlkioWeight", "body", int64(m.BlkioWeight), 0, false); err != nil { @@ -467,10 +584,37 @@ func (m *Resources) validateBlkioWeightDevice(formats strfmt.Registry) error { return nil } +func (m *Resources) validateCgroupParent(formats strfmt.Registry) error { + + if err := validate.RequiredString("CgroupParent", "body", string(m.CgroupParent)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCPUCount(formats strfmt.Registry) error { + + if err := validate.Required("CpuCount", "body", int64(m.CPUCount)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCPUPercent(formats strfmt.Registry) error { + + if err := validate.Required("CpuPercent", "body", int64(m.CPUPercent)); err != nil { + return err + } + + return nil +} + func (m *Resources) validateCPUPeriod(formats strfmt.Registry) error { - if swag.IsZero(m.CPUPeriod) { // not required - return nil + if err := validate.Required("CpuPeriod", "body", int64(m.CPUPeriod)); err != nil { + return err } if err := validate.MinimumInt("CpuPeriod", "body", int64(m.CPUPeriod), 1000, false); err != nil { @@ -486,8 +630,8 @@ func (m *Resources) validateCPUPeriod(formats strfmt.Registry) error { func (m *Resources) validateCPUQuota(formats strfmt.Registry) error { - if swag.IsZero(m.CPUQuota) { // not required - return nil + if err := validate.Required("CpuQuota", "body", int64(m.CPUQuota)); err != nil { + return err } if err := validate.MinimumInt("CpuQuota", "body", int64(m.CPUQuota), 1000, false); err != nil { @@ -497,10 +641,55 @@ func (m *Resources) validateCPUQuota(formats strfmt.Registry) error { return nil } +func (m *Resources) validateCPURealtimePeriod(formats strfmt.Registry) error { + + if err := validate.Required("CpuRealtimePeriod", "body", int64(m.CPURealtimePeriod)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCPURealtimeRuntime(formats strfmt.Registry) error { + + if err := validate.Required("CpuRealtimeRuntime", "body", int64(m.CPURealtimeRuntime)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCPUShares(formats strfmt.Registry) error { + + if err := validate.Required("CpuShares", "body", m.CPUShares); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCpusetCpus(formats strfmt.Registry) error { + + if err := validate.RequiredString("CpusetCpus", "body", string(m.CpusetCpus)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateCpusetMems(formats strfmt.Registry) error { + + if err := validate.RequiredString("CpusetMems", "body", string(m.CpusetMems)); err != nil { + return err + } + + return nil +} + func (m *Resources) validateDeviceCgroupRules(formats strfmt.Registry) error { - if swag.IsZero(m.DeviceCgroupRules) { // not required - return nil + if err := validate.Required("DeviceCgroupRules", "body", m.DeviceCgroupRules); err != nil { + return err } return nil @@ -533,10 +722,55 @@ func (m *Resources) validateDevices(formats strfmt.Registry) error { return nil } +func (m *Resources) validateIOMaximumBandwidth(formats strfmt.Registry) error { + + if err := validate.Required("IOMaximumBandwidth", "body", uint64(m.IOMaximumBandwidth)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateIOMaximumIOps(formats strfmt.Registry) error { + + if err := validate.Required("IOMaximumIOps", "body", uint64(m.IOMaximumIOps)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateIntelRdtL3Cbm(formats strfmt.Registry) error { + + if err := validate.RequiredString("IntelRdtL3Cbm", "body", string(m.IntelRdtL3Cbm)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateKernelMemory(formats strfmt.Registry) error { + + if err := validate.Required("KernelMemory", "body", m.KernelMemory); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateMemory(formats strfmt.Registry) error { + + if err := validate.Required("Memory", "body", int64(m.Memory)); err != nil { + return err + } + + return nil +} + func (m *Resources) validateMemoryExtra(formats strfmt.Registry) error { - if swag.IsZero(m.MemoryExtra) { // not required - return nil + if err := validate.Required("MemoryExtra", "body", m.MemoryExtra); err != nil { + return err } if err := validate.MinimumInt("MemoryExtra", "body", int64(*m.MemoryExtra), 0, false); err != nil { @@ -552,8 +786,8 @@ func (m *Resources) validateMemoryExtra(formats strfmt.Registry) error { func (m *Resources) validateMemoryForceEmptyCtl(formats strfmt.Registry) error { - if swag.IsZero(m.MemoryForceEmptyCtl) { // not required - return nil + if err := validate.Required("MemoryForceEmptyCtl", "body", int64(m.MemoryForceEmptyCtl)); err != nil { + return err } if err := validate.MinimumInt("MemoryForceEmptyCtl", "body", int64(m.MemoryForceEmptyCtl), 0, false); err != nil { @@ -567,10 +801,28 @@ func (m *Resources) validateMemoryForceEmptyCtl(formats strfmt.Registry) error { return nil } +func (m *Resources) validateMemoryReservation(formats strfmt.Registry) error { + + if err := validate.Required("MemoryReservation", "body", int64(m.MemoryReservation)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateMemorySwap(formats strfmt.Registry) error { + + if err := validate.Required("MemorySwap", "body", int64(m.MemorySwap)); err != nil { + return err + } + + return nil +} + func (m *Resources) validateMemorySwappiness(formats strfmt.Registry) error { - if swag.IsZero(m.MemorySwappiness) { // not required - return nil + if err := validate.Required("MemorySwappiness", "body", m.MemorySwappiness); err != nil { + return err } if err := validate.MinimumInt("MemorySwappiness", "body", int64(*m.MemorySwappiness), -1, false); err != nil { @@ -586,8 +838,8 @@ func (m *Resources) validateMemorySwappiness(formats strfmt.Registry) error { func (m *Resources) validateMemoryWmarkRatio(formats strfmt.Registry) error { - if swag.IsZero(m.MemoryWmarkRatio) { // not required - return nil + if err := validate.Required("MemoryWmarkRatio", "body", m.MemoryWmarkRatio); err != nil { + return err } if err := validate.MinimumInt("MemoryWmarkRatio", "body", int64(*m.MemoryWmarkRatio), 0, false); err != nil { @@ -601,10 +853,37 @@ func (m *Resources) validateMemoryWmarkRatio(formats strfmt.Registry) error { return nil } +func (m *Resources) validateNanoCpus(formats strfmt.Registry) error { + + if err := validate.Required("NanoCPUs", "body", int64(m.NanoCpus)); err != nil { + return err + } + + return nil +} + +func (m *Resources) validateOomKillDisable(formats strfmt.Registry) error { + + if err := validate.Required("OomKillDisable", "body", m.OomKillDisable); err != nil { + return err + } + + return nil +} + +func (m *Resources) validatePidsLimit(formats strfmt.Registry) error { + + if err := validate.Required("PidsLimit", "body", m.PidsLimit); err != nil { + return err + } + + return nil +} + func (m *Resources) validateScheLatSwitch(formats strfmt.Registry) error { - if swag.IsZero(m.ScheLatSwitch) { // not required - return nil + if err := validate.Required("ScheLatSwitch", "body", int64(m.ScheLatSwitch)); err != nil { + return err } if err := validate.MinimumInt("ScheLatSwitch", "body", int64(m.ScheLatSwitch), 0, false); err != nil {