Skip to content

number of loop devices is fixed and unpredictable #1248

@pohly

Description

@pohly

What happened:

Block device tests running inside the KinD cluster are flaky (kubernetes-csi/csi-driver-host-path#119). It looks like this is because the Docker container in which kubelet runs has a static copy of the host's /dev. In devfs, new loop devices are added by the kernel as needed. But inside the container only those /dev/loop* devices are available which existed already on the host when the container was created, causing losetup to fail:

losetup: /tmp/testfile: failed to set up loop device: No such file or directory

What you expected to happen:

/dev needs to be shared with the host. This isn't nice from a security perspective, but I don't see another solution.

How to reproduce it (as minimally and precisely as possible):

Create a KinD cluster, pick one container with docker ps, then run losetup repeatedly:

$ docker exec f049e80f378a sh -c 'ls /dev/loop*'
/dev/loop-control
/dev/loop0
/dev/loop1
/dev/loop2
/dev/loop3
/dev/loop4
/dev/loop5
/dev/loop6
/dev/loop7
$ docker exec f049e80f378a sh -c 'truncate -s 1G /tmp/testfile; losetup -f --show /tmp/testfile'
/dev/loop0
....
$ docker exec f049e80f378a sh -c 'truncate -s 1G /tmp/testfile; losetup -f --show /tmp/testfile'
/dev/loop7
$ docker exec f049e80f378a sh -c 'truncate -s 1G /tmp/testfile; losetup -f --show /tmp/testfile'
losetup: /tmp/testfile: failed to set up loop device: No such file or directory

Environment:

  • kind version: (use kind version): v0.6.0-alpha

Metadata

Metadata

Labels

kind/bugCategorizes issue or PR as related to a bug.lifecycle/activeIndicates that an issue or PR is actively being worked on by a contributor.priority/critical-urgentHighest priority. Must be actively worked on as someone's top priority right now.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions