From 7d0334b029f1d739b012c44dfce024e9d94da8cf Mon Sep 17 00:00:00 2001 From: Sid Patel Date: Mon, 8 Jun 2020 17:45:22 -0400 Subject: [PATCH 1/3] fix: ansible kinesis stream paginated shards bug --- plugins/modules/kinesis_stream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/kinesis_stream.py b/plugins/modules/kinesis_stream.py index 51ca85ddc94..e41a5fa6460 100644 --- a/plugins/modules/kinesis_stream.py +++ b/plugins/modules/kinesis_stream.py @@ -362,6 +362,7 @@ def find_stream(client, stream_name, check_mode=False): ) shards.extend(results.pop('Shards')) has_more_shards = results['HasMoreShards'] + params['ExclusiveStartShardId'] = shards[-1]['ShardId'] results['Shards'] = shards num_closed_shards = len([s for s in shards if 'EndingSequenceNumber' in s['SequenceNumberRange']]) results['OpenShardsCount'] = len(shards) - num_closed_shards From 8db1a9d0373d6334dc0127dded167fc5be2698e1 Mon Sep 17 00:00:00 2001 From: Sid Patel Date: Tue, 16 Jun 2020 10:57:34 -0400 Subject: [PATCH 2/3] only set shardid params when more shards --- plugins/modules/kinesis_stream.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/kinesis_stream.py b/plugins/modules/kinesis_stream.py index e41a5fa6460..9ef1d040864 100644 --- a/plugins/modules/kinesis_stream.py +++ b/plugins/modules/kinesis_stream.py @@ -362,7 +362,8 @@ def find_stream(client, stream_name, check_mode=False): ) shards.extend(results.pop('Shards')) has_more_shards = results['HasMoreShards'] - params['ExclusiveStartShardId'] = shards[-1]['ShardId'] + if has_more_shards: + params['ExclusiveStartShardId'] = shards[-1]['ShardId'] results['Shards'] = shards num_closed_shards = len([s for s in shards if 'EndingSequenceNumber' in s['SequenceNumberRange']]) results['OpenShardsCount'] = len(shards) - num_closed_shards From d1e64dec219363042f755ecbdfb951ce6e5768e6 Mon Sep 17 00:00:00 2001 From: Sid Patel Date: Mon, 24 Aug 2020 15:06:17 -0400 Subject: [PATCH 3/3] add changelog fragment --- .../fragments/93-kinesis_stream-get-more-shards-resolve.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/93-kinesis_stream-get-more-shards-resolve.yml diff --git a/changelogs/fragments/93-kinesis_stream-get-more-shards-resolve.yml b/changelogs/fragments/93-kinesis_stream-get-more-shards-resolve.yml new file mode 100644 index 00000000000..84365d6ff15 --- /dev/null +++ b/changelogs/fragments/93-kinesis_stream-get-more-shards-resolve.yml @@ -0,0 +1,2 @@ +bugfixes: +- kinesis_stream - fixes issue where kinesis streams with > 100 shards get stuck in an infinite loop (https://github.com/ansible-collections/community.aws/pull/93)