Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-42190: Allow use of client/server Butler #125

Merged
merged 6 commits into from
Jan 25, 2024
Merged

Conversation

dhirving
Copy link
Contributor

@dhirving dhirving commented Jan 17, 2024

Updated usage of the Butler to make it compatible with the new client/server version of Butler.

The biggest change is that we now use a new Butler API 'LabeledButlerFactory' for creating the Butler. This adds support for RemoteButler, and also fixes some issues when using the old DirectButler. (The way Datalinker was using a single global Butler shared between threads was never OK -- DirectButler instances are not threadsafe because they have database session state that can get extremely confused if multiple threads use it at the same time.)

Butler server returns signed URLs directly, so there is a new case in the links endpoint that bypasses Datalinker's own URL signing when it gets an HTTP URL from the Butler.

I eliminated usage of some deprecated Butler methods that are not supported by RemoteButler. Also removed a workaround for a Butler bug that was fixed several months ago.

This does not immediately change the deployed Datalinker services to use Butler server -- that will be done via a configuration change in Phalanx in the coming weeks.

This PR depends on unreleased versions of safir, daf_butler, and resources, so this won't merge until those are updated to point to real releases.

@dhirving dhirving force-pushed the tickets/DM-42190 branch 7 times, most recently from 7935f69 to a17b301 Compare January 19, 2024 23:39
@dhirving dhirving requested a review from cbanek January 19, 2024 23:47
Copy link
Member

@rra rra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the exception of the dependencies on unreleased Butler and lsst-resources, this looks good. Good to merge as far as I'm concerned once those libraries have regular releases.

Comment on lines 23 to 30
safir[gcs]
#safir[gcs]
structlog

# Uncomment this, change the branch, comment out safir above, and run make
# update-deps-no-hashes to test against an unreleased version of Safir.
#git+https://github.com/lsst-sqre/safir@main#egg=safir[gcs]
git+https://github.com/lsst-sqre/safir@main#egg=safir[gcs]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new Safir has now been released with your change.

Upgrade safir for auth_delegated_token_dependency, and daf_butler for LabeledButlerFactory.
Use the new Butler factory class 'LabeledButlerFactory' to construct Butler instances.  This has two benefits:
1.  The previous construction pattern, where a single Butler instance was shared globally between requests, was not threadsafe.  Butler instances have internal state for database connection management and caching that gets confused if used simultaneously from more than one request/thread.
LabeledButlerFactory creates a separate Butler instance for each request.
2.  The factory allows the use of Butler's client/server mode, instead of always requiring direct access to the database.
The 'MissingCollectionError' issue that this code was working around was fixed a few months ago in DM-41117, with a test added in DM-42138.
The 'registry' object is now deprecated, and the getDataset function was moved to the root Butler interface as 'get_dataset'.
In the next commit I will be adding a usage of another ResourcePath property, so instead of mocking it there is no reason not to use the real library.

There was also a convoluted way of specifying the test size that was effectively a constant, so just make it a constant.
Butler server returns signed URLs directly, so there is no need for additional signing.
@dhirving dhirving marked this pull request as ready for review January 25, 2024 17:10
@dhirving dhirving merged commit d9bd7dd into main Jan 25, 2024
3 checks passed
@dhirving dhirving deleted the tickets/DM-42190 branch January 25, 2024 17:10
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.

2 participants