3.17 Katello , Puppet 6.14 and foreman 2.2 | 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]

I update puppet to puppet

puppet-agent-6.19.1-1.el7.x86_64 puppetserver-6.14.1-1.el7.noarch

[ERROR 2020-11-05T14:33:43 main] Errors encountered during run:

[ERROR 2020-11-05T14:33:43 main] foreman-maintain packages is-locked --assumeyes failed! Check the output for error!

[ERROR 2020-11-05T14:33:43 main] ‘pulpcore-manager migrate --noinput’ returned 1 instead of one of [0]

[ERROR 2020-11-05T14:33:43 main] /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]

I believe if you change repos or delete existing repos below error come but not sure

foreman-maintain packages is-locked --assumeyes failed! Check the output for error!

can you try running this as root:

PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager migrate --noinput

and see if you get any errors?

1 Like

I run foreman-installer again and it fixed but sure what was the issue but I del repo in yum.repos which I revert.

PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager migrate --noinput

System check identified some issues:

WARNINGS:

?: (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').

Operations to perform:

Apply all migrations: admin, auth, certguard, container, contenttypes, core, file, guardian, pulp_2to3_migration, rpm, sessions

Running migrations:

No migrations to apply.

Yep that looks fine. I guess the problem is resolved?

1 Like

yes foreman-maintain service restart

I also ran into this error upgrading from 3.16 to 3.17. This post pointed me in the right direction… But for me I found that the ownership of /etc/pulp/settings.py was root, 0640. Once I changed it to pulp as owner, the foreman-install completed.

chown pulp /etc/pulp/settings.py
foreman-installer
2 Likes

That is not recommended. The ownership should be root while the group should be pulp. If that doesn’t work, it’s a bug. In fact, the installer should reset those permissions before it even runs migrations.

1 Like

Alright, well let me know if you have a recommendation. It fixed the problem and I didn’t have time to do a fresh re-build. If I have time I will dig into the logs again and post the exact errors.

I submitted a PR that should provide log output in case it fails. That should make debugging easier in the future.

Thanks!

Follow up here with @ekohl’s PR. While running the installer with:
foreman-installer --foreman-proxy-plugin-pulp-pulpcore-enabled true

$ PULP_SETTINGS=/etc/pulp/settings.py sudo pulpcore-manager migrate --noinput
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pulpcore/app/settings.py", line 253, in <module>
    CONTENT_ORIGIN
NameError: name 'CONTENT_ORIGIN' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bin/pulpcore-manager", line 11, in <module>
    load_entry_point('pulpcore==3.7.3', 'console_scripts', 'pulpcore-manager')()
  File "/usr/lib/python3.6/site-packages/pulpcore/app/manage.py", line 11, in manage
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/usr/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/usr/lib/python3.6/site-packages/pulpcore/app/apps.py", line 81, in ready
    self.import_viewsets()
  File "/usr/lib/python3.6/site-packages/pulpcore/app/apps.py", line 110, in import_viewsets
    from pulpcore.app.viewsets import NamedModelViewSet
  File "/usr/lib/python3.6/site-packages/pulpcore/app/viewsets/__init__.py", line 1, in <module>
    from .base import (  # noqa
  File "/usr/lib/python3.6/site-packages/pulpcore/app/viewsets/base.py", line 17, in <module>
    from pulpcore.app import tasks
  File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/__init__.py", line 1, in <module>
    from pulpcore.app.tasks import base, repository, upload  # noqa
  File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/upload.py", line 6, in <module>
    from pulpcore.app.serializers import ArtifactSerializer
  File "/usr/lib/python3.6/site-packages/pulpcore/app/serializers/__init__.py", line 42, in <module>
    from .exporter import (  # noqa
  File "/usr/lib/python3.6/site-packages/pulpcore/app/serializers/exporter.py", line 8, in <module>
    from pulpcore.app import models, settings
  File "/usr/lib/python3.6/site-packages/pulpcore/app/settings.py", line 257, in <module>
    "CONTENT_ORIGIN is a required setting but it was not configured. This may be caused "
django.core.exceptions.ImproperlyConfigured: CONTENT_ORIGIN is a required setting but it was not configured. This may be caused by invalid read permissions of the settings file. Note that CONTENT_ORIGIN is set by the installer automatically.

The contents of the /etc/pulp/settings.py:

$ sudo cat /etc/pulp/settings.py 
CONTENT_HOST = "centos7-proxy-devel.jjeffers.example.com"
CONTENT_ORIGIN = "https://centos7-proxy-devel.jjeffers.example.com"
[...]

pulpcore-manager should run as the pulp user, not as root. Ideally this would be a wrapper that actually enforces that, but I think the Pulp team is aware of it. I also think that sudo drops your PULP_SETTINGS env var.

Does this also mean the installer should be run as a non-root user as well?

No, just the pulpcore-manager command. Most notably, if you run pulpcore-manager collectstatic as root, you will mess up permissions and break future upgrades. The installer should run it as the correct user.

Hi,

I’m facing the same problem. I tried running foreman-installer to update my expired custom ssl certs and so I tried the following as suggested:

[root@katello ssl]# su - pulp -s /bin/bash
-bash-4.2$ PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager migrate --noinput
System check identified some issues:
WARNINGS:
?: (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').
Operations to perform:
Apply all migrations: admin, auth, certguard, container, contenttypes, core, deb, file, guardian, pulp_2to3_migration, rpm, sessions
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won’t be applied.
Run ‘manage.py makemigrations’ to make new migrations, and then re-run ‘manage.py migrate’ to apply them.

Maybe this whole problem was caused by me trying to migrate from pulp2 to pulp3 some time ago. Any ideas?

I also faced this issue while upgrading from 3.16.2 to 3.17.0….the key for me was to reboot after upgrading the package, ensure to restart all services using foreman maintain and then proceed with foreman-installer. I am not why why those steps needed to be fallow but it work for me and upgrade went fine.

Sorry, but that is bad advice. You absolutely should not do that. Follow the docs.

The upgrade procedure tells you to stop foreman before upgrading the packages. What you seem to do is to upgrade the packages while foreman is running. The even rebooting or restarting foreman, which may not even start properly because the new packages don’t necessarily work with the database level.

Do not start foreman with the new packages installed before running foreman-installer. foreman-installer will start all services again, updating all necessary information and database tables on the way.

Stop foreman with foreman-maintain services stop. Upgrade the packages. Run foreman-installer.

You should even do this with any package update (even if it is not directly foreman related). For instance after updating httpd you have to run foreman-installer again.