kubernetes/minikube

cleanup: Driver.setupIP() duplicated in multiple drivers

Open

Aperta il 19 lug 2025

Vedi su GitHub
 (8 commenti) (0 reazioni) (1 assegnatario)Go (31.799 star) (5222 fork)batch import
co/krunkitco/qemu-driverco/vfkithelp wantedkind/cleanuplifecycle/frozen

Descrizione

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.

Guida contributor