kubelet/userns: Remove tests that fail as root

For some reason the CI didn't fail when we open the PR. But when you run
"go test" as root, with all the capabilities, tests that exercise
permission errors will never work. As the capabilities makes them always
bypass the permission checks.

For some reason it seems that:
 * Not all our CI was run when the PR was open
 * The CI was changed to run as root now
 * _Some_ CI was added and it runs as root

If it wasn't one of that, or a combination, I don't see how this could
have happened. If any of that indeed happened, it can break more tests
outside the userns package too.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
This commit is contained in:
Rodrigo Campos 2024-02-19 14:44:34 -03:00
parent 3516bc6f49
commit 5a8579a3e4

View File

@ -378,21 +378,3 @@ func TestMakeUserNsManagerFailsListPod(t *testing.T) {
assert.Error(t, err)
assert.ErrorContains(t, err, "read pods from disk")
}
func TestMakeUserNsManagerFailsPodRecord(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.UserNamespacesSupport, true)()
testUserNsPodsManager := &testUserNsPodsManager{
podList: []types.UID{"pod-1", "pod-2"},
podDir: t.TempDir(),
}
// Remove read/execute permissions from this directory.
if err := os.Chmod(testUserNsPodsManager.podDir, 0222); err != nil {
t.Fatal(err)
}
_, err := MakeUserNsManager(testUserNsPodsManager)
assert.Error(t, err)
assert.ErrorContains(t, err, "record pod mappings")
}