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

Introduce crt imds client. #184

Merged
merged 1 commit into from
Apr 4, 2023
Merged

Introduce crt imds client. #184

merged 1 commit into from
Apr 4, 2023

Conversation

eslrahc-swa
Copy link
Contributor

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).

@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests March 28, 2023 22:23 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests March 28, 2023 22:23 — with GitHub Actions Failure
Copy link
Contributor

@monthonk monthonk left a 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.

.gitignore Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
}

/// 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>> {
Copy link
Contributor

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.

Copy link
Contributor Author

@eslrahc-swa eslrahc-swa Mar 31, 2023

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.

Copy link
Contributor

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>> {
Copy link
Contributor

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?

Copy link
Contributor

@dannycjones dannycjones left a 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.

.gitignore Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
}

/// 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>> {
Copy link
Contributor

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. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@dannycjones dannycjones Mar 31, 2023

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.

mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
@dannycjones
Copy link
Contributor

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.

mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests March 31, 2023 19:06 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests March 31, 2023 19:06 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests March 31, 2023 19:06 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:15 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:15 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:15 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:16 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:16 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 03:16 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:30 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:30 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:30 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:32 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:32 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 2, 2023 20:32 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 2, 2023 20:36 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 3, 2023 20:14 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 3, 2023 20:14 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 22:46 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 22:46 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 22:46 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:09 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:09 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:21 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:21 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:21 — with GitHub Actions Failure
@awslabs awslabs deleted a comment from monthonk Apr 3, 2023
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:53 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:53 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa had a problem deploying to PR integration tests April 3, 2023 23:53 — with GitHub Actions Failure
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 00:04 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 00:04 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 00:04 — with GitHub Actions Inactive
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-crt/src/auth/imds_client.rs Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
mountpoint-s3/src/main.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Outdated Show resolved Hide resolved
mountpoint-s3-client/src/imds_crt_client.rs Show resolved Hide resolved
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>
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 01:24 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 01:24 — with GitHub Actions Inactive
@eslrahc-swa eslrahc-swa temporarily deployed to PR integration tests April 4, 2023 01:24 — with GitHub Actions Inactive
@jamesbornholt jamesbornholt enabled auto-merge (squash) April 4, 2023 01:29
@jamesbornholt jamesbornholt merged commit 2fade8b into awslabs:main Apr 4, 2023
@dannycjones
Copy link
Contributor

Nice work!

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.

Auto-configure Network Interface Card (NIC) throughput
4 participants