From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <a.lauterer@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 519A2922FF
 for <pve-devel@lists.proxmox.com>; Fri, 16 Feb 2024 17:34:50 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 2F84F618D
 for <pve-devel@lists.proxmox.com>; Fri, 16 Feb 2024 17:34:20 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Fri, 16 Feb 2024 17:34:19 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E341E48593
 for <pve-devel@lists.proxmox.com>; Fri, 16 Feb 2024 17:34:18 +0100 (CET)
Message-ID: <0b95517a-a6db-4dcb-b561-6179b42048e7@proxmox.com>
Date: Fri, 16 Feb 2024 17:34:17 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
To: pve-devel@lists.proxmox.com
References: <20240123170053.490250-1-a.lauterer@proxmox.com>
 <20240123170053.490250-15-a.lauterer@proxmox.com>
 <hlxjwyg7qxkzhyufxjq5zpylw2bcftnn7yoy7ov2jlmpjfp4ag@64bgsvtlp7dz>
 <326092b9-4f52-427c-850c-963ba33f3839@proxmox.com>
From: Aaron Lauterer <a.lauterer@proxmox.com>
In-Reply-To: <326092b9-4f52-427c-850c-963ba33f3839@proxmox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.065 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [partition.rs]
Subject: Re: [pve-devel] [PATCH v1 installer 14/18] auto-installer: add
 fetch answer binary
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 16 Feb 2024 16:34:50 -0000



On 2/8/24 17:46, Aaron Lauterer wrote:
> 
> 
> On 2/8/24 15:18, Christoph Heiss wrote:
>> Sorry for not including this in the first email.
>>
>> On Tue, Jan 23, 2024 at 06:00:49PM +0100, Aaron Lauterer wrote:
>> [..]
>>> diff --git a/proxmox-auto-installer/src/fetch_plugins/partition.rs b/proxmox-auto-installer/src/fetch_plugins/partition.rs
>>> new file mode 100644
>>> index 0000000..0552ddd
>>> --- /dev/null
>>> +++ b/proxmox-auto-installer/src/fetch_plugins/partition.rs
>>> @@ -0,0 +1,102 @@
>>> +use anyhow::{bail, Result};
>>> +use log::{info, warn};
>>> +use std::fs::read_to_string;
>>> +use std::path::{Path, PathBuf};
>>> +use std::process::Command;
>>> +
>>> +static ANSWER_FILE: &str = "answer.toml";
>>> +static ANSWER_MP: &str = "/mnt/answer";
>>> +static PARTLABEL: &str = "proxmoxinst";
>>> +static SEARCH_PATH: &str = "/dev/disk/by-label";
>>> +
>>> +pub struct FetchFromPartition;
>>> +
>>> +impl FetchFromPartition {
>>> +    /// Returns the contents of the answer file
>>> +    pub fn get_answer() -> Result<String> {
>>> +        let part_path = Self::scan_partlabels()?;
>>> +        Self::mount_part(part_path)?;
>>> +        Self::get_answer_file()
>>
>> Before returning, the partition should be unmounted, as it is not needed
>> anymore after this point.
>>
>> This also prevents some funny error that occurs if the installation
>> fails due to some error. The next time `proxmox-fetch-answer` is run, it
>> cannot mount the answer partition anymore, due to being already mounted.
> 
> For now sure. If we add additional plugins to fetch the answer file via a URL, we might want to place the ssl fingerprint on the same partition. Then we would have to either mount it again, or wait with the unmount until we have reached the end of going through the plugins, as a cleanup measure.

Actually, I think we want to keep it mounted. A warning when running the `proxmox-fetch-answer` once more, should be okay and will mainly happen during testing but not in a real-life scenario. It also makes it easy to place additional data on the partition and use it in a pre- or post-command. For example, scripts, config files, deb packages and so forth.