-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add endpoint for REST version and capabilities. #5429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for starting this! I left some first comments and let's discuss the next steps.
tiledb/sm/rest/curl.cc
Outdated
@@ -369,6 +369,8 @@ Status Curl::set_headers(struct curl_slist** headers) const { | |||
std::string basic_auth = username + std::string(":") + password; | |||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |||
curl_easy_setopt(curl, CURLOPT_USERPWD, basic_auth.c_str()); | |||
} else { | |||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. Why allow that? This doesn't look good or necessary. Why allow version checking to be unauthenticated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The endpoint doesn't require authentication server side, all other endpoints currently supported by core do. If we make this request we could assume we plan to make requests to authenticated routes so the error is likely inevitable, on first pass it just seemed strange to require a token for an unauthenticated route.
I removed it and we now require the authentication to be configured, I don't think there is really a case where we would just make this request and not send any others. I'll bring this up on my REST PR as well to see if we want to require authentication on the REST side as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for requiring authentication on the REST side as well, but yes checking with REST experts might be a better idea. The only downside I can see is performance, but having a general rule that all client-server communication needs to be authenticated sounds more important to me.
tiledb/sm/rest/curl.cc
Outdated
@@ -956,6 +960,7 @@ Status Curl::get_data( | |||
|
|||
CURLcode ret; | |||
headerData.uri = &res_ns_uri; | |||
headerData.should_cache_redirect = res_ns_uri != "no-cache"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that because the version request will always be the first one to get to the server? It's worth at least a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of yeah, AFAICT this is the first endpoint supported by core that doesn't require an asset URI. We use the asset URI in Curl::write_header_callback
to parse and cache redirect URIs. This was quite hacky though, it was really just for POC.
There was already a similar boolean flag in Curl::init
to disable this so I updated to use that instead. Without an asset URI we need to disable the caching done on the URI or we fail the curl request after returning 0 here: https://github.com/tiledb-inc/tiledb/blob/286da187ee9a3bc9d66538ce2ed433cc2c8b759a/tiledb/sm/rest/curl.cc#L167
The logging looks like this when you set TILEDB_CONFIG_LOGGING_LEVEL=5, we end up in a retry loop after returning 0 in the callback linked above (Failure writing output to destination, passed 17 returned 0
)
[2025-01-22 15:47:08.313] [Process: 2121225] [error] [1737578828284111920-Global] Rest components as array_ns and array_uri cannot be empty
[2025-01-22 15:47:08.313] [Process: 2121225] [trace] [1737578828261932792-Context: 2] [curl : 2] [curl : 1] OP=CORE-TO-REST,SECONDS=0.001,RETRY=0,CODE=200,URL=127.0.0.1:8181/v4/version
[2025-01-22 15:47:08.313] [Process: 2121225] [debug] [1737578828284111920-Global] Request to 127.0.0.1:8181/v4/version failed with Curl error message "Failure writing output to destination, passed 17 returned 0", will sleep 500ms, retry count 0
Also I guess the UT can't go in as part of this PR, but will have to be moved to the next one that will come after the REST server has moved the libtiledb (minor) release that includes this PR. Hopefully for the last time 😅 |
ebcebce
to
feef2fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments but overall it looks good!
tiledb/sm/rest/rest_capabilities.h
Outdated
class RestClientRemote; | ||
|
||
class RestCapabilities { | ||
friend RestClientRemote; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have accessors for all private arguments, how about making this a struct as well and simplify things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess what I meant is that once we make this a struct
, we no longer need friend
or getters for the members. If you think it's important that the member variables are not set outside of the struct or its friends you can revert this to a class
to preserve those semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha, this should work just fine since RestClientRemote
returns only a const reference of the struct. I kept the RestClientRemote::rest_tiledb_version()
and similar accessors in RestClientRemote
for convenience, but I removed accessors from the struct itself since they are not needed.
tiledb/sm/rest/curl.cc
Outdated
@@ -369,6 +369,8 @@ Status Curl::set_headers(struct curl_slist** headers) const { | |||
std::string basic_auth = username + std::string(":") + password; | |||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |||
curl_easy_setopt(curl, CURLOPT_USERPWD, basic_auth.c_str()); | |||
} else { | |||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_NONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for requiring authentication on the REST side as well, but yes checking with REST experts might be a better idea. The only downside I can see is performance, but having a general rule that all client-server communication needs to be authenticated sounds more important to me.
f05f1d0
to
fc3332c
Compare
Co-authored-by: Theodore Tsirpanis <[email protected]>
+ Can be added back once REST used in CI supports the endpoint.
7099ce3
to
fc8044a
Compare
fc8044a
to
8c67284
Compare
This is ready for review, a few notes for reviewers -
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some last comments and I'll approve. Let's also add a link to the design doc in the PR description.
tiledb/sm/rest/rest_capabilities.h
Outdated
class RestClientRemote; | ||
|
||
class RestCapabilities { | ||
friend RestClientRemote; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess what I meant is that once we make this a struct
, we no longer need friend
or getters for the members. If you think it's important that the member variables are not set outside of the struct or its friends you can revert this to a class
to preserve those semantics.
This adds the REST capabilities endpoint to
RestClientRemote
and serialization for theRestCapabilities
response. The endpoint is currently not in use internally and there is no way to make the request using public APIs.The
RestCapabilities
response currently provides the TileDB core version deployed to REST, and the minimum TileDB core client version supported by the REST server. The response may be updated in the future to add more information as needed - discussion in shortcut and design documentTYPE: FEATURE
DESC: Add endpoint for REST version and capabilities.