kubernetes/minikube

cleanup: Driver.setupIP() duplicated in multiple drivers

Closed

#21,093 opened on Jul 19, 2025

 (8 comments) (0 reactions) (1 assignee)Go (5,222 forks)batch import
co/krunkitco/qemu-driverco/vfkithelp wantedkind/cleanuplifecycle/frozen

Repository metrics

Stars
 (31,799 stars)
PR merge metrics
 (Avg merge 12d 19h) (43 merged PRs in 30d)

Description

The function exists in hyperkit, vfkit and krunkit.

The vfkit and krunkit version is an exact duplicate. The hyperkit version is simpler and implemented differently.

All 3 functions duplicate the same wait loop:

	// Implement a retry loop because IP address isn't added to dhcp leases file immediately
	for i := 0; i < 60; i++ {
		log.Debugf("Attempt %d", i)
		err = getIP()
		if err == nil {
			break
		}
		time.Sleep(2 * time.Second)
	}

The hyperkit version does 30 retries, vfkit and krunkit do 60 retries.

The fvkit and krunkit version have duplicate code to "unblock" booted on errors, which is incorrect for macOS < 15, and never needed for macOS >= 15.

	if !isBootpdError(err) {
		return errors.Wrap(err, "IP address never found in dhcp leases file")
	}
	if unblockErr := firewall.UnblockBootpd(); unblockErr != nil {
		klog.Errorf("failed unblocking bootpd from firewall: %v", unblockErr)
		exit.Error(reason.IfBootpdFirewall, "ip not found", err)
	}
	out.Styled(style.Restarting, "Successfully unblocked bootpd process from firewall, retrying")

We need to extract the common parts to common location and reuse them in the drivers instead of duplicating the code.

We may need to unify the number of retries, and make it configurable.

Contributor guide