← Back to team overview

curtin-dev team mailing list archive

[Merge] ~ogayot/curtin:LP1970409 into curtin:master

 

Olivier Gayot has proposed merging ~ogayot/curtin:LP1970409 into curtin:master.

Commit message:
Make sure curthooks do not discard supplied proxy settings
    
Just like we witnessed for the APT preferences, the proxy settings are not honored when Subiquity installs packages from the "packages" autoinstall section. This also applies for unattended-upgrades.
    
This happened because the installation of packages and execution of unattended-upgrades occur after running curthooks. Curtooks call handle_apt with an almost empty configuration.
    
Therefore, we would discard the proxy settings by removing the etc/apt/apt.conf.d/90curtin-aptproxy file.
    
Fixed by not removing etc/apt/preferences.d/90curtin.pref when the configuration does not contain APT preferences.


Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #1970409 in subiquity: "22.04: autoinstall ignores proxy on unattended-upgrades job"
  https://bugs.launchpad.net/subiquity/+bug/1970409

For more details, see:
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/420651

Just like we did a few months ago for APT preferences, we make sure that curthooks don't remove the proxy configuration file when executing.

This raises some questions though. Other files are subject to being discarded by curthooks, namely /etc/apt/apt.conf.d/94curtin-config. Should we also make sure they don't get removed? Maybe we need to change the way curthooks interact with the APT configuration.

Also, I'm curious to know what use-case the deletion of files in apt-config was covering.
-- 
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:LP1970409 into curtin:master.
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
index 1dc0233..4f62a86 100644
--- a/curtin/commands/apt_config.py
+++ b/curtin/commands/apt_config.py
@@ -579,7 +579,7 @@ def find_apt_mirror_info(cfg, arch=None):
 
 def apply_apt_proxy_config(cfg, proxy_fname, config_fname):
     """apply_apt_proxy_config
-       Applies any apt*proxy config from if specified
+       Applies any apt*proxy from config if specified
     """
     # Set up any apt proxy
     cfgs = (('proxy', 'Acquire::http::Proxy "%s";'),
@@ -592,8 +592,14 @@ def apply_apt_proxy_config(cfg, proxy_fname, config_fname):
         LOG.debug("write apt proxy info to %s", proxy_fname)
         util.write_file(proxy_fname, '\n'.join(proxies) + '\n')
     elif os.path.isfile(proxy_fname):
-        util.del_file(proxy_fname)
-        LOG.debug("no apt proxy configured, removed %s", proxy_fname)
+        # When $ curtin apt-config is called with no proxy set, it makes
+        # sense to remove the proxy file (if present). Having said that,
+        # this code is also called automatically at the curthooks stage with an
+        # empty configuration. Since the installation of external packages and
+        # execution of unattended-upgrades (which happen after executing the
+        # curthooks) need to use the proxy if specified, we must not let the
+        # curthooks remove the proxy file.
+        pass
 
     if cfg.get('conf', None):
         LOG.debug("write apt config info to %s", config_fname)

Follow ups