Skip deleting leftovers if bin not available

Avoids spamming the log with extra drivers
pull/7959/head
Anders F Björklund 2020-05-09 13:47:45 +02:00
parent c1be17346b
commit 9673b421df
1 changed files with 8 additions and 2 deletions

View File

@ -168,6 +168,7 @@ func runDelete(cmd *cobra.Command, args []string) {
if orphan {
// TODO: generalize for non-KIC drivers: #8040
deletePossibleKicLeftOver(cname, driver.Docker)
deletePossibleKicLeftOver(cname, driver.Podman)
}
}
@ -210,8 +211,6 @@ func DeleteProfiles(profiles []*config.Profile) []error {
// TODO: remove and/or move to delete package: #8040
func deletePossibleKicLeftOver(cname string, driverName string) {
glog.Infof("deleting possible KIC leftovers for %s (driver=%s) ...", cname, driverName)
bin := ""
switch driverName {
case driver.Docker:
@ -222,6 +221,13 @@ func deletePossibleKicLeftOver(cname string, driverName string) {
return
}
if _, err := exec.LookPath(bin); err != nil {
glog.Infof("skipping deletePossibleKicLeftOver for %s: %v", bin, err)
return
}
glog.Infof("deleting possible KIC leftovers for %s (driver=%s) ...", cname, driverName)
delLabel := fmt.Sprintf("%s=%s", oci.ProfileLabelKey, cname)
cs, err := oci.ListContainersByLabel(bin, delLabel)
if err == nil && len(cs) > 0 {