mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Fix panic in pkg/volume/csi tests
When run as non-root user, TestAttacherMountDevice fails, because of missing nil check that induces a panic. Fixed by doing err nil check before using the returned user value from user.Current()
This commit is contained in:
parent
0ae157df39
commit
1e250610b2
@ -1187,10 +1187,14 @@ func TestAttacherMountDevice(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
user, _ := user.Current()
|
||||
user, err := user.Current()
|
||||
if err != nil {
|
||||
t.Logf("Current user could not be determined, assuming non-root: %v", err)
|
||||
} else {
|
||||
if tc.populateDeviceMountPath && user.Uid == "0" {
|
||||
t.Skipf("Skipping intentional failure on existing data when running as root.")
|
||||
}
|
||||
}
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
t.Logf("Running test case: %s", tc.testName)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user