Skip to content

Commit a1a2f8c

Browse files
authored
Merge pull request kubernetes#93225 from hasheddan/storage-panic
Return error instead of panic if container index outside bounds
2 parents b6174e6 + 4e4d629 commit a1a2f8c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test/e2e/storage/testsuites/subpath.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,9 @@ func formatVolume(f *framework.Framework, pod *v1.Pod) {
10591059
}
10601060

10611061
func podContainerExec(pod *v1.Pod, containerIndex int, command string) (string, error) {
1062+
if containerIndex > len(pod.Spec.Containers)-1 {
1063+
return "", fmt.Errorf("container not found in pod: index %d", containerIndex)
1064+
}
10621065
var shell string
10631066
var option string
10641067
if framework.NodeOSDistroIs("windows") {

0 commit comments

Comments
 (0)