public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change
@ 2026-09-14 12:45 Jonas Theisen
  2026-09-14 12:45 ` [PATCH pve-manager 1/2] fix #8031: factor out APT proxy write from update_database call Jonas Theisen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jonas Theisen @ 2026-09-14 12:45 UTC (permalink / raw)
  To: pve-devel

To allow reuse of the same code this patch series factors out
the relevant function inside the APT part of the API and reuses
the function on change of the http_proxy variable in the Cluster API.

This is to ensure a consistent state after a change of the HTTP proxy
without having to run a Refresh / apt update through the PVE tooling.

https://bugzilla.proxmox.com/show_bug.cgi?id=8031

Jonas Theisen (2):
  fix #8031: factor out APT proxy write from update_database call
  fix #8031: write APT proxy config on http_proxy change

 PVE/API2/APT.pm     | 23 ++++++++++++++---------
 PVE/API2/Cluster.pm |  9 +++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.47.3





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH pve-manager 1/2] fix #8031: factor out APT proxy write from update_database call
  2026-09-14 12:45 [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change Jonas Theisen
@ 2026-09-14 12:45 ` Jonas Theisen
  2026-09-14 12:45 ` [PATCH pve-manager 2/2] fix #8031: write APT proxy config on http_proxy change Jonas Theisen
  2026-09-14 15:25 ` [PATCH pve-manager 0/2] fix #8031: Write " Jonas Theisen
  2 siblings, 0 replies; 4+ messages in thread
From: Jonas Theisen @ 2026-09-14 12:45 UTC (permalink / raw)
  To: pve-devel

To allow reuse of the same function for the Cluster set_options call
this commit factors the function to write the APT proxy config file
out of the update_database call into a sub function.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 PVE/API2/APT.pm | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index 6dd4c261..936a7242 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -290,6 +290,19 @@ __PACKAGE__->register_method({
     },
 });
 
+sub set_apt_proxy_config {
+    my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+    my $aptconf = "// no proxy configured\n";
+
+    if (my $http_proxy = $dcconf->{http_proxy}) {
+        my $http_proxy_uri = URI->new($http_proxy);
+        $aptconf = "Acquire::http::Proxy \"${http_proxy_uri}\";\n";
+    }
+    my $aptcfn = "/etc/apt/apt.conf.d/76pveproxy";
+
+    PVE::Tools::file_set_contents($aptcfn, $aptconf);
+}
+
 __PACKAGE__->register_method({
     name => 'update_database',
     path => 'update',
@@ -334,15 +347,7 @@ __PACKAGE__->register_method({
         my $realcmd = sub {
             my $upid = shift;
 
-            # setup proxy for apt
-
-            my $aptconf = "// no proxy configured\n";
-            if (my $http_proxy = $dcconf->{http_proxy}) {
-                my $http_proxy_uri = URI->new($http_proxy);
-                $aptconf = "Acquire::http::Proxy \"${http_proxy_uri}\";\n";
-            }
-            my $aptcfn = "/etc/apt/apt.conf.d/76pveproxy";
-            PVE::Tools::file_set_contents($aptcfn, $aptconf);
+            set_apt_proxy_config();
 
             my $cmd = ['apt-get', 'update'];
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH pve-manager 2/2] fix #8031: write APT proxy config on http_proxy change
  2026-09-14 12:45 [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change Jonas Theisen
  2026-09-14 12:45 ` [PATCH pve-manager 1/2] fix #8031: factor out APT proxy write from update_database call Jonas Theisen
@ 2026-09-14 12:45 ` Jonas Theisen
  2026-09-14 15:25 ` [PATCH pve-manager 0/2] fix #8031: Write " Jonas Theisen
  2 siblings, 0 replies; 4+ messages in thread
From: Jonas Theisen @ 2026-09-14 12:45 UTC (permalink / raw)
  To: pve-devel

Writes the necessary file for APT if the http_proxy variable
on the datacenter level is changed.

This reuses the same function from the APT API for a regular
database update.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 PVE/API2/Cluster.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 4e5efbfd..e67f1f12 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -36,6 +36,7 @@ use PVE::API2::ClusterConfig;
 use PVE::API2::Firewall::Cluster;
 use PVE::API2::HAConfig;
 use PVE::API2::ReplicationConfig;
+use PVE::API2::APT qw(set_apt_proxy_config);
 
 my $have_sdn;
 eval {
@@ -842,7 +843,11 @@ __PACKAGE__->register_method({
     code => sub {
         my ($param) = @_;
 
+        my $http_proxy_change = 0;
+
         my $delete = extract_param($param, 'delete');
+        $http_proxy_change = 1
+            if ((defined($param->{http_proxy})) || ($delete eq 'http_proxy'));
 
         cfs_lock_file(
             'datacenter.cfg',
@@ -859,6 +864,10 @@ __PACKAGE__->register_method({
         );
         die $@ if $@;
 
+        if ($http_proxy_change) {
+            PVE::API2::APT::set_apt_proxy_config();
+        }
+
         return undef;
     },
 });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change
  2026-09-14 12:45 [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change Jonas Theisen
  2026-09-14 12:45 ` [PATCH pve-manager 1/2] fix #8031: factor out APT proxy write from update_database call Jonas Theisen
  2026-09-14 12:45 ` [PATCH pve-manager 2/2] fix #8031: write APT proxy config on http_proxy change Jonas Theisen
@ 2026-09-14 15:25 ` Jonas Theisen
  2 siblings, 0 replies; 4+ messages in thread
From: Jonas Theisen @ 2026-09-14 15:25 UTC (permalink / raw)
  To: pve-devel

superseded by 
https://lore.proxmox.com/pve-devel/20260914152423.410631-1-j.theisen@proxmox.com/T/#t 





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-14 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 12:45 [PATCH pve-manager 0/2] fix #8031: Write APT proxy config on http_proxy change Jonas Theisen
2026-09-14 12:45 ` [PATCH pve-manager 1/2] fix #8031: factor out APT proxy write from update_database call Jonas Theisen
2026-09-14 12:45 ` [PATCH pve-manager 2/2] fix #8031: write APT proxy config on http_proxy change Jonas Theisen
2026-09-14 15:25 ` [PATCH pve-manager 0/2] fix #8031: Write " Jonas Theisen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal