Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minikube delete exclude networks from other profiles #14279

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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