Skip to content

Commit b536c38

Browse files
committed
id errors 6
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 7f18572 commit b536c38

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

cmd/nerdctl/container/container_inspect_linux_test.go

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ func TestContainerInspectContainsMounts(t *testing.T) {
6767
testutil.NginxAlpineImage).AssertOK()
6868

6969
inspect := base.InspectContainer(testContainer)
70-
t.Logf("inspect in TestContainerInspectContainsMounts: %+v", inspect)
71-
t.Logf("inspect.Mounts in TestContainerInspectContainsMounts: %+v", inspect.Mounts)
7270
// convert array to map to get by key of Destination
7371
actual := make(map[string]dockercompat.MountPoint)
7472
for i := range inspect.Mounts {
@@ -119,19 +117,6 @@ func TestContainerInspectContainsMounts(t *testing.T) {
119117
RW: true,
120118
},
121119
},
122-
123-
// Tmpfs
124-
{
125-
dest: "/app1",
126-
mountPoint: dockercompat.MountPoint{
127-
Type: "tmpfs",
128-
Name: "",
129-
Source: "tmpfs",
130-
Destination: "/app1",
131-
Mode: "noexec,nosuid,nodev,size=64m",
132-
RW: true,
133-
},
134-
},
135120
}
136121

137122
for i := range expected {
@@ -431,3 +416,52 @@ func TestContainerInspectHostConfigPIDDefaults(t *testing.T) {
431416
// assert.DeepEqual(t, expectedSysctls, inspect.HostConfig.Sysctls)
432417
// expectedDevices := []string{"/dev/null:/dev/null"}
433418
// assert.DeepEqual(t, expectedDevices, inspect.HostConfig.Devices)
419+
420+
// func TestContainerInspectHostConfigAdvanced(t *testing.T) {
421+
// testContainer := testutil.Identifier(t)
422+
423+
// base := testutil.NewBase(t)
424+
// defer base.Cmd("rm", "-f", testContainer).Run()
425+
426+
// // Run a container with various advanced HostConfig options
427+
// base.Cmd("run", "-d", "--name", testContainer,
428+
// "--read-only",
429+
// "--uts", "host",
430+
// "--shm-size", "256m",
431+
// "--runtime", "io.containerd.runtime.v1.linux",
432+
// "--sysctl", "net.core.somaxconn=1024",
433+
// "--device", "/dev/null:/dev/null",
434+
// testutil.AlpineImage, "sleep", "infinity").AssertOK()
435+
436+
// inspect := base.InspectContainer(testContainer)
437+
438+
// // Check ReadonlyRootfs
439+
// assert.Equal(t, true, inspect.HostConfig.ReadonlyRootfs)
440+
441+
// // Check UTSMode
442+
// assert.Equal(t, "host", inspect.HostConfig.UTSMode)
443+
444+
// // Check ShmSize
445+
// assert.Equal(t, int64(268435456), inspect.HostConfig.ShmSize)
446+
447+
// // Check Runtime
448+
// assert.Equal(t, "io.containerd.runtime.v1.linux", inspect.HostConfig.Runtime)
449+
450+
// // Check Sysctls
451+
// expectedSysctls := map[string]string{
452+
// "net.core.somaxconn": "1024",
453+
// }
454+
// assert.DeepEqual(t, expectedSysctls, inspect.HostConfig.Sysctls)
455+
456+
// // Check Devices
457+
// expectedDevices := []string{"/dev/null:/dev/null"}
458+
// assert.DeepEqual(t, expectedDevices, inspect.HostConfig.Devices)
459+
460+
// // Log the entire HostConfig for debugging
461+
// hostConfigJSON, err := json.MarshalIndent(inspect.HostConfig, "", " ")
462+
// if err != nil {
463+
// t.Errorf("Failed to marshal HostConfig: %v", err)
464+
// } else {
465+
// t.Logf("HostConfig in TestContainerInspectHostConfigAdvanced:\n%s", string(hostConfigJSON))
466+
// }
467+
// }

pkg/inspecttypes/dockercompat/dockercompat.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,13 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
344344
}
345345
c.Mounts = mounts
346346
if len(mounts) > 0 {
347-
tmpfsMounts = filterTmpfsMounts(mounts)
347+
tmpfsMounts = mounts
348+
// filterTmpfsMounts(mounts)
348349
}
349350
}
351+
// if len(tmpfsMounts) > 0 {
350352
c.HostConfig.Tmpfs = tmpfsMounts
353+
// }
351354

352355
if nedctlExtraHosts := n.Labels[labels.ExtraHosts]; nedctlExtraHosts != "" {
353356
c.HostConfig.ExtraHosts = parseExtraHosts(nedctlExtraHosts)

pkg/inspecttypes/dockercompat/dockercompat_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestContainerFromNative(t *testing.T) {
8383
Opts: map[string]string{},
8484
},
8585
UTSMode: "host",
86-
Tmpfs: []MountPoint{},
8786
},
8887
Mounts: []MountPoint{
8988
{

pkg/testutil/testutil.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ func (b *Base) InspectContainer(name string) dockercompat.Container {
216216
cmdResult := b.Cmd("container", "inspect", name).Run()
217217
assert.Equal(b.T, cmdResult.ExitCode, 0)
218218
var dc []dockercompat.Container
219+
b.T.Log("==========")
220+
b.T.Log(cmdResult.Stdout())
221+
b.T.Log("==========")
219222
if err := json.Unmarshal([]byte(cmdResult.Stdout()), &dc); err != nil {
220223
b.T.Fatal(err)
221224
}

0 commit comments

Comments
 (0)