Skip to content

Commit

Permalink
docker: add ownership regression test
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Oct 9, 2023
1 parent fbb5dee commit 2e2f2d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions kola/tests/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ func dockerBaseTests(c cluster.TestCluster) {
c.Run("resources", dockerResources)
c.Run("networks-reliably", dockerNetworksReliably)
c.Run("user-no-caps", dockerUserNoCaps)
// This prevents regression like: https://github.com/flatcar/Flatcar/issues/1203
c.Run("ownership", dockerOwnership)
}

// using a simple container, exercise various docker options that set resource
Expand Down Expand Up @@ -708,3 +710,18 @@ docker run -v "/etc/misc:/opt" --rm ghcr.io/flatcar/busybox true`
c.Fatal("/etc/misc/hello should holds 'world'")
}
}

// Reported by a user: a regression on stable
// that causes ownernship being lost when exporting a Docker
// container.
// https://github.com/flatcar/Flatcar/issues/1203
func dockerOwnership(c cluster.TestCluster) {
m := c.Machines()[0]

runOwnership := c.MustSSH(m, `docker run --name ownership ghcr.io/flatcar/nginx stat -c "%u/%g" /etc/shadow`)
exportOwnership := c.MustSSH(m, `docker export ownership | tar tv etc/shadow | awk '{print $2}'`)

if string(runOwnership) != string(exportOwnership) {
c.Fatalf("ownership should be conserved between run and export of Docker containers. Got: %s and %s", runOwnership, exportOwnership)
}
}

0 comments on commit 2e2f2d7

Please sign in to comment.