Skip to content

Commit ed85029

Browse files
prilrclaude
andcommitted
CLOS-4056 follow-up: target_userspace_creator: tolerate missing dnf-plugin-spacewalk config
When the target userspace is built from no-auth-aware repos (rhn-client-tools >= 3.0.1, which Obsoletes dnf-plugin-spacewalk on CL8/9 per CLOS-4056), /etc/dnf/plugins/spacewalk.conf is absent in /var/lib/leapp/elNuserspace/. The unconditional `open(spacewalk_conf, 'r')` inside `if os.path.isdir('/etc/sysconfig/rhn')` then raises IOError: [Errno 2] No such file or directory: '/var/lib/leapp/el8userspace/etc/dnf/plugins/spacewalk.conf' and target_userspace_creator crashes with exit code 1, blocking preupgrade on every CL7+CLN -> CL8+no_auth transition where the new RC packages reach the target. Surfaced during CLOS-4056 verification (elevate-qa Run #3 build #40 with BS_BUILDS_TARGET delivery wired up correctly via leapp_upgrade_repositories.repo late-append). The outer /etc/sysconfig/rhn check is correct (CLN registration may persist on no-auth for licensing), but the inner file presence is no longer guaranteed - guard it with an explicit os.path.isfile check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fcecc76 commit ed85029

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

  • repos/system_upgrade/common/actors/targetuserspacecreator/libraries

repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,16 +681,26 @@ def _prep_repository_access(context, target_userspace):
681681
run(['rm', '-rf', os.path.join(target_etc, 'rhsm')])
682682
context.copytree_from('/etc/rhsm', os.path.join(target_etc, 'rhsm'))
683683

684-
if os.path.isdir('/etc/sysconfig/rhn'):
684+
# Set up spacewalk plugin config in the target chroot only if the plugin's
685+
# config file actually exists there. Under the no-auth migration (CLOS-4056)
686+
# rhn-client-tools >= 3.0.1 Obsoletes dnf-plugin-spacewalk on CL8/9, so
687+
# the target userspace built from the no-auth-aware repos has no
688+
# /etc/dnf/plugins/spacewalk.conf - the original unconditional open
689+
# raised IOError [Errno 2] and crashed target_userspace_creator. The
690+
# outer /etc/sysconfig/rhn directory check is on the source side and
691+
# remains valid (CLN registration may persist for licensing/inventory),
692+
# but the inner file presence is no longer guaranteed.
693+
spacewalk_conf = os.path.join(target_etc, 'dnf/plugins/spacewalk.conf')
694+
if os.path.isdir('/etc/sysconfig/rhn') and os.path.isfile(spacewalk_conf):
685695
# Set up spacewalk plugin config
686-
with open(os.path.join(target_etc, 'dnf/plugins/spacewalk.conf'), 'r') as f:
696+
with open(spacewalk_conf, 'r') as f:
687697
lines = f.readlines()
688698
new_lines = []
689699
for line in lines:
690700
if 'enabled' in line:
691701
line = 'enabled = 1\n'
692702
new_lines.append(line)
693-
with open(os.path.join(target_etc, 'dnf/plugins/spacewalk.conf'), 'w') as f:
703+
with open(spacewalk_conf, 'w') as f:
694704
f.writelines(new_lines)
695705

696706
if os.path.isfile('/etc/mirrorlist'):

0 commit comments

Comments
 (0)