Align metadata uploader script with standard async setup - #1250
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/upload_repository_metadata.pywas still on the legacy async entrypoint:syncer.sync(main())plus a hand-assembledopen_async_session(get_async_db_key()), and it never calledsetup_all(). This aligns it with the pattern every other script inscripts/uses (seescripts/noarch_checker.py).Note that the missing
setup_all()looks like a latent bug rather than a cosmetic gap —MetadataUploaderneeds both the async session key and the sync'pulp'key (alws/utils/uploader.pycallsopen_session('pulp')), andfastapi_sqla_setup.setup_all()is what registers those session factories.Changes
scripts/upload_repository_metadata.pysync(main())->asyncio.run(main()), dropping thesyncerdependencyawait setup_all()at the top ofmain(), after arg validation so the earlyreturn 1path doesn't pay DB setup costopen_async_session(get_async_db_key())-> theget_async_db_session()context manager fromalws.dependencies(an@asynccontextmanagerwrapping the exact same call, so commit/rollback semantics are unchanged)syncer,open_async_session,get_async_db_keyandasynccontextmanagerimportsTesting
python -m py_compilepasses;sys.exit(...)still propagates thereturn 1exit code from the no-file-specified pathget_async_db_sessionatalws/dependencies.py:26,setup_allatalws/utils/fastapi_sqla_setup.py:16setup_all()before any session is opened)