Skip to content

Align metadata uploader script with standard async setup - #1250

Merged
anfimovdm merged 1 commit into
masterfrom
modernize-metadata-uploader-script
Aug 11, 2026
Merged

Align metadata uploader script with standard async setup#1250
anfimovdm merged 1 commit into
masterfrom
modernize-metadata-uploader-script

Conversation

@anfimovdm

Copy link
Copy Markdown
Contributor

Summary

scripts/upload_repository_metadata.py was still on the legacy async entrypoint: syncer.sync(main()) plus a hand-assembled open_async_session(get_async_db_key()), and it never called setup_all(). This aligns it with the pattern every other script in scripts/ uses (see scripts/noarch_checker.py).

Note that the missing setup_all() looks like a latent bug rather than a cosmetic gap — MetadataUploader needs both the async session key and the sync 'pulp' key (alws/utils/uploader.py calls open_session('pulp')), and fastapi_sqla_setup.setup_all() is what registers those session factories.

Changes

  • scripts/upload_repository_metadata.py
    • sync(main()) -> asyncio.run(main()), dropping the syncer dependency
    • added await setup_all() at the top of main(), after arg validation so the early return 1 path doesn't pay DB setup cost
    • open_async_session(get_async_db_key()) -> the get_async_db_session() context manager from alws.dependencies (an @asynccontextmanager wrapping the exact same call, so commit/rollback semantics are unchanged)
    • removed the now-unused syncer, open_async_session, get_async_db_key and asynccontextmanager imports

Testing

  • python -m py_compile passes; sys.exit(...) still propagates the return 1 exit code from the no-file-specified path
  • Verified the new imports resolve: get_async_db_session at alws/dependencies.py:26, setup_all at alws/utils/fastapi_sqla_setup.py:16
  • Diffed against the ~25 sibling scripts already on this pattern to confirm ordering (setup_all() before any session is opened)
  • No automated test covers this script; not run against a live DB/Pulp instance.

@anfimovdm
anfimovdm merged commit cd4b939 into master Aug 11, 2026
2 of 4 checks passed
@anfimovdm
anfimovdm deleted the modernize-metadata-uploader-script branch August 11, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant