-
Notifications
You must be signed in to change notification settings - Fork 342
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
inventory/aws_ec2: allow multi-entries for one host #1026
inventory/aws_ec2: allow multi-entries for one host #1026
Conversation
Docs Build 📝Thank you for contribution!✨ This PR has been merged and your docs changes will be incorporated when they are next published. |
…ns#1026) Add AWSRetry.jittered_backoff to rds_instance_info SUMMARY Add AWSRetry.jittered_backoff to the rds_instance_info module. When calling rds_instance_info we have been seeing API rate limit errors from AWS. When calling this module, it usually runs to about 90-150 times in a minute before we get rate limited. Using jittered_backoff should significantly decrease the number of times we see API rate limits here. 02:20:36 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded 02:20:36 fatal: [polaris -> localhost]: FAILED! => {"boto3_version": "1.20.22", "botocore_version": "1.23.22", "changed": false, "error": {"code": "Throttling", "message": "Rate exceeded", "type": "Sender"}, "msg": "Couldn't get instance information: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded", "response_metadata": {"http_headers": {"connection": "close", "content-length": "254", "content-type": "text/xml", "date": "Tue, 15 Mar 2022 09:20:34 GMT", "x-amzn-requestid": "5de8131e-3f59-4b04-af25-5f7083ee09b9"}, "http_status_code": 400, "max_attempts_reached": true, "request_id": "5de8131e-3f59-4b04-af25-5f7083ee09b9", "retry_attempts": 4}} ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance_info ADDITIONAL INFORMATION Decorated rds_instance_info with AWSRetry.jittered_backoff Reviewed-by: Mark Woolley <mw@marknet15.com> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@6a2793a
8a374f2
to
9ffb35a
Compare
71e22b6
to
299fd6c
Compare
299fd6c
to
3c26253
Compare
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.
@goneri Could you also please update the documentation with this option https://github.com/ansible-collections/amazon.aws/blob/main/docs/docsite/rst/aws_ec2_guide.rst ?
…ns#1026) Add AWSRetry.jittered_backoff to rds_instance_info SUMMARY Add AWSRetry.jittered_backoff to the rds_instance_info module. When calling rds_instance_info we have been seeing API rate limit errors from AWS. When calling this module, it usually runs to about 90-150 times in a minute before we get rate limited. Using jittered_backoff should significantly decrease the number of times we see API rate limits here. 02:20:36 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded 02:20:36 fatal: [polaris -> localhost]: FAILED! => {"boto3_version": "1.20.22", "botocore_version": "1.23.22", "changed": false, "error": {"code": "Throttling", "message": "Rate exceeded", "type": "Sender"}, "msg": "Couldn't get instance information: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded", "response_metadata": {"http_headers": {"connection": "close", "content-length": "254", "content-type": "text/xml", "date": "Tue, 15 Mar 2022 09:20:34 GMT", "x-amzn-requestid": "5de8131e-3f59-4b04-af25-5f7083ee09b9"}, "http_status_code": 400, "max_attempts_reached": true, "request_id": "5de8131e-3f59-4b04-af25-5f7083ee09b9", "retry_attempts": 4}} ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance_info ADDITIONAL INFORMATION Decorated rds_instance_info with AWSRetry.jittered_backoff Reviewed-by: Mark Woolley <mw@marknet15.com> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@6a2793a
recheck |
2537a21
to
510d80f
Compare
Add an option to allow multiple duplicated entry for on single instance. Closes: ansible-collections#950
This can happen is a host is found but doesnt match any of the `hostnames` rules.
510d80f
to
a200eee
Compare
@@ -176,6 +184,9 @@ | |||
separator: '-' # Hostname will be aws-test_literal | |||
prefix: 'aws' | |||
|
|||
# Returns all the hostnames for a given instance | |||
allow_duplicated_hosts: False |
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.
allow_duplicated_hosts: False | |
allow_duplicated_hosts: True |
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.
My understanding was the the new behaviour is a bug and we would like to switch back to what we had in 4.0.0.
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 fix in this PR #862 should do this (that is how it should be, it's not a bug really).
- Fix returned hosts when
hostnames:
- tag:Tag1,Tag2
- Fix returned hosts when
hostnames:
- tag:Tag1
- tag:Tag2
- Fix returned hosts when
hostnames:
- tag:Tag1=Test1,Tag2=Test2
Given and EC2 instance with the following tags
tags:
Tag1: Test1
Tag2: Test2
Instead of only returning
"aws_ec2": {
"hosts": [
"Test1"
]
},
"tag_Name_instance_02": {
"hosts": [
"Test1"
]
},
"tag_Tag1_Test1": {
"hosts": [
"Test1"
]
},
"tag_Tag2_Test2": {
"hosts": [
"Test1"
]
}
It returns now
{
"_meta": {
"hostvars": {
"Test1": {
"ami_launch_index": 0,
"ansible_host": "10.210.0.101",
...},
"Test2": {
"ami_launch_index": 0,
"ansible_host": "10.210.0.101",
...},
},
"all": {
"children": [
"aws_ec2",
"tag_Name_instance_02",
"tag_Tag1_Test1",
"tag_Tag2_Test2",
"ungrouped"
]
},
"aws_ec2": {
"hosts": [
"Test1",
"Test2"
]
},
"tag_Name_instance_02": {
"hosts": [
"Test1",
"Test2"
]
},
"tag_Tag1_Test1": {
"hosts": [
"Test1",
"Test2"
]
},
"tag_Tag2_Test2": {
"hosts": [
"Test1",
"Test2"
]
}
}
The problem is it altered the way the hosts were returned introducing a breaking change for the users unfortunately. So, for some users this behaviour is useful while for some others it is not. What about @tremble's suggestion here #862 (comment) ?
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 PR implements what @markuman describe here #862 (comment)
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.
I might just be confused. I would expect allow_duplicated_hosts: False
to only return unique names. And I would expect what markuman suggested (unique_hostnames: true
) to do the same thing.
In this example the comment reads:
# Returns all the hostnames for a given instance
But the example parameter is allow_duplicated_hosts: False
- which I think would not return "all" hostnames, because it would only return unique / non-duplicate names.
Is my logic wrong?
This comment was marked as resolved.
This comment was marked as resolved.
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.
Left one comment, otherwise, lgtm! Thank you @goneri
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 code LGTM, just a little confused on the naming and default value. Thanks @goneri!
…ns#1026) Add AWSRetry.jittered_backoff to rds_instance_info SUMMARY Add AWSRetry.jittered_backoff to the rds_instance_info module. When calling rds_instance_info we have been seeing API rate limit errors from AWS. When calling this module, it usually runs to about 90-150 times in a minute before we get rate limited. Using jittered_backoff should significantly decrease the number of times we see API rate limits here. 02:20:36 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded 02:20:36 fatal: [polaris -> localhost]: FAILED! => {"boto3_version": "1.20.22", "botocore_version": "1.23.22", "changed": false, "error": {"code": "Throttling", "message": "Rate exceeded", "type": "Sender"}, "msg": "Couldn't get instance information: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded", "response_metadata": {"http_headers": {"connection": "close", "content-length": "254", "content-type": "text/xml", "date": "Tue, 15 Mar 2022 09:20:34 GMT", "x-amzn-requestid": "5de8131e-3f59-4b04-af25-5f7083ee09b9"}, "http_status_code": 400, "max_attempts_reached": true, "request_id": "5de8131e-3f59-4b04-af25-5f7083ee09b9", "retry_attempts": 4}} ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance_info ADDITIONAL INFORMATION Decorated rds_instance_info with AWSRetry.jittered_backoff Reviewed-by: Mark Woolley <mw@marknet15.com> Reviewed-by: Mark Chappell <None>
…ns#1026) Add AWSRetry.jittered_backoff to rds_instance_info SUMMARY Add AWSRetry.jittered_backoff to the rds_instance_info module. When calling rds_instance_info we have been seeing API rate limit errors from AWS. When calling this module, it usually runs to about 90-150 times in a minute before we get rate limited. Using jittered_backoff should significantly decrease the number of times we see API rate limits here. 02:20:36 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded 02:20:36 fatal: [polaris -> localhost]: FAILED! => {"boto3_version": "1.20.22", "botocore_version": "1.23.22", "changed": false, "error": {"code": "Throttling", "message": "Rate exceeded", "type": "Sender"}, "msg": "Couldn't get instance information: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded", "response_metadata": {"http_headers": {"connection": "close", "content-length": "254", "content-type": "text/xml", "date": "Tue, 15 Mar 2022 09:20:34 GMT", "x-amzn-requestid": "5de8131e-3f59-4b04-af25-5f7083ee09b9"}, "http_status_code": 400, "max_attempts_reached": true, "request_id": "5de8131e-3f59-4b04-af25-5f7083ee09b9", "retry_attempts": 4}} ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance_info ADDITIONAL INFORMATION Decorated rds_instance_info with AWSRetry.jittered_backoff Reviewed-by: Mark Woolley <mw@marknet15.com> Reviewed-by: Mark Chappell <None>
…ns#1026) Add AWSRetry.jittered_backoff to rds_instance_info SUMMARY Add AWSRetry.jittered_backoff to the rds_instance_info module. When calling rds_instance_info we have been seeing API rate limit errors from AWS. When calling this module, it usually runs to about 90-150 times in a minute before we get rate limited. Using jittered_backoff should significantly decrease the number of times we see API rate limits here. 02:20:36 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded 02:20:36 fatal: [polaris -> localhost]: FAILED! => {"boto3_version": "1.20.22", "botocore_version": "1.23.22", "changed": false, "error": {"code": "Throttling", "message": "Rate exceeded", "type": "Sender"}, "msg": "Couldn't get instance information: An error occurred (Throttling) when calling the DescribeDBInstances operation (reached max retries: 4): Rate exceeded", "response_metadata": {"http_headers": {"connection": "close", "content-length": "254", "content-type": "text/xml", "date": "Tue, 15 Mar 2022 09:20:34 GMT", "x-amzn-requestid": "5de8131e-3f59-4b04-af25-5f7083ee09b9"}, "http_status_code": 400, "max_attempts_reached": true, "request_id": "5de8131e-3f59-4b04-af25-5f7083ee09b9", "retry_attempts": 4}} ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance_info ADDITIONAL INFORMATION Decorated rds_instance_info with AWSRetry.jittered_backoff Reviewed-by: Mark Woolley <mw@marknet15.com> Reviewed-by: Mark Chappell <None>
Depends-On: #1066
Add an option to allow multiple duplicated entries for one single instance.
Closes: #950