Repository: lima-vm/lima
Pull request #548 (2022-01-13 06:34:10)

nerdctl: update to v0.16.0
https://github.com/containerd/nerdctl/releases/tag/v0.16.0


Patch:
diff --git a/cmd/limactl/debug.go b/cmd/limactl/debug.go
index 0ce89bc2..2554cee9 100644
--- a/cmd/limactl/debug.go
+++ b/cmd/limactl/debug.go
@@ -27,27 +27,22 @@ func newDebugDNSCommand() *cobra.Command {
 		Args:  cobra.RangeArgs(1, 2),
 		RunE:  debugDNSAction,
 	}
-	cmd.Flags().BoolP("ipv6", "6", false, "lookup IPv6 addresses too")
 	return cmd
 }
 
 func debugDNSAction(cmd *cobra.Command, args []string) error {
-	ipv6, err := cmd.Flags().GetBool("ipv6")
-	if err != nil {
-		return err
-	}
 	udpLocalPort, err := strconv.Atoi(args[0])
 	if err != nil {
 		return err
 	}
 	tcpLocalPort := 0
-	if len(args) > 1 {
+	if len(args) > 2 {
 		tcpLocalPort, err = strconv.Atoi(args[1])
 		if err != nil {
 			return err
 		}
 	}
-	srv, err := dns.Start(udpLocalPort, tcpLocalPort, ipv6)
+	srv, err := dns.Start(udpLocalPort, tcpLocalPort)
 	if err != nil {
 		return err
 	}
diff --git a/pkg/cidata/cidata.go b/pkg/cidata/cidata.go
index a4049c93..1a045565 100644
--- a/pkg/cidata/cidata.go
+++ b/pkg/cidata/cidata.go
@@ -138,7 +138,7 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
 	if err != nil {
 		return err
 	}
-	if *y.HostResolver.Enabled {
+	if *y.UseHostResolver {
 		args.UDPDNSLocalPort = udpDNSLocalPort
 		args.TCPDNSLocalPort = tcpDNSLocalPort
 		args.DNSAddresses = append(args.DNSAddresses, qemu.SlirpDNS)
diff --git a/pkg/hostagent/dns/dns.go b/pkg/hostagent/dns/dns.go
index cf30bce8..6b3887c9 100644
--- a/pkg/hostagent/dns/dns.go
+++ b/pkg/hostagent/dns/dns.go
@@ -18,7 +18,6 @@ const truncateSize = 512
 type Handler struct {
 	clientConfig *dns.ClientConfig
 	clients      []*dns.Client
-	IPv6         bool
 }
 
 type Server struct {
@@ -44,7 +43,7 @@ func newStaticClientConfig(ips []net.IP) (*dns.ClientConfig, error) {
 	return dns.ClientConfigFromReader(r)
 }
 
-func newHandler(IPv6 bool) (dns.Handler, error) {
+func newHandler() (dns.Handler, error) {
 	cc, err := dns.ClientConfigFromFile("/etc/resolv.conf")
 	if err != nil {
 		fallbackIPs := []net.IP{net.ParseIP("8.8.8.8"), net.ParseIP("1.1.1.1")}
@@ -61,7 +60,6 @@ func newHandler(IPv6 bool) (dns.Handler, error) {
 	h := &Handler{
 		clientConfig: cc,
 		clients:      clients,
-		IPv6:         IPv6,
 	}
 	return h, nil
 }
@@ -80,12 +78,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
 			Ttl:    5,
 		}
 		switch q.Qtype {
-		case dns.TypeAAAA:
-			if !h.IPv6 {
-				break
-			}
-			fallthrough
-		case dns.TypeCNAME, dns.TypeA:
+		case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA:
 			cname, err := net.LookupCNAME(q.Name)
 			if err != nil {
 				break
@@ -219,8 +212,8 @@ func (h *Handler) ServeDNS(w dns.ResponseWriter, req *dns.Msg) {
 	}
 }
 
-func Start(udpLocalPort, tcpLocalPort int, IPv6 bool) (*Server, error) {
-	h, err := newHandler(IPv6)
+func Start(udpLocalPort, tcpLocalPort int) (*Server, error) {
+	h, err := newHandler()
 	if err != nil {
 		return nil, err
 	}
diff --git a/pkg/hostagent/hostagent.go b/pkg/hostagent/hostagent.go
index 19d00b1a..c0706b1e 100644
--- a/pkg/hostagent/hostagent.go
+++ b/pkg/hostagent/hostagent.go
@@ -92,7 +92,7 @@ func New(instName string, stdout io.Writer, sigintCh chan os.Signal, opts ...Opt
 	}
 
 	var udpDNSLocalPort, tcpDNSLocalPort int
-	if *y.HostResolver.Enabled {
+	if *y.UseHostResolver {
 		udpDNSLocalPort, err = findFreeUDPLocalPort()
 		if err != nil {
 			return nil, err
@@ -248,8 +248,8 @@ func (a *HostAgent) Run(ctx context.Context) error {
 		a.emitEvent(ctx, exitingEv)
 	}()
 
-	if *a.y.HostResolver.Enabled {
-		dnsServer, err := dns.Start(a.udpDNSLocalPort, a.tcpDNSLocalPort, *a.y.HostResolver.IPv6)
+	if *a.y.UseHostResolver {
+		dnsServer, err := dns.Start(a.udpDNSLocalPort, a.tcpDNSLocalPort)
 		if err != nil {
 			return fmt.Errorf("cannot start DNS server: %w", err)
 		}
diff --git a/pkg/limayaml/default.yaml b/pkg/limayaml/default.yaml
index 144241d8..9577f1fd 100644
--- a/pkg/limayaml/default.yaml
+++ b/pkg/limayaml/default.yaml
@@ -236,14 +236,9 @@ propagateProxyEnv: null
 # The host agent implements a DNS server that looks up host names on the host
 # using the local system resolver. This means changing VPN and network settings
 # are reflected automatically into the guest, including conditional forward,
-# and mDNS lookup. By default only IPv4 addresses will be returned. IPv6 addresses
-# can only work when using a vmnet network interface and the host has working
-# IPv6 configured as well.
-hostResolver:
-  # Default: true
-  enabled: null
-  # Default: false
-  ipv6: null
+# and mDNS lookup:
+# Default: true
+useHostResolver: null
 
 # If useHostResolver is false, then the following rules apply for configuring dns:
 # Explicitly set DNS addresses for qemu user-mode networking. By default qemu picks *one*
diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go
index 728d02d0..6fd527e5 100644
--- a/pkg/limayaml/defaults.go
+++ b/pkg/limayaml/defaults.go
@@ -21,7 +21,7 @@ import (
 )
 
 func defaultContainerdArchives() []File {
-	const nerdctlVersion = "0.15.0"
+	const nerdctlVersion = "0.16.0"
 	location := func(goarch string) string {
 		return "https://github.com/containerd/nerdctl/releases/download/v" + nerdctlVersion + "/nerdctl-full-" + nerdctlVersion + "-linux-" + goarch + ".tar.gz"
 	}
@@ -29,12 +29,12 @@ func defaultContainerdArchives() []File {
 		{
 			Location: location("amd64"),
 			Arch:     X8664,
-			Digest:   "sha256:ca40d99d257e69f0220bb1cbdab1b602032692f45f713c901f328d2f4e3c12b3",
+			Digest:   "sha256:6dd955393fd781601a1cc7655d178fa539543f7a62f29e7c34a00e31ff4dddcf",
 		},
 		{
 			Location: location("arm64"),
 			Arch:     AARCH64,
-			Digest:   "sha256:dd8639ce868bab394467576f55375c4b40a8288badb579d2e30c3487da6004ea",
+			Digest:   "sha256:b342f6bec1bc0452148e9d8ec4afdf9de7b1e442e58e55fcf5330702e2fea62f",
 		},
 	}
 }
@@ -217,36 +217,14 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
 		// After defaults processing the singular HostPort and GuestPort values should not be used again.
 	}
 
-	// If both `useHostResolved` and `HostResolver.Enabled` are defined in the same config,
-	// then the deprecated `useHostResolved` setting is silently ignored.
-	if y.HostResolver.Enabled == nil {
-		y.HostResolver.Enabled = y.UseHostResolver
+	if y.UseHostResolver == nil {
+		y.UseHostResolver = d.UseHostResolver
 	}
-	if d.HostResolver.Enabled == nil {
-		d.HostResolver.Enabled = d.UseHostResolver
+	if o.UseHostResolver != nil {
+		y.UseHostResolver = o.UseHostResolver
 	}
-	if o.HostResolver.Enabled == nil {
-		o.HostResolver.Enabled = o.UseHostResolver
-	}
-
-	if y.HostResolver.Enabled == nil {
-		y.HostResolver.Enabled = d.HostResolver.Enabled
-	}
-	if o.HostResolver.Enabled != nil {
-		y.HostResolver.Enabled = o.HostResolver.Enabled
-	}
-	if y.HostResolver.Enabled == nil {
-		y.HostResolver.Enabled = pointer.Bool(true)
-	}
-
-	if y.HostResolver.IPv6 == nil {
-		y.HostResolver.IPv6 = d.HostResolver.IPv6
-	}
-	if o.HostResolver.IPv6 != nil {
-		y.HostResolver.IPv6 = o.HostResolver.IPv6
-	}
-	if y.HostResolver.IPv6 == nil {
-		y.HostResolver.IPv6 = pointer.Bool(false)
+	if y.UseHostResolver == nil {
+		y.UseHostResolver = pointer.Bool(true)
 	}
 
 	if y.PropagateProxyEnv == nil {
diff --git a/pkg/limayaml/limayaml.go b/pkg/limayaml/limayaml.go
index 053c5469..20e33d36 100644
--- a/pkg/limayaml/limayaml.go
+++ b/pkg/limayaml/limayaml.go
@@ -25,8 +25,7 @@ type LimaYAML struct {
 	Network           NetworkDeprecated `yaml:"network,omitempty" json:"network,omitempty"` // DEPRECATED, use `networks` instead
 	Env               map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
 	DNS               []net.IP          `yaml:"dns,omitempty" json:"dns,omitempty"`
-	HostResolver      HostResolver      `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
-	UseHostResolver   *bool             `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
+	UseHostResolver   *bool             `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"`
 	PropagateProxyEnv *bool             `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
 }
 
@@ -133,11 +132,6 @@ type Network struct {
 	Interface  string `yaml:"interface,omitempty" json:"interface,omitempty"`
 }
 
-type HostResolver struct {
-	Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
-	IPv6    *bool `yaml:"ipv6,omitempty" json:"ipv6,omitempty"`
-}
-
 // DEPRECATED types below
 
 // Types have been renamed to turn all references to the old names into compiler errors,
diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go
index 7ec8f721..14b7f0ad 100644
--- a/pkg/limayaml/validate.go
+++ b/pkg/limayaml/validate.go
@@ -194,8 +194,8 @@ func Validate(y LimaYAML, warn bool) error {
 		// processed sequentially and the first matching rule for a guest port determines forwarding behavior.
 	}
 
-	if y.HostResolver.Enabled != nil && *y.HostResolver.Enabled && len(y.DNS) > 0 {
-		return fmt.Errorf("field `dns` must be empty when field `HostResolver.Enabled` is true")
+	if y.UseHostResolver != nil && *y.UseHostResolver && len(y.DNS) > 0 {
+		return fmt.Errorf("field `dns` must be empty when field `useHostResolver` is true")
 	}
 
 	if err := validateNetwork(y, warn); err != nil {


Test patch:
diff --git a/pkg/limayaml/defaults_test.go b/pkg/limayaml/defaults_test.go
index bfe08289..f6ca06b6 100644
--- a/pkg/limayaml/defaults_test.go
+++ b/pkg/limayaml/defaults_test.go
@@ -67,10 +67,7 @@ func TestFillDefault(t *testing.T) {
 		Video: Video{
 			Display: pointer.String("none"),
 		},
-		HostResolver: HostResolver{
-			Enabled: pointer.Bool(true),
-			IPv6:    pointer.Bool(false),
-		},
+		UseHostResolver:   pointer.Bool(true),
 		PropagateProxyEnv: pointer.Bool(true),
 	}
 
@@ -189,10 +186,7 @@ func TestFillDefault(t *testing.T) {
 		Video: Video{
 			Display: pointer.String("cocoa"),
 		},
-		HostResolver: HostResolver{
-			Enabled: pointer.Bool(false),
-			IPv6:    pointer.Bool(true),
-		},
+		UseHostResolver:   pointer.Bool(false),
 		PropagateProxyEnv: pointer.Bool(false),
 
 		Mounts: []Mount{
@@ -304,10 +298,7 @@ func TestFillDefault(t *testing.T) {
 		Video: Video{
 			Display: pointer.String("cocoa"),
 		},
-		HostResolver: HostResolver{
-			Enabled: pointer.Bool(false),
-			IPv6:    pointer.Bool(false),
-		},
+		UseHostResolver:   pointer.Bool(false),
 		PropagateProxyEnv: pointer.Bool(false),
 
 		Mounts: []Mount{