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

Add a StopPaginationOnSameToken customization to CloudWatchLogs.GetLogEvents operation #3296

Conversation

muhammad-othman
Copy link
Member

@muhammad-othman muhammad-othman commented Apr 24, 2024

Description

This PR fixes DOTNET-7441 by adding StopPaginationOnSameToken flag to Operation customizations in the generator and adds this flag to CloudWatchLogs.GetLogEvents operation customization.

Motivation and Context

CloudWatchLogs.GetLogEvents operation response includes two pagination tokens (NextBackwardToken and NextForwardToken), but they won't be null once all events are retrieved (instead, CloudWatch will return the same value sent in the request)
This means the .NET paginator (which is generated from the model to keep invoking the API until the response token is empty) enters an infinite loop as the NextForwardToken will never be null.
Additionally this issue was opened #3218 and we couldn't advise to use the paginator since it will enter an infinite loop.

This PR contains the following commits to fix this issue:

Testing

  • Created a console app to test GetLogEvents pagination with a long and a short LogStream and validated that it the pagination stops when it reaches the end of the stream.
  • Updated GetLogEventsTest_TwoResponses test to reflect the service response.
  • Did a full dry run DRY_RUN-36b366d9-c447-45f7-8764-df58b7cb716a.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@muhammad-othman muhammad-othman force-pushed the muhamoth/DOTNET-7441-CloudWatchLogs-GetLogEvents-does-not-return-any-event branch from d7bf7b6 to 414e885 Compare April 24, 2024 21:17
@@ -70,7 +70,7 @@ IEnumerable<GetLogEventsResponse> IPaginator<GetLogEventsResponse>.Paginate()
nextToken = response.NextForwardToken;
yield return response;
}
while (!string.IsNullOrEmpty(nextToken));
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes look good, but can you double check if the other SDKs (Java / JS) do something different for NextBackwardToken? (asking because this API allows customers to paginate in both directions)

@muhammad-othman muhammad-othman merged commit 4c5667b into main-staging Apr 26, 2024
3 checks passed
@muhammad-othman muhammad-othman deleted the muhamoth/DOTNET-7441-CloudWatchLogs-GetLogEvents-does-not-return-any-event branch April 30, 2024 19:34
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