@@ -32,7 +32,9 @@ import (
3232 // Register the typeurl
3333 "github.com/containerd/containerd/cio"
3434 "github.com/containerd/containerd/containers"
35+ "github.com/containerd/containerd/namespaces"
3536 "github.com/containerd/containerd/oci"
37+ "github.com/containerd/containerd/platforms"
3638 _ "github.com/containerd/containerd/runtime"
3739 "github.com/containerd/typeurl"
3840 specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -1528,3 +1530,59 @@ func TestContainerHook(t *testing.T) {
15281530 }
15291531 defer task .Delete (ctx , WithProcessKill )
15301532}
1533+
1534+ func TestShimSockLength (t * testing.T ) {
1535+ t .Parallel ()
1536+
1537+ // Max length of namespace should be 76
1538+ namespace := strings .Repeat ("n" , 76 )
1539+
1540+ ctx , cancel := context .WithCancel (context .Background ())
1541+ defer cancel ()
1542+
1543+ ctx = namespaces .WithNamespace (ctx , namespace )
1544+
1545+ client , err := newClient (t , address )
1546+ if err != nil {
1547+ t .Fatal (err )
1548+ }
1549+ defer client .Close ()
1550+
1551+ image , err := client .Pull (ctx , testImage ,
1552+ WithPlatformMatcher (platforms .Default ()),
1553+ WithPullUnpack ,
1554+ )
1555+ if err != nil {
1556+ t .Fatal (err )
1557+ }
1558+
1559+ id := strings .Repeat ("c" , 64 )
1560+
1561+ // We don't have limitation with length of container name,
1562+ // but 64 bytes of sha256 is the common case
1563+ container , err := client .NewContainer (ctx , id ,
1564+ WithNewSnapshot (id , image ),
1565+ WithNewSpec (oci .WithImageConfig (image ), withExitStatus (0 )),
1566+ )
1567+ if err != nil {
1568+ t .Fatal (err )
1569+ }
1570+ defer container .Delete (ctx , WithSnapshotCleanup )
1571+
1572+ task , err := container .NewTask (ctx , empty ())
1573+ if err != nil {
1574+ t .Fatal (err )
1575+ }
1576+ defer task .Delete (ctx )
1577+
1578+ statusC , err := task .Wait (ctx )
1579+ if err != nil {
1580+ t .Fatal (err )
1581+ }
1582+
1583+ if err := task .Start (ctx ); err != nil {
1584+ t .Fatal (err )
1585+ }
1586+
1587+ <- statusC
1588+ }
0 commit comments