Pulpcore-manager migrate fails on url.netloc.rsplit("@", maxsplit=1)

Problem:
When upgrading to 3.3.0.17, the installer runs the migration script 0077_move_remote_url_credentials.py. It fails on:

Running migrations:
   Applying core.0077_move_remote_url_credentials...Traceback (most recent call last):
   File "/usr/bin/pulpcore-manager", line 33, in <module>
[...full trace below...]
     _, url_split = url.netloc.rsplit("@", maxsplit=1)
ValueError: not enough values to unpack (expected 2, got 1)

Expected outcome:
It completes successfully.

Foreman and Proxy versions:
3.3.0.17 / 3.3.0
Foreman and Proxy plugin versions:
0077_move_remote_url_credentials.py is from:
python39-pulpcore-3.18.10-1.el8pc.noarch

Distribution and version:
Red Hat Enterprise Linux release 8.6 (Ootpa)
(upgraded to 8.7 during the foreman upgrade)

Other relevant data:

2022-11-21 17:22:50 [DEBUG ] [configure] Pulpcore::Admin[migrate --noinput]: Starting to evaluate the resource (13515 of 13614)
2022-11-21 17:22:50 [DEBUG ] [configure] Pulpcore::Admin[migrate --noinput]: Evaluated in 0.00 seconds
2022-11-21 17:22:50 [DEBUG ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]: Starting to evaluate the resource (13516 of 13614)
2022-11-21 17:22:50 [DEBUG ] [configure] Exec[pulpcore-manager migrate --noinput](provider=posix): Executing check 'pulpcore-manager migrate --plan | grep "No planned migration operations"'
2022-11-21 17:22:50 [DEBUG ] [configure] Executing with uid=pulp: 'pulpcore-manager migrate --plan | grep "No planned migration operations"'
2022-11-21 17:22:52 [DEBUG ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/unless: System check identified some issues:
2022-11-21 17:22:52 [DEBUG ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/unless:
2022-11-21 17:22:52 [DEBUG ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/unless: WARNINGS:
2022-11-21 17:22:52 [DEBUG ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/unless: ?: (guardian.W001) Guardian authentication backend is not hooked. You can add this in settings as eg: `AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'guardian.backends.ObjectPermissionBackend')`.
2022-11-21 17:22:52 [DEBUG ] [configure] Exec[pulpcore-manager migrate --noinput](provider=posix): Executing 'pulpcore-manager migrate --noinput'
2022-11-21 17:22:52 [DEBUG ] [configure] Executing with uid=pulp: 'pulpcore-manager migrate --noinput'
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: System check identified some issues:
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: WARNINGS:
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: ?: (guardian.W001) Guardian authentication backend is not hooked. You can add this in settings as eg: `AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'guardian.backends.ObjectPermissionBackend')`.
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: Operations to perform:
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   Apply all migrations: admin, ansible, auth, certguard, container, contenttypes, core, file, guardian, rpm, sessions
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: Running migrations:
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   Applying core.0077_move_remote_url_credentials...Traceback (most recent call last):
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/bin/pulpcore-manager", line 33, in <module>
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     sys.exit(load_entry_point('pulpcore==3.18.10', 'console_scripts', 'pulpcore-manager')())
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/pulpcore/app/manage.py", line 11, in manage
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     execute_from_command_line(sys.argv)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     utility.execute()
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packa
ges/django/core/management/__init__.py", line 413, in execute
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     self.fetch_command(subcommand).run_from_argv(self.argv)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     self.execute(*args, **cmd_options)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     output = self.handle(*args, **options)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     res = handle_func(*args, **kwargs)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     post_migrate_state = executor.migrate(
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     state = migration.apply(state, schema_editor)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     self.code(from_state.apps, schema_editor)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:   File "/usr/lib/python3.9/site-packages/pulpcore/app/migrations/0077_move_remote_url_credentials.py", line 19, in move_remote_url_credentials
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns:     _, url_split = url.netloc.rsplit("@", maxsplit=1)
2022-11-21 17:22:55 [INFO  ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: ValueError: not enough values to unpack (expected 2, got 1)
2022-11-21 17:22:55 [ERROR ] [configure] 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]
2022-11-21 17:22:55 [ERROR ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: change from 'notrun' to ['0'] failed: 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]

There is a patch posted in Foreman 3.3 / Katello 4.5 upgrade failed [pulpcore-manager migrate --noinput] for this exact issue. We didn’t update the repos yet to contain it, though.

2 Likes

Thanks, I just found it at the same time you commented. I’ll try to edit the file mid-upgrade before it runs and see if it completes.

You can edit the file before running the foreman-installer, it won’t overwrite it as the packages are already updated.