Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: add ownership regression test #462

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a large fan of regression tests for mainly upstream issues, specially when they are so specific that they probably won't happen exactly this way again but different. Anyway, if this function won't take long to execute it's ok to have it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point. By doing this we can prevent this regression again (even if there is a small probability that it occurs again as you said) but we can also catch other issues caused by this scenario.
The test only runs on qemu as part of the docker base tests, the only "long" action is the pulling of the nginx image, the rest is super fast.

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)
}
}