Skip to content

Commit

Permalink
Merge pull request #14279 from kadern0/issue-12635
Browse files Browse the repository at this point in the history
fix: minikube delete exclude networks from other profiles
  • Loading branch information
sharifelgamal committed Jun 7, 2022
2 parents 409254e + f6d6391 commit d381a43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/drivers/kic/oci/network_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func tryCreateDockerNetwork(ociBin string, subnet *network.Parameters, mtu int,
args = append(args, fmt.Sprintf("com.docker.network.driver.mtu=%d", mtu))
}
}
args = append(args, fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)
args = append(args, fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), fmt.Sprintf("--label=%s=%s", ProfileLabelKey, name), name)

rr, err := runCmd(exec.Command(ociBin, args...))
if err != nil {
Expand Down Expand Up @@ -320,10 +320,10 @@ func networkNamesByLabel(ociBin string, label string) ([]string, error) {
return lines, nil
}

// DeleteKICNetworks deletes all networks created by kic
func DeleteKICNetworks(ociBin string) []error {
// DeleteAllKICKNetworksByLabel deletes all networks that have a specific label
func DeleteKICNetworksByLabel(ociBin string, label string) []error {
var errs []error
ns, err := networkNamesByLabel(ociBin, CreatedByLabelKey)
ns, err := networkNamesByLabel(ociBin, label)
if err != nil {
return []error{errors.Wrap(err, "list all volume")}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func PossibleLeftOvers(ctx context.Context, cname string, driverName string) {
klog.Warningf("error deleting volumes (might be okay).\nTo see the list of volumes run: 'docker volume ls'\n:%v", errs)
}

errs = oci.DeleteKICNetworks(bin)
errs = oci.DeleteKICNetworksByLabel(bin, delLabel)
if errs != nil {
klog.Warningf("error deleting leftover networks (might be okay).\nTo see the list of networks: 'docker network ls'\n:%v", errs)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/kic_custom_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestKicExistingNetwork(t *testing.T) {
t.Fatalf("error creating network: %v", err)
}
defer func() {
if err := oci.DeleteKICNetworks(oci.Docker); err != nil {
if err := oci.DeleteKICNetworksByLabel(oci.Docker, networkName); err != nil {
t.Logf("error deleting kic network, may need to delete manually: %v", err)
}
}()
Expand Down

0 comments on commit d381a43

Please sign in to comment.