From 2e2f2d7aebb271009e0eae6443f226112d63c2bb Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Mon, 9 Oct 2023 19:59:39 +0200 Subject: [PATCH] docker: add ownership regression test Signed-off-by: Mathieu Tortuyaux --- kola/tests/docker/docker.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kola/tests/docker/docker.go b/kola/tests/docker/docker.go index 66d3c9e6b..254fffbbb 100644 --- a/kola/tests/docker/docker.go +++ b/kola/tests/docker/docker.go @@ -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 @@ -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) + } +}