Merge pull request #7783 from inspektor-gadget/qasim/cri-disable-swap
cri: make swapping disabled with memory limit
This commit is contained in:
@@ -448,6 +448,10 @@ func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHu
|
||||
}
|
||||
if limit != 0 {
|
||||
s.Linux.Resources.Memory.Limit = &limit
|
||||
// swap/memory limit should be equal to prevent container from swapping by default
|
||||
if swapLimit == 0 {
|
||||
s.Linux.Resources.Memory.Swap = &limit
|
||||
}
|
||||
}
|
||||
if swapLimit != 0 {
|
||||
s.Linux.Resources.Memory.Swap = &swapLimit
|
||||
|
||||
@@ -70,7 +70,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -113,7 +116,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -151,7 +157,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -197,7 +206,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
|
||||
@@ -70,7 +70,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -113,7 +116,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -151,7 +157,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
@@ -197,7 +206,10 @@ func TestUpdateOCILinuxResource(t *testing.T) {
|
||||
Process: &runtimespec.Process{OOMScoreAdj: oomscoreadj},
|
||||
Linux: &runtimespec.Linux{
|
||||
Resources: &runtimespec.LinuxResources{
|
||||
Memory: &runtimespec.LinuxMemory{Limit: proto.Int64(54321)},
|
||||
Memory: &runtimespec.LinuxMemory{
|
||||
Limit: proto.Int64(54321),
|
||||
Swap: proto.Int64(54321),
|
||||
},
|
||||
CPU: &runtimespec.LinuxCPU{
|
||||
Shares: proto.Uint64(4444),
|
||||
Quota: proto.Int64(5555),
|
||||
|
||||
Reference in New Issue
Block a user