addres review comments

pull/7862/head
Medya Gh 2020-04-24 14:07:54 -07:00
parent 51655af562
commit 63f9bfbb61
No known key found for this signature in database
GPG Key ID: 7CF7792C6DF3245C
4 changed files with 8 additions and 8 deletions

View File

@ -99,7 +99,7 @@ func (d *Driver) Create() error {
},
)
exists, err := oci.ContainerExists(d.OCIBinary, params.Name)
exists, err := oci.ContainerExists(d.OCIBinary, params.Name, true)
if err != nil {
glog.Warningf("failed to check if container already exists: %v", err)
}
@ -234,7 +234,7 @@ func (d *Driver) GetURL() (string, error) {
// GetState returns the state that the host is in (running, stopped, etc)
func (d *Driver) GetState() (state.State, error) {
return oci.ContainerStatus(d.OCIBinary, d.MachineName)
return oci.ContainerStatus(d.OCIBinary, d.MachineName, true)
}
// Kill stops a host forcefully, including any containers that we are managing.

View File

@ -232,7 +232,7 @@ func ContainerID(ociBin string, nameOrID string) (string, error) {
// ContainerExists checks if container name exists (either running or exited)
func ContainerExists(ociBin string, name string, warnSlow ...bool) (bool, error) {
rr, err := runCmd(exec.Command(ociBin, "ps", "-a", "--format", "{{.Names}}"), true)
rr, err := runCmd(exec.Command(ociBin, "ps", "-a", "--format", "{{.Names}}"), warnSlow...)
if err != nil {
return false, err
}
@ -395,7 +395,7 @@ func withPortMappings(portMappings []PortMapping) createOpt {
// ListContainersByLabel returns all the container names with a specified label
func ListContainersByLabel(ociBin string, label string, warnSlow ...bool) ([]string, error) {
rr, err := runCmd(exec.Command(ociBin, "ps", "-a", "--filter", fmt.Sprintf("label=%s", label), "--format", "{{.Names}}"), true)
rr, err := runCmd(exec.Command(ociBin, "ps", "-a", "--filter", fmt.Sprintf("label=%s", label), "--format", "{{.Names}}"), warnSlow...)
if err != nil {
return nil, err
}
@ -432,7 +432,7 @@ func PointToHostDockerDaemon() error {
// ContainerStatus returns status of a container running,exited,...
func ContainerStatus(ociBin string, name string, warnSlow ...bool) (state.State, error) {
cmd := exec.Command(ociBin, "inspect", name, "--format={{.State.Status}}")
rr, err := runCmd(cmd, true)
rr, err := runCmd(cmd, warnSlow...)
o := strings.TrimSpace(rr.Stdout.String())
switch o {
case "running":

View File

@ -40,7 +40,7 @@ func DeleteAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []er
}
for _, v := range vs {
if _, err := runCmd(exec.Command(ociBin, "volume", "rm", "--force", v), true); err != nil {
if _, err := runCmd(exec.Command(ociBin, "volume", "rm", "--force", v), warnSlow...); err != nil {
deleteErrs = append(deleteErrs, fmt.Errorf("deleting %q", v))
}
}
@ -55,7 +55,7 @@ func PruneAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []err
var deleteErrs []error
glog.Infof("trying to prune all %s volumes with label %s", ociBin, label)
cmd := exec.Command(ociBin, "volume", "prune", "-f", "--filter", "label="+label)
if _, err := runCmd(cmd, true); err != nil {
if _, err := runCmd(cmd, warnSlow...); err != nil {
deleteErrs = append(deleteErrs, errors.Wrapf(err, "prune volume by label %s", label))
}

View File

@ -42,7 +42,7 @@ func deleteOrphanedKIC(ociBin string, name string) {
_, err := oci.ContainerStatus(ociBin, name)
if err != nil {
glog.Infof("couldn't inspect container %q before deleting, %s-daemon might needs a restart!: %v", name, ociBin, err)
glog.Infof("couldn't inspect container %q before deleting: %v", name, err)
return
}
// allow no more than 5 seconds for delting the container