Test pod sandbox resource updates persist across containerd restarts.
(t *testing.T)
| 574 | |
| 575 | // Test pod sandbox resource updates persist across containerd restarts. |
| 576 | func TestUpdatePodSandboxWithRestart(t *testing.T) { |
| 577 | skipNriTestIfNecessary(t) |
| 578 | |
| 579 | t.Log("Test that pod sandbox resource updates persist across containerd restarts.") |
| 580 | |
| 581 | tc := &nriTest{ |
| 582 | t: t, |
| 583 | } |
| 584 | tc.setup() |
| 585 | |
| 586 | podID := tc.runPod("pod0") |
| 587 | _ = tc.startContainer(podID, "ctr0") |
| 588 | |
| 589 | overhead := &runtime.LinuxContainerResources{MemoryLimitInBytes: 10} |
| 590 | res := &runtime.LinuxContainerResources{MemoryLimitInBytes: 5} |
| 591 | err := tc.runtime.UpdatePodSandboxResources(podID, overhead, res) |
| 592 | assert.NoError(tc.t, err, "update pod sandbox") |
| 593 | |
| 594 | t.Logf("Verify sandbox resources are updated before restart") |
| 595 | _, info, err := SandboxInfo(podID) |
| 596 | require.NoError(t, err) |
| 597 | require.NotNil(t, info.Resources) |
| 598 | require.NotNil(t, info.Overhead) |
| 599 | assert.Equal(t, res.MemoryLimitInBytes, info.Resources.GetLinux().GetMemoryLimitInBytes()) |
| 600 | assert.Equal(t, overhead.MemoryLimitInBytes, info.Overhead.GetLinux().GetMemoryLimitInBytes()) |
| 601 | |
| 602 | t.Logf("Restart containerd") |
| 603 | RestartContainerd(t, syscall.SIGTERM) |
| 604 | |
| 605 | t.Logf("Verify sandbox resources are still updated after restart") |
| 606 | _, info, err = SandboxInfo(podID) |
| 607 | require.NoError(t, err) |
| 608 | require.NotNil(t, info.Resources) |
| 609 | require.NotNil(t, info.Overhead) |
| 610 | assert.Equal(t, res.MemoryLimitInBytes, info.Resources.GetLinux().GetMemoryLimitInBytes()) |
| 611 | assert.Equal(t, overhead.MemoryLimitInBytes, info.Overhead.GetLinux().GetMemoryLimitInBytes()) |
| 612 | } |
| 613 | |
| 614 | // Test NRI vs. containerd restart. |
| 615 | func TestNriPluginContainerdRestart(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…