-
Notifications
You must be signed in to change notification settings - Fork 167
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
Introduce crt imds client. #184
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.
Great work! left a few comments that I think we should address.
} | ||
|
||
/// Make an HTTP request using this IMDS client that invokes the given callbacks. | ||
pub fn make_instance_type_query(&self) -> oneshot::Receiver<Result<OsString, error::Error>> { |
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.
We probably want to map CRT error into something else likeImdsCrtClientError
before returning, so that whoever call this function don't have to know CRT types when they do error handling. Also, the result should be String
instead of OsString
.
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.
Also, the result should be String instead of OsString.
* will fix that.
However, I do not see the benefit of mapping mountpoint_s3_crt::common::error::Error
to other type of error given it's either success or failure with no other reason.
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 difference is that if we return mountpoint_s3_crt::common::error::Error
and we want to use it at higher level (mountpoint-s3) like using match
on the result, then we also have to add mountpoint_s3_crt
as a dependency instead of just mountpoint_s3_client
.
So, I would avoid having CRT types in the interface if possible.
} | ||
|
||
/// Make an HTTP request using this IMDS client that invokes the given callbacks. | ||
pub fn make_instance_type_query(&self) -> oneshot::Receiver<Result<OsString, error::Error>> { |
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.
Could we add some tests around this function?
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.
Nice! I have a few feedback.
} | ||
|
||
/// Make an HTTP request using this IMDS client that invokes the given callbacks. | ||
pub fn make_instance_type_query(&self) -> oneshot::Receiver<Result<OsString, error::Error>> { |
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.
Does this function signature make sense?
I would expect something that looks more like pub async fn get_instance_type(&self) -> Result<String, CrtError>
. No clue how to get there. :)
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.
This function should not be async
, just like s3_crt_client.rs -> fn make_meta_request<T: Send + 'static, E: Send + 'static>
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.
Hmmmm, I see. And we do use .await
later with this function. I will read into this a bit more again.
Maybe we considered this already: should we be using CRT for this or should we use a Rust-based HTTP client? CRT of course will make things easier in terms of how to use IMDS, but it does mean we have to put thought into the safety interacting with its C code. |
The main goal of using crt imds client is to query ec2 instance type mountpoint-s3 running on. Signed-off-by: Charles Zhang <zyaoshen@amazon.com>
Nice work! |
The main goal for using crt imds client is to query ec2 instance type mountpoint-s3 running on.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).