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

Validate Invalid Network Interface Names at Client Initialization #456

Merged
merged 13 commits into from
Oct 16, 2024

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented Oct 15, 2024

Description of changes:

  • If there are any typos in the network_interface_names, we can catch them at client initialization time instead of when we try to make a request and it fails due to timeout.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.68%. Comparing base (ab70f74) to head (f4fb728).

Files with missing lines Patch % Lines
source/s3_client.c 96.29% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
+ Coverage   89.30%   89.68%   +0.37%     
==========================================
  Files          20       20              
  Lines        6132     6144      +12     
==========================================
+ Hits         5476     5510      +34     
+ Misses        656      634      -22     
Files with missing lines Coverage Δ
source/s3_client.c 90.16% <96.29%> (+2.09%) ⬆️

@@ -352,6 +356,7 @@ struct aws_s3_client *aws_s3_client_new(
struct aws_s3_buffer_pool_usage_stats pool_usage = aws_s3_buffer_pool_get_usage(client->buffer_pool);

if (client_config->max_part_size > pool_usage.mem_limit) {
aws_s3_buffer_pool_destroy(client->buffer_pool);
Copy link
Contributor

Choose a reason for hiding this comment

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

trying to clean up behind yourself is hard in C
which is why we prefer the "goto error, cleanup everything" pattern,
and why our cleanup/destroy functions are the only ones that tolerate unexpected NULL args

This function already has 2 different "goto error" labels.
Now 1 of those labels you have to be careful to also cleanup a specific variable before you goto it. this is too fragile 😓

Seems better to completely remove the on_early_fail label from this function, and just always try to cleanup everything via goto on_error?

Another option: instead of the on_error: label sharing 90% the same cleanup code as s_s3_client_finish_destroy_default(), have them share code, and tolerate destroying a half-assembled client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have moved code around to get rid of on_early_fail.

Comment on lines 346 to 350
client->buffer_pool = aws_s3_buffer_pool_new(allocator, part_size, mem_limit);

if (client->buffer_pool == NULL) {
goto on_early_fail;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need to move any of this code around? Can we keep it where it was, and change goto on_early_fail -> goto on_error and call it a day?

Copy link
Contributor Author

@waahm7 waahm7 Oct 15, 2024

Choose a reason for hiding this comment

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

Yeah, like one issue is that we need to make sure we acquire the bootstrap reference before on_error, since on_error releases the reference. There might be other similar issues. Nevermind, we will release the client->bootstrap. Looking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated with a test.

@waahm7 waahm7 merged commit 45eee8d into main Oct 16, 2024
31 checks passed
@waahm7 waahm7 deleted the validate-interface-name-helper-api branch October 16, 2024 15:39
unexge added a commit to unexge/mountpoint-s3 that referenced this pull request Oct 17, 2024
CRT was returning error during first operation before if it provided
with a non-existent network interface name. But with
awslabs/aws-c-s3#456, it started failing
during the client creation phase. Our tests were written for the
previous behaviour and was expecting client creation to succeed even
with an invalid network interface. The test is updated to expect
errors during client creation.

Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>
github-merge-queue bot pushed a commit to awslabs/mountpoint-s3 that referenced this pull request Oct 17, 2024
* Update CRT submodules to latest releases

Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>

* Update non-existent network interface initialization test

CRT was returning error during first operation before if it provided
with a non-existent network interface name. But with
awslabs/aws-c-s3#456, it started failing
during the client creation phase. Our tests were written for the
previous behaviour and was expecting client creation to succeed even
with an invalid network interface. The test is updated to expect
errors during client creation.

Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>

* Update CHANGELOG

Co-authored-by: Monthon Klongklaew <monthonk@amazon.com>
Signed-off-by: Burak <unexge@gmail.com>

---------

Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>
Signed-off-by: Burak <unexge@gmail.com>
Co-authored-by: Monthon Klongklaew <monthonk@amazon.com>
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.

3 participants