kubernetes/minikube

cleanup: Driver.setupIP() duplicated in multiple drivers

クローズ

#21,093 opened on 2025/07/19

 (8 件のコメント) (0 件のリアクション) (1 人の担当者)Go (5,222 件のフォーク)batch import
co/krunkitco/qemu-driverco/vfkithelp wantedkind/cleanuplifecycle/frozen

Repository metrics

Stars
 (31,799 個のスター)
PR merge metrics
 (平均マージ 12d 19h) (30d で 43 merged PRs)

説明

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.

コントリビューターガイド