kubernetes/minikube

cleanup: Driver.setupIP() duplicated in multiple drivers

Open

#21,093 建立於 2025年7月19日

在 GitHub 查看
 (8 留言) (0 反應) (1 負責人)Go (31,799 star) (5,222 fork)batch import
co/krunkitco/qemu-driverco/vfkithelp wantedkind/cleanuplifecycle/frozen

描述

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.

貢獻者指南