Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Add case for docker-pullable (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 authored Feb 3, 2022
1 parent 2165d05 commit 816ca25
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,14 @@ func NewGenericTesterAndValidate(templateFile, schemaPath string, values map[str
return tester, handlers
}

// RunCommandInContainerNameSpace run a host command in a running container with the nsenter command.
// takes the container nodeName, node Oc and container UID
// returns the raw output of the command
func RunCommandInContainerNameSpace(nodeName string, nodeOc *interactive.Oc, containerID, command string, timeout time.Duration, runtime string) string {
containrPID := GetContainerPID(nodeName, nodeOc, containerID, runtime)
nodeCommand := "nsenter -t " + containrPID + " -n " + command
return RunCommandInNode(nodeName, nodeOc, nodeCommand, timeout)
}

// GetContainerPID gets the container PID from a kubernetes node, Oc and container PID
func GetContainerPID(nodeName string, nodeOc *interactive.Oc, containerID, runtime string) string {
command := ""
switch runtime {
case "docker": //nolint:goconst // used only once
command = "chroot /host docker inspect -f '{{.State.Pid}}' " + containerID + " 2>/dev/null"
case "docker-pullable": //nolint:goconst // used only once
command = "chroot /host docker inspect -f '{{.State.Pid}}' " + containerID + " 2>/dev/null"
case "cri-o": //nolint:goconst // used only once
command = "chroot /host crictl inspect --output go-template --template '{{.info.pid}}' " + containerID + " 2>/dev/null"
default:
Expand Down

0 comments on commit 816ca25

Please sign in to comment.