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

--set with .dns doesn't always seem to work #1940

Closed
pmalek opened this issue Oct 23, 2023 · 5 comments
Closed

--set with .dns doesn't always seem to work #1940

pmalek opened this issue Oct 23, 2023 · 5 comments
Labels

Comments

@pmalek
Copy link

pmalek commented Oct 23, 2023

Description

I use the following set of flags

'--set=.cpus = 6 | .memory = "10GiB" | .arch = "aarch64" | .vmType = "vz"  | .dns = []  | .dns += "192.168.1.250"'

Recently (with b5aa0dd) discovered that the dns setting doesn't always work as expected. I'm not sure what should be the effect of that setting but sometimes it does put 192.168.1.250 in /etc/resolv.conf and sometimes doesn't.

What should be the effect of that setting?


limactl -v
limactl version HEAD-b5aa0dd
@pmalek pmalek changed the title --set with .dns doesn't seem to work --set with .dns doesn't always seem to work Oct 23, 2023
@balajiv113
Copy link
Member

@pmalek Which template are you using ??
Is it Alpine or Ubuntu ??

@AkihiroSuda AkihiroSuda added the bug Something isn't working label Oct 27, 2023
@neowu
Copy link
Contributor

neowu commented Oct 28, 2023

i encountered same behavior, after digging little into source code

it looks like, if vmType == VZ, then it's always using args.SlirpDNS (which is gatewayIp) to generate user-data
and bypass DNS settings in lima.yml, then output user-data like

manage_resolv_conf: true

resolv_conf:
  nameservers:
  - 192.168.5.2

not sure whether it's intended behavior.

from the source

if firstUsernetIndex != -1 || *y.VMType == limayaml.VZ {

always go into first if condition branch

	if firstUsernetIndex != -1 || *y.VMType == limayaml.VZ {
		args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
	} else if *y.HostResolver.Enabled {
		args.UDPDNSLocalPort = udpDNSLocalPort
		args.TCPDNSLocalPort = tcpDNSLocalPort
		args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
	} else if len(y.DNS) > 0 {
		for _, addr := range y.DNS {
			args.DNSAddresses = append(args.DNSAddresses, addr.String())
		}
	} else {
		args.DNSAddresses, err = osutil.DNSAddresses()
		if err != nil {
			return err
		}
	}

@balajiv113
Copy link
Member

@neowu Yes that's the issue. Thanks for the analysis.
Willing to take it for fix ?? Or i can fix it

@neowu
Copy link
Contributor

neowu commented Oct 28, 2023

@balajiv113 I am willing to submit PR, though I haven't worked on Go project before :)

just need to make sure the expected behavior, do we always want to use DNS settings if existed, something like

	if len(y.DNS) > 0 {
		for _, addr := range y.DNS {
			args.DNSAddresses = append(args.DNSAddresses, addr.String())
		}
	} else if firstUsernetIndex != -1 || *y.VMType == limayaml.VZ {
		args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
	} else if *y.HostResolver.Enabled {
		args.UDPDNSLocalPort = udpDNSLocalPort
		args.TCPDNSLocalPort = tcpDNSLocalPort
		args.DNSAddresses = append(args.DNSAddresses, args.SlirpDNS)
	} else {
		args.DNSAddresses, err = osutil.DNSAddresses()
		if err != nil {
			return err
		}
	}

@balajiv113
Copy link
Member

Fixed as part of #1962

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants