From owner-freebsd-cloud@freebsd.org Mon Apr 20 20:47:15 2020 Return-Path: Delivered-To: freebsd-cloud@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3955F2AFD41 for ; Mon, 20 Apr 2020 20:47:15 +0000 (UTC) (envelope-from lwhsu.freebsd@gmail.com) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 495dzh0wmWz45pF; Mon, 20 Apr 2020 20:47:11 +0000 (UTC) (envelope-from lwhsu.freebsd@gmail.com) Received: by mail-yb1-f171.google.com with SMTP id l5so6181553ybf.5; Mon, 20 Apr 2020 13:47:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=EW24zqlsSvzNqppkC2+gDNxEakrfRd8OGmy5Q5B6i+8=; b=WgvDJ03p2ydMJYFvk0nw+cgP0KUDV7Nrr6x0KQ6KBVxqH/YXjlUBUSD4x1Pxgsj2YQ GPYiV6Ej88RXWoxORQSa1Rph+hIYPzfQMMdox/xateVApJ9ms3GdarxtBMrM8LK6KvJw mliosqg3MZ+0jbQ7ZXJQr/IfXQPFqlkvMWr6NDeq9pAE+QvFkqap8O9v9mQ2QR1b0lM4 h9LLP4gdwwh6muh+uc6WBWDg61s7Ydhyq2N2F0i70M8q3rjm/yo72J3mOEuUgPg6BqGd LabNepol09CI0t7tK/wkBeBceYCzvapKnupppCpCcwkSUyLi/CLTDjfFBFkd5hva4Ryz bxOw== X-Gm-Message-State: AGi0PuYmc7AUHNdfi48RUm4W4gvVtE9yjj+zISWN6Es+L/VaYqn+zjYj NBrwceUTfbMT/48vuPCCvLjkBoKUBTJVdzH7698h1f6S X-Google-Smtp-Source: APiQypIDjzElJvhwvnEECdGB8QhVLpxn/dqGo6WDC+WL8fu+FwVXmuFwQqtuYEGbm2iedPNh4FqV5JJiz1dCF5teTwU= X-Received: by 2002:a5b:283:: with SMTP id x3mr7201486ybl.497.1587415630520; Mon, 20 Apr 2020 13:47:10 -0700 (PDT) MIME-Version: 1.0 From: Li-Wen Hsu Date: Tue, 21 Apr 2020 04:46:58 +0800 Message-ID: Subject: Instance of 11.3 got "pkg: repository meta has wrong version 2" To: "freebsd-cloud@FreeBSD.org" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 495dzh0wmWz45pF X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of lwhsufreebsd@gmail.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=lwhsufreebsd@gmail.com X-Spamd-Result: default: False [-3.87 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[lwhsu@freebsd.org,lwhsufreebsd@gmail.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; IP_SCORE(-1.87)[ip: (-8.48), ipnet: 209.85.128.0/17(-0.40), asn: 15169(-0.43), country: US(-0.05)]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[171.219.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FORGED_SENDER(0.30)[lwhsu@freebsd.org,lwhsufreebsd@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[171.219.85.209.rep.mailspike.net : 127.0.0.17]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-cloud@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "FreeBSD on cloud platforms \(EC2, GCE, Azure, etc.\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2020 20:47:15 -0000 This is a stripped version from several private discussion. I think it will be useful to post here. CC bapt as he helped answer lots of my pkg questions, all the correct things following are from him, and hope he can correct if I have misunderstands below. :-) The background is some users reported that when launch instance of 11.3, pkg doesn't work at all and the error message is: "pkg: repository meta has wrong version 2" In short, this is due to the pkg installed (already bootstraped when creating the image) in the VM cannot handle the repository metadata created by newer pkg. This is safe and recommended to do a `pkg bootstrap -f` on the first boot of a VM created from an image. The `pkg update` is also recommended but not necessary, as the pkg will check if the index needs updating automatically. Long version: "pkg: repository meta has wrong version 2" means that pkg on client cannot handle the repository created by newer pkg on server. There are multiple versions of the repositories to allow backward compatibility. After a certain amount of time, we change the default version and deprecated the old versions on the server side. The problem we had is that the repository version 2 is very old (likely pkg 1.10), and the repository created by it was deprecated when pkg 1.12 was released (and latest version is 1.14 now). In most cases, the machines got maintained should already receive the latest pkg since it checks for self-update automatically. When the 11.3 image was created, the pkg was 1.9 and because we need to install utilities like agent for the cloud provider, the pkg was already bootstraped in the system, and got "fixed" in the image. A vanilla installed 11.3 also doesn't have this problem because when the system just installed, it has no "real" pkg bootstraped, the one comes with base system is /usr/sbin/pkg , a.k.a pkg(7), its responsibility is bootstraping pkg(8) from package repository, installed as /usr/local/sbin/pkg . Finally, a `pkg bootstrap -f` is recommended on the first boot of every VM created from an pre-built image, to ensure it gets the latest pkg before performing all the other actions with pkg. It is also safe because pkg will take care of the upgrading local pkg database (which stores the information about installed packages on the system.) I will check if doing `ASSUME_ALWAYS_YES=yes pkg bootstrap -f; pkg update` is feasible to make this as a default action in the "cloudware" release target, like we run freebsd-update on firstboot. Best, Li-Wen