Class ContainerLimits
Used by same Docker related (and derived) fixtures to limit the machine resources that can be consumed by managed containers. We support many of the limits described in detail bere:
https://docs.docker.com/config/containers/resource_constraints/
note
Byte size properties like Memory are strings including the
size (a double
) along with an optional unit designation from
ByteUnits like KiB, MiB, and GiB rather
than using the Docker unit conventions for consistency with NEONKUBE
cluster definitions, etc. These values will be converted to a simple
byte count before passing them on to Docker.
note
We're currently implementing some memory limits along with one CPU limit.
Namespace: Neon.Xunit
Assembly: Neon.Xunit.dll
Syntax
public class ContainerLimits
Properties
KernelMemory
The minimum amount of kernel memory the container can use. Setting this can prevent the container from obtaining so much kernel memory that other machine level components are impacted. The minimum value is 4MiB and the default is unconstrained. See the Docker documentation for more details on how this works:
https://docs.docker.com/config/containers/resource_constraints/#--kernel-memory-details
Declaration
public string KernelMemory { get; set; }
Property Value
Type | Description |
---|---|
string |
Memory
Optionally specifies the maximum memory that can be allocated to the container. The minimum value is 4MiB. The default value is unconstrained.
Declaration
public string Memory { get; set; }
Property Value
Type | Description |
---|---|
string |
MemoryReservation
Specifies a lower soft limit on memory than Memory when Docker detects contention or low memory on the host. Memory must also be set and MemoryReservation must be less than that for this to have any effect.
note
Because it is a soft limit, it does not guarantee that the container doesn’t exceed this value.
Declaration
public string MemoryReservation { get; set; }
Property Value
Type | Description |
---|---|
string |
MemorySwap
The amount of memory the container is allowed to swap to disk. This required Memory to be also set to have any effect. See the Docker documentation for more details on how this works:
https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details
Declaration
public string MemorySwap { get; set; }
Property Value
Type | Description |
---|---|
string |
MemorySwappiness
The percentage of anonymous memory pages used by the container that may be swapped to disk. This is an integer number between 0..100. See the Docker documentation for more details on how this works:
https://docs.docker.com/config/containers/resource_constraints/#--memory-swappiness-details
Declaration
public int? MemorySwappiness { get; set; }
Property Value
Type | Description |
---|---|
int? |
OomKillDisable
By default, the host machine's OOM killer will kill processes in a container
when the host runs out of memory (OOM). You can disable this behavior by setting
this to true
. This defaults to false
.
note
**WARNING:** You should also set Memory when enabling this to help prevent the OOM killer from killing important host level processes.
Validate() will check for this condition.
Declaration
public bool OomKillDisable { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
Validate()
Verifies that the limit properties make sense.
Declaration
public string Validate()
Returns
Type | Description |
---|---|
string |
|