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

Test access points #1

Open
wants to merge 93 commits into
base: accessPointTest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
1ce21df
Implement forget (#359)
passaro Jul 7, 2023
ed542e7
Add some tests for UTF-8 filenames (#362)
jamesbornholt Jul 9, 2023
5feb0e5
Update CRT submodules to latest releases (#365)
passaro Jul 10, 2023
b6493af
Remove closed issue warnings (#366)
dannycjones Jul 11, 2023
a516cc8
Introduce release workflow. (#356)
eslrahc-swa Jul 12, 2023
862625f
Disable new `items_after_test_module` Clippy lint (#372)
jamesbornholt Jul 13, 2023
caeff99
Add unlink to reference model tests (#368)
jamesbornholt Jul 13, 2023
146b9d3
Remove checksum feature from the workflow (#379)
monthonk Jul 14, 2023
d335a48
Remove the temporary checksum feature (#378)
monthonk Jul 14, 2023
7be6f2f
Compute checksums on write and compare with trailing checksums (#367)
passaro Jul 14, 2023
8d44b12
Allow omitting commit hash from version when specified as official re…
dannycjones Jul 14, 2023
6e2551a
Disable logging to file by default (#373)
dannycjones Jul 14, 2023
3a1db05
Fix merge conflict (#381)
jamesbornholt Jul 14, 2023
1c2ba5b
Tweak some of the CLI help text (#382)
jamesbornholt Jul 17, 2023
0efc380
Support open with O_RDWR flag (#370)
monthonk Jul 17, 2023
6d03df1
Adds region in tests (#375)
ahmarsuhail Jul 17, 2023
5a3aa4c
Fix missing feature in CI (#385)
jamesbornholt Jul 17, 2023
839ccfd
Remove inodes from their parent in `forget` (#380)
jamesbornholt Jul 17, 2023
d0ef0b9
Report current file size during writes (#384)
monthonk Jul 18, 2023
4f8cf0b
Reconcile remote and existing inodes at `update` time (#386)
jamesbornholt Jul 19, 2023
9d09e1e
Add detailed CRT metrics and tweak per-request logging (#390)
jamesbornholt Jul 19, 2023
5364fcc
Maintain metadata checksums and verify on unlink (#388)
passaro Jul 20, 2023
7786053
Add merge_group as workflow trigger for tests and integ tests (#392)
dannycjones Jul 20, 2023
ef35149
Fix sequential write test with O_RDWR flag (#393)
passaro Jul 20, 2023
6a717f9
Add always-successful workflow for DCO on merge_group event only (#397)
dannycjones Jul 20, 2023
7bbc21a
Emit warning-level logs to syslog when log directory is unset (#387)
jamesbornholt Jul 20, 2023
8efeaa8
Remove IMDS call for instance throughput when IMDS is disabled (#394)
dannycjones Jul 20, 2023
183a20c
Implement setattr to support changing time attributes (#391)
monthonk Jul 21, 2023
bb0f479
Introduce option to allow delete (#398)
passaro Jul 21, 2023
d3a8d05
Remove delete feature (#399)
passaro Jul 21, 2023
ed61a21
Refactor Dockerfile and update README (#402)
dprestegard Jul 24, 2023
c90fe48
Update inode status on fsync or write failure (#395)
passaro Jul 24, 2023
39ec6d6
Invalidate inodes when the remote object changes (#401)
jamesbornholt Jul 24, 2023
33fe81f
Bump some dependencies to mostly remove `atty` (#403)
jamesbornholt Jul 24, 2023
147f0b3
Adds support for storage class in client (#406)
passaro Jul 25, 2023
c40ff34
Update CRT submodules to latest releases (#407)
dannycjones Jul 25, 2023
173e1c5
fs: refactor to use a structured error type (#405)
jamesbornholt Jul 25, 2023
c419a6e
Endpoint Resolver for each request (#396)
Jul 25, 2023
47d06c1
Fix region detection with specified region (#409)
jamesbornholt Jul 26, 2023
7dfc30c
Adds storage class (#400)
ahmarsuhail Jul 26, 2023
c1720bc
Add flags for logging configuration (#404)
jamesbornholt Jul 26, 2023
3832cca
fuse: log all operation failures (#408)
jamesbornholt Jul 26, 2023
c2bdecb
Add S3_SUBSESSION_IAM_ROLE environment variable (#412)
jamesbornholt Jul 26, 2023
54851a9
Add new subsession IAM role for auth integration tests (#410)
jamesbornholt Jul 26, 2023
df4087b
Use ListObjectsV2 instead of HeadBucket for region detection (#413)
jamesbornholt Jul 27, 2023
cfe1f39
Present flexible retrieval objects with 000 permissions (#414)
jamesbornholt Jul 27, 2023
d6b530f
Dynamically scale fuse threads (#411)
passaro Jul 28, 2023
9775eef
Map all HTTP 403 errors to S3RequestError::Forbidden (#419)
jamesbornholt Jul 29, 2023
0beb322
Fix clippy error on macOS (#421)
passaro Jul 31, 2023
a39424c
Revamp semantics documentation (#418)
jamesbornholt Jul 31, 2023
a0060db
Build infrastructure for release packages (#420)
jamesbornholt Aug 1, 2023
c61d0cb
Prepare release workflow (#424)
jamesbornholt Aug 2, 2023
1011086
Bump version of mountpoint-s3 to v0.4.0 (#425)
dannycjones Aug 2, 2023
ae18473
Use AWS_REGION and IMDS to determine region (#422)
passaro Aug 3, 2023
de2e9a2
Make inode-related errors more user-friendly (#416)
jamesbornholt Aug 3, 2023
ab7501a
Update network throughput (#426)
jamesbornholt Aug 3, 2023
eae8b4d
Print a message when mount succeeds (#427)
jamesbornholt Aug 3, 2023
014b9c7
Parse endpoint property of Auth Scheme from endpoint resolver (#423)
Aug 4, 2023
28f31ce
Change artifact names for aarch64 package (#431)
monthonk Aug 4, 2023
00ecc60
Bump version of mountpoint-s3 to v0.4.1 (#432)
monthonk Aug 4, 2023
59f2ebb
Build SigningConfig from AuthScheme for each request (#428)
passaro Aug 5, 2023
dd52165
Remove --fips command-line flag (#437)
passaro Aug 7, 2023
8728575
Document Mountpoint configuration options and defaults (#436)
jamesbornholt Aug 7, 2023
e106f62
Bump version of mountpoint-s3 to v1.0.0 (#438)
monthonk Aug 8, 2023
16a9857
Update README and INSTALL documentation for 1.0.0 release (#439)
jamesbornholt Aug 9, 2023
243c4df
decrease closed-channel log severity (#443)
jchorl Aug 10, 2023
b65eda8
Add an example using Mountpoint with PyTorch (#440)
jamesbornholt Aug 11, 2023
3ecc0ae
Update BENCHMARKING.md for GA release (#453)
dannycjones Aug 14, 2023
3380f0c
Increase credentials duration when assuming role for benchmark ci job…
monthonk Aug 16, 2023
4c49fdb
Improved Error message for Invalid Credential (#447)
Aug 16, 2023
35d23e9
Refactor metrics to have sharded shared state (#445)
jamesbornholt Aug 16, 2023
d74c745
Improve benchmark script (#458)
monthonk Aug 16, 2023
578f47f
Stub out unimplemented FUSE operations (#460)
jamesbornholt Aug 17, 2023
dd61aeb
Add new metrics for IO, handles, throughput (#461)
jamesbornholt Aug 18, 2023
5556377
Small docs fixes (#464)
jamesbornholt Aug 21, 2023
b9f7e91
Bump AWS SDKs to latest version (#476)
jamesbornholt Aug 23, 2023
6103a2f
Make allow_other and allow_root mutually exclusive (#475)
monthonk Aug 24, 2023
c7464d0
Fixes for Rust 1.72 (#479)
jamesbornholt Aug 25, 2023
a7e12ec
Updates encryption documentation for SSE-KMS, DSSE-KMS (#480)
ahmarsuhail Aug 25, 2023
f10dc5b
Bump aws-actions/configure-aws-credentials from 2 to 3 (#484)
dependabot[bot] Aug 28, 2023
09f556e
Support building with Clang 16 (#486)
lesserwhirls Aug 28, 2023
73a27c1
Small fixes for S3 on Outposts (#470)
jamesbornholt Aug 30, 2023
5626e20
Allow reading restored GFR/GDA objects (#434) (#467)
vladem Aug 30, 2023
5e8d834
Close input/output handles when running in background (#489)
jamesbornholt Aug 31, 2023
7643a22
Bump version of Mountpoint to v1.0.1 (#494)
Sep 1, 2023
cc7f31e
Update documentation for live editing use case (#491)
monthonk Sep 1, 2023
efb334d
Change release title in the workflow (#496)
monthonk Sep 1, 2023
534c3ed
Added Unreleased section in changelog (#497)
Sep 1, 2023
b632bbe
Use default thread config for benchmark (#504)
monthonk Sep 6, 2023
4db11ad
Cancel unused in-flight prefetch tasks (#505)
dannycjones Sep 6, 2023
57d1bd6
Added accesspoint variables in integration.yml (#508)
Sep 7, 2023
0a8bb28
Removed extra $ from environment variable for MRAP (#514)
Sep 13, 2023
84af192
Added accesspoint and transfer acceleration tests
Sep 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use AWS_REGION and IMDS to determine region (awslabs#422)
* Add support for AWS_REGION to determine region

Determine the region using the following sources (in order):
  * `--region` flag,
  * `AWS_REGION` environment variables,
  * default region (us-east-1).

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

* Add get_identity_document to the IMDS client

Extend the IMDS client to query the identity document of the current EC2 instance. The identity document is returned as a json response, which is parsed (using serde) to extract  the region and the instance type. The new `get_identity_document()` is tested by comparing its result to those obtained via the SDK.

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

* Use AWS_REGION and IMDS to determine region

Determine the region using the following sources (in order):
  * `--region` flag,
  * `AWS_REGION` environment variables,
  * EC2 instance region (using the IMDS client),
  * default region (us-east-1).

In order to avoid querying the IMDS twice, this change also refactors the retrieval of the instance type (used in the calculation of the maximum network throughput). The new type `InstanceInfo` will lazily query the IMDS client for both value if and when required.

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

* Move InstanceInfo into a separate module

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

* Refactor all region handling logic into get_region

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

* Remove unused methods in ImdsCrtClient and ImdsClient

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>

---------

Signed-off-by: Alessandro Passaro <alexpax@amazon.co.uk>
  • Loading branch information
passaro authored Aug 3, 2023
commit ae18473cf5668df8fd6e09b49b7a665464786b8b
37 changes: 19 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mountpoint-s3-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ thiserror = "1.0.34"
time = { version = "0.3.17", features = ["formatting", "parsing"] }
tracing = { version = "0.1.35", default-features = false, features = ["std", "log"] }
xmltree = "0.10.3"
serde_json = "1.0.104"

[dev-dependencies]
anyhow = { version = "1.0.64", features = ["backtrace"] }
Expand Down
66 changes: 39 additions & 27 deletions mountpoint-s3-client/src/imds_crt_client.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;

use futures::channel::oneshot;
use futures::Future;
use mountpoint_s3_crt::auth::imds_client::{ImdsClient, ImdsClientConfig};
use mountpoint_s3_crt::common::allocator::Allocator;
use mountpoint_s3_crt::common::error;
use mountpoint_s3_crt::io::channel_bootstrap::{ClientBootstrap, ClientBootstrapOptions};
use mountpoint_s3_crt::io::event_loop::EventLoopGroup;
use mountpoint_s3_crt::io::host_resolver::{HostResolver, HostResolverDefaultOptions};
use pin_project::pin_project;
use serde_json::Value;
use thiserror::Error;

#[derive(Debug)]
Expand Down Expand Up @@ -55,34 +50,47 @@ impl ImdsCrtClient {
})
}

/// Query the type of the EC2 instance this code is executed on.
pub fn make_instance_type_query(&self) -> Result<ImdsQueryRequest, ImdsQueryRequestError> {
/// Query the identity document of the EC2 instance this code is executed on.
pub async fn get_identity_document(&self) -> Result<IdentityDocument, ImdsQueryRequestError> {
const IDENTITY_DOCUMENT_PATH: &str = "/latest/dynamic/instance-identity/document";

let (tx, rx) = oneshot::channel();
self.imds_client.get_instance_type(move |result| {
let _ = tx.send(result.map_err(ImdsQueryRequestError::CrtError));
self.imds_client.get_resource(IDENTITY_DOCUMENT_PATH, move |result| {
let _ = tx.send(result);
})?;

Ok(ImdsQueryRequest { receiver: rx })
let json = match rx.await {
Ok(Ok(json)) => json,
Ok(Err(err)) => return Err(ImdsQueryRequestError::CrtError(err)),
Err(err) => return Err(ImdsQueryRequestError::InternalError(Box::new(err))),
};

let json = &json;
let parsed: Value =
serde_json::from_str(json).map_err(|_| ImdsQueryRequestError::InvalidResponse(json.to_owned()))?;
let instance_type = parsed
.get("instanceType")
.and_then(Value::as_str)
.ok_or_else(|| ImdsQueryRequestError::InvalidResponse(json.to_owned()))?
.to_owned();
let region = parsed
.get("region")
.and_then(Value::as_str)
.ok_or_else(|| ImdsQueryRequestError::InvalidResponse(json.to_owned()))?
.to_owned();

Ok(IdentityDocument { instance_type, region })
}
}

/// Information about an EC2 instance.
#[derive(Debug)]
#[pin_project]
/// ImdsQueryRequest is a data encapsulation wrapper for asnychronous instance metadata query.
pub struct ImdsQueryRequest {
#[pin]
receiver: oneshot::Receiver<Result<String, ImdsQueryRequestError>>,
}

impl Future for ImdsQueryRequest {
type Output = Result<String, ImdsQueryRequestError>;

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
this.receiver
.poll(cx)
.map(|result| result.unwrap_or_else(|err| Err(ImdsQueryRequestError::InternalError(Box::new(err)))))
}
pub struct IdentityDocument {
// TODO: Add more fields as required.
/// The instance type of the instance.
pub instance_type: String,
/// The Region in which the instance is running.
pub region: String,
}

/// ImdsQueryRequestError is returned by an asynchronous query.
Expand All @@ -95,4 +103,8 @@ pub enum ImdsQueryRequestError {
/// An internal error from within the AWS Common Runtime. The request may have been sent.
#[error("Unknown CRT error")]
CrtError(#[from] error::Error),

/// The response from Imds was not valid.
#[error("Invalid response from Imds: {0}")]
InvalidResponse(String),
}
2 changes: 1 addition & 1 deletion mountpoint-s3-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod s3_crt_client;
mod util;

pub use endpoint_config::{AddressingStyle, EndpointConfig};
pub use imds_crt_client::ImdsCrtClient;
pub use imds_crt_client::{IdentityDocument, ImdsCrtClient};
pub use object_client::*;
pub use s3_crt_client::head_bucket::HeadBucketError;
pub use s3_crt_client::{S3ClientAuthConfig, S3ClientConfig, S3CrtClient, S3RequestError};
Expand Down
33 changes: 33 additions & 0 deletions mountpoint-s3-client/tests/imds_crt_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::assert_eq;

use aws_config::imds::Client;
use mountpoint_s3_client::ImdsCrtClient;
use serde_json::Value;

#[tokio::test]
async fn test_get_identity_document() {
let sdk_client = Client::builder().build().await.unwrap();
match sdk_client.get("/latest/dynamic/instance-identity/document").await {
Ok(expected_json) => {
let expected_doc: Value = serde_json::from_str(&expected_json).unwrap();
let expected_region = expected_doc.get("region").unwrap().as_str().unwrap();
let expected_instance_type = expected_doc.get("instanceType").unwrap().as_str().unwrap();

let client = ImdsCrtClient::new().unwrap();
let identity_document = client
.get_identity_document()
.await
.expect("should return a valid document");

assert_eq!(identity_document.region, expected_region);
assert_eq!(identity_document.instance_type, expected_instance_type);
}
Err(_) => {
let client = ImdsCrtClient::new().unwrap();
let _ = client
.get_identity_document()
.await
.expect_err("should not return a valid document");
}
}
}
17 changes: 11 additions & 6 deletions mountpoint-s3-crt/src/auth/imds_client.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! A client for retrieving ec2 instance metadata.

use crate::auth::auth_library_init;
use crate::common::allocator::Allocator;
use crate::common::error::Error;
use crate::io::channel_bootstrap::ClientBootstrap;
use crate::io::retry_strategy::RetryStrategy;
use crate::CrtError;
use crate::{auth::auth_library_init, ToAwsByteCursor};
use mountpoint_s3_crt_sys::{
aws_byte_buf, aws_imds_client, aws_imds_client_get_instance_type, aws_imds_client_new, aws_imds_client_options,
aws_byte_buf, aws_imds_client, aws_imds_client_get_resource_async, aws_imds_client_new, aws_imds_client_options,
aws_imds_client_release,
};
use std::ptr::NonNull;
Expand Down Expand Up @@ -66,8 +66,8 @@ impl ImdsClient {
Ok(Self { inner })
}

/// Get the EC2 instance type.
pub fn get_instance_type<F>(&self, callback: F) -> Result<(), Error>
/// Get the value for the given resource path.
pub fn get_resource<F>(&self, resource_path: &str, callback: F) -> Result<(), Error>
where
F: FnOnce(Result<String, Error>) + 'static,
{
Expand All @@ -79,8 +79,13 @@ impl ImdsClient {
// SAFETY: `self.inner` is a valid `aws_imds_client`. `get_resource_callback_fn_ptr` is leaked by [Box::into_raw]
// and so will live until the `imds_client_get_resource_callback` function is invoked.
unsafe {
aws_imds_client_get_instance_type(self.inner.as_ptr(), get_resource_callback_fn_ptr, callback_raw_ptr)
.ok_or_last_error()
aws_imds_client_get_resource_async(
self.inner.as_ptr(),
resource_path.as_aws_byte_cursor(),
get_resource_callback_fn_ptr,
callback_raw_ptr,
)
.ok_or_last_error()
}
}
}
Expand Down
Loading