MCPcopy
hub / github.com/cubefs/cubefs / checkContainerExistence

Function checkContainerExistence

deploy/cmd/docker.go:86–98  ·  view source on GitHub ↗
(nodeUser, node, containerName string)

Source from the content-addressed store, hash-verified

84}
85
86func checkContainerExistence(nodeUser, node, containerName string) (bool, error) {
87 cmd := exec.Command("ssh", nodeUser+"@"+node, "docker ps -a --format "+`{{.Names}}`+" | grep "+`"`+containerName+`"`)
88 output, err := cmd.Output()
89 if err != nil {
90 return false, err
91 }
92 for _, name := range strings.Fields(string(output)) {
93 if name == containerName {
94 return true, nil
95 }
96 }
97 return false, nil
98}
99
100func checkAndDeleteContainerOnNode(nodeUser, node, containerName string) error {
101 if ok, _ := checkContainerExistence(nodeUser, node, containerName); ok {

Callers 3

stopContainerOnNodeFunction · 0.85
rmContainerOnNodeFunction · 0.85

Calls 1

OutputMethod · 0.65

Tested by

no test coverage detected