Orphaned packages

Hi,

Is there a general procedure to clean packages left behind after foreman/katello upgrades?

It seems there are quite a few:

# package-cleanup --orphans
python39-aiofiles-0:22.1.0-1.el8.noarch
python39-aioredis-0:2.0.1-2.el8.noarch
python39-aiosignal-0:1.3.1-1.el8.noarch
python39-asgiref-0:3.6.0-1.el8.noarch
python39-async-lru-0:1.0.3-1.el8.noarch
python39-async-timeout-0:4.0.2-2.el8.noarch
python39-asyncio-throttle-0:1.0.2-3.el8.noarch
python39-attrs-0:21.4.0-2.el8.noarch
python39-backoff-0:2.2.1-1.el8.noarch
python39-beautifulsoup4-0:4.11.2-1.el8.noarch
python39-bleach-0:3.3.1-2.el8.noarch
python39-bleach-allowlist-0:1.0.3-3.el8.noarch
python39-bracex-0:2.2.1-2.el8.noarch
python39-brotli-0:1.0.9-2.el8.x86_64
python39-cchardet-0:2.1.7-4.el8.x86_64
python39-certifi-0:2020.6.20-3.el8.noarch
python39-charset-normalizer-0:2.1.1-1.el8.noarch
python39-click-0:8.1.3-1.el8.noarch
python39-click-shell-0:2.1-3.el8.noarch
python39-colorama-0:0.4.4-3.el8.noarch
python39-commonmark-0:0.9.1-5.el8.noarch
python39-contextlib2-0:21.6.0-3.el8.noarch
python39-dataclasses-0:0.8-3.el8.noarch
python39-dateutil-0:2.8.2-2.el8.noarch
python39-debian-0:0.1.44-3.el8.noarch
python39-defusedxml-0:0.7.1-3.el8.noarch
python39-deprecated-0:1.2.13-1.el8.noarch
python39-diff-match-patch-0:20200713-3.el8.noarch
python39-ecdsa-0:0.18.0-1.el8.noarch
python39-et-xmlfile-0:1.1.0-2.el8.noarch
python39-filelock-0:3.8.0-1.el8.noarch
python39-frozenlist-0:1.3.3-1.el8.x86_64
python39-future-0:0.18.3-1.el8.noarch
python39-gitdb-0:4.0.10-1.el8.noarch
python39-gitpython-0:3.1.32-1.el8.noarch
python39-gnupg-0:0.5.0-1.el8.noarch
python39-googleapis-common-protos-0:1.59.1-1.el8.noarch
python39-grpcio-0:1.56.0-1.el8.x86_64
python39-idna-ssl-0:1.1.0-5.el8.noarch
python39-importlib-metadata-0:6.0.1-1.el8.noarch
python39-inflection-0:0.5.1-3.el8.noarch
python39-iniparse-0:0.4-35.el8.noarch
python39-jinja2-0:3.1.2-1.el8.noarch
python39-markuppy-0:1.14-3.el8.noarch
python39-markupsafe-0:2.1.2-1.el8.x86_64
python39-mccabe-0:0.6.1-3.el8.noarch
python39-multidict-0:6.0.4-1.el8.x86_64
python39-naya-0:1.1.1-3.el8.noarch
python39-odfpy-0:1.4.1-6.el8.noarch
python39-openpyxl-0:3.1.0-1.el8.noarch
python39-packaging-0:21.3-1.el8.noarch
python39-parsley-0:1.3-2.el8.noarch
python39-pillow-0:9.5.0-1.el8.x86_64
python39-productmd-0:1.33-3.el8.noarch
python39-prometheus-client-0:0.8.0-3.el8.noarch
python39-protobuf-0:4.21.6-1.el8.noarch
python39-psycopg-0:3.1.9-1.el8.noarch
python39-pyOpenSSL-0:22.1.0-1.el8.noarch
python39-pycairo-0:1.20.1-3.el8.x86_64
python39-pycares-0:4.1.2-2.el8.x86_64
python39-pycryptodomex-0:3.14.1-2.el8.x86_64
python39-pygtrie-0:2.5.0-1.el8.noarch
python39-pyparsing-0:2.4.7-3.el8.noarch
python39-pyrsistent-0:0.18.1-2.el8.x86_64
python39-pytz-0:2022.2.1-1.el8.noarch
python39-redis-0:4.3.4-1.el8.noarch
python39-requirements-parser-0:0.2.0-3.el8.noarch
python39-rhsm-0:1.19.2-3.el8.x86_64
python39-ruamel-yaml-0:0.17.21-2.el8.noarch
python39-ruamel-yaml-clib-0:0.2.7-1.el8.x86_64
python39-schema-0:0.7.5-2.el8.noarch
python39-semantic-version-0:2.10.0-1.el8.noarch
python39-smmap-0:5.0.0-2.el8.noarch
python39-socks-0:2.0.3-2.el8.noarch
python39-soupsieve-0:2.3.1-3.el8.noarch
python39-tablib-0:3.3.0-1.el8.noarch
python39-tenacity-0:7.0.0-3.el8.noarch
python39-types-cryptography-0:3.3.23.2-1.el8.noarch
python39-typing-extensions-0:4.7.1-1.el8.noarch
python39-uritemplate-0:4.1.1-2.el8.noarch
python39-url-normalize-0:1.4.3-4.el8.noarch
python39-urlman-0:2.0.1-1.el8.noarch
python39-uuid6-0:2023.5.2-1.el8.noarch
python39-webencodings-0:0.5.1-3.el8.noarch
python39-whitenoise-0:6.0.0-1.el8.noarch
python39-wrapt-0:1.14.1-1.el8.x86_64
python39-xlrd-0:2.0.1-5.el8.noarch
python39-xlwt-0:1.3.0-3.el8.noarch
python39-yarl-0:1.8.2-1.el8.x86_64
python39-zipp-0:3.4.0-4.el8.noarch
qpid-proton-c-0:0.37.0-1.el8.x86_64
rubygem-anemone-0:0.7.2-24.el8.noarch
rubygem-mini_portile2-0:2.8.0-1.el8.noarch
rubygem-qpid_proton-0:0.37.0-1.el8.x86_64
rubygem-thread_safe-0:0.3.6-6.el8.noarch
rubygem-unicode-0:0.4.4.4-4.el8.x86_64
rubygem-webpack-rails-0:0.9.11-1.el8.noarch

I have removed those a while ago:

remove rubygem-unicode.x86_64 rubygem-qpid_proton.x86_64 qpid-proton-c.x86_64
remove -y python39-aiofiles.noarch python39-aioredis.noarch python39-aiosignal.noarch python39-asgiref.noarch python39-async-lru.noarch python39-async-timeout.noarch python39-asyncio-throttle.noarch python39-attrs.noarch python39-backoff.noarch python39-beautifulsoup4.noarch python39-bleach.noarch python39-bleach-allowlist.noarch python39-bracex.noarch python39-brotli.x86_64 python39-cchardet.x86_64 python39-certifi.noarch python39-charset-normalizer.noarch python39-click.noarch python39-click-shell.noarch python39-colorama.noarch python39-commonmark.noarch python39-contextlib2.noarch python39-dataclasses.noarch python39-dateutil.noarch python39-debian.noarch python39-defusedxml.noarch python39-deprecated.noarch python39-diff-match-patch.noarch python39-ecdsa.noarch python39-et-xmlfile.noarch python39-filelock.noarch python39-frozenlist.x86_64 python39-future.noarch python39-gitdb.noarch python39-gitpython.noarch python39-gnupg.noarch python39-googleapis-common-protos.noarch python39-grpcio.x86_64 python39-idna-ssl.noarch python39-importlib-metadata.noarch python39-inflection.noarch python39-iniparse.noarch python39-jinja2.noarch python39-lockfile.noarch python39-markuppy.noarch python39-markupsafe.x86_64 python39-mccabe.noarch python39-multidict.x86_64 python39-naya.noarch python39-odfpy.noarch python39-openpyxl.noarch python39-packaging.noarch python39-parsley.noarch python39-pillow.x86_64 python39-productmd.noarch python39-prometheus-client.noarch python39-protobuf.noarch python39-psycopg.noarch python39-ptyprocess.noarch python39-pyOpenSSL.noarch python39-pycairo.x86_64 python39-pycares.x86_64 python39-pycryptodomex.x86_64 python39-pygtrie.noarch python39-pyparsing.noarch python39-pyrsistent.x86_64 python39-pytz.noarch python39-redis.noarch python39-requirements-parser.noarch python39-rhsm.x86_64 python39-ruamel-yaml.noarch python39-ruamel-yaml-clib.x86_64 python39-schema.noarch python39-semantic-version.noarch python39-smmap.noarch python39-socks.noarch python39-soupsieve.noarch python39-tablib.noarch python39-tenacity.noarch python39-types-cryptography.noarch python39-typing-extensions.noarch python39-uritemplate.noarch python39-url-normalize.noarch python39-urlman.noarch python39-uuid6.noarch python39-webencodings.noarch python39-whitenoise.noarch python39-wrapt.x86_64 python39-xlrd.noarch python39-xlwt.noarch python39-yarl.x86_64 python39-zipp.noarch
remove python3-lockfile.noarch python3-daemon.noarch

There are still some unneeded packages listed on our server and I never dared to simply run dnf autoremove. But for your list it looks like an autoremove should be safe.