Skip to content

Conversation

@adev-code
Copy link
Contributor

@adev-code adev-code commented Oct 14, 2025

Currently, TCP Keep-Alive can be configured using Config object
and ~/.aws/config file as per Configuration Doc.
This PR adds environment variable support via BOTOCORE_TCP_KEEPALIVE.

Example Usage:
export BOTOCORE_TCP_KEEPALIVE=True or true
or
os.environ['BOTOCORE_TCP_KEEPALIVE'] = 'True' or 'true'

Addresses: #2268

@adev-code
Copy link
Contributor Author

Tests and Configuration Documentation edit will be added.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (8121342) to head (98e2bd8).
⚠️ Report is 41 commits behind head on develop.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3579      +/-   ##
===========================================
- Coverage    93.17%   93.15%   -0.02%     
===========================================
  Files           68       68              
  Lines        15411    15411              
===========================================
- Hits         14359    14356       -3     
- Misses        1052     1055       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adev-code
Copy link
Contributor Author

Created a PR for Doc change to add BOTOCORE_TCP_KEEPALIVE

boto/boto3#4642

@adev-code
Copy link
Contributor Author

Changelog added

Copy link
Contributor

@arandito arandito left a comment

Choose a reason for hiding this comment

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

Thanks for this PR Adrian!

I left two comments regarding backwards compatibility with the changes to _compute_socket_options and the testing bridge. Curious to see what Jonathan thinks.

Let's also make sure to merge this PR at the same time as the docs change in boto3.

service_name, region_name, endpoint_url, is_secure
)

def _compute_socket_options(self, scoped_config, client_config=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is a private API so it shouldn't be used by anyone, but are we confident this will not break any customers?

I did a quick search and it doesn't look like we use this elsewhere in our repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per checking our code, the _compute_socket_options is only used in return statement of the function get_client_args(). Before, the scoped_keepalive checks the config file. Now it is taking care of tcp_keepalive as it also checks the config file. I suppose this should not break as the functionality of scoped_keepalive is now covered by tcp_keepalive.

}
call_kwargs.update(**override_kwargs)

# Bridge test's scoped_config to config_store for new _compute_socket_options implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this bridge avoids modifying existing tests to keep backwards compatibility, but since we are breaking _compute_socket_options, it may make sense to refactor all the tcp keepalive tests to use config_store instead of scoped_config.

This can cause confusion for future developers that see a mismatch in what the functions accepts (which is only client_config) and what is used in tests (scoped_config). They may lack the historical context to understand why this bridge is necessary.

Other tests in this file useconfig_store.set_config_variable to set the config value, we should be able to use this here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that make sense. I will refactor (next commit) all the TCP keepalive tests to use config_store.set_config_variable() directly and removed the bridge entirely. The tests are now consistent with the rest and match what _compute_socket_options actually expects. Thanks for pointing this out as it may cause confusion in the future for developers.

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