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

[Internal] Update Jobs GetRun API to support paginated responses for jobs and ForEach tasks with >100 runs #1009

Closed
wants to merge 11 commits into from

Conversation

gkiko10
Copy link
Contributor

@gkiko10 gkiko10 commented Aug 7, 2024

Changes

Jobs GetRun 2.2 behind the scenes pagination

Tests

  • make test passing
  • make fmt applied
  • relevant integration tests applied

Copy link

@ricardoc-db ricardoc-db left a comment

Choose a reason for hiding this comment

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

Not a golang expert, but logic looks OK.

service/jobs/ext_api.go Show resolved Hide resolved
service/jobs/ext_api.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

First round of comments. Mostly looks good, my main feedback is about the tests/comments but the behavior seems OK. Were you able to manually test this?

@dvkuznietsov @gkiko10: I think we should think carefully about whether we want to include the non-paginated repeated fields that have a fixed value in every response (i.e. that the same JobClusters are returned in each GetRun request for different pages). This means that if you want to add pagination for any other fields in the response (like JobClusters), that would be a behavior change of your API, and we wouldn't be able to release the client code in the SDKs until that behavior change is released everywhere. Otherwise, those fields would contain a copy of the nested resources for each requested page (e.g. if there was 1 job cluster but five pages of tasks, the SDK would return a run with 5 job clusters). If we get this behavior right from the start, we can avoid this.

service/jobs/ext_api.go Outdated Show resolved Hide resolved
return nil, err
}

isPaginatingIterations := run.Iterations != nil && len(run.Iterations) > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

For posterity, it would be good to document this behavior, as it isn't immediately obvious how this works from the spec itself. Something like:

When querying a Job run, a page token is returned when there are more than 100 tasks. No iterations are defined for a Job run. Therefore, the next page in the response only includes the next page of tasks.
When querying a ForEach task run, a page token is returned when there are more than 100 iterations. Only a single task is returned, corresponding to the ForEach task itself. Therefore, the client only reads the iterations from the next page and not the tasks.
For any other task type, iterations is empty and tasks only contains the one task, so no pagination is needed.

service/jobs/ext_api_test.go Outdated Show resolved Hide resolved
Comment on lines 244 to 245
assert.Empty(t, run.NextPageToken)
assert.Empty(t, run.PrevPageToken)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not now, but longer-term, we may want to hide these fields from the SDK in general. cc @hectorcast-db @renaudhartert-db

},
},
},
//API 2.1 stubs
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these used in any test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current generated code of jobs/impl.go references 2.1 endpoints. Once the new docs are public they will reference 2.2 endpoint. The tests will not fail because they mock both 2.1 and 2.2

service/jobs/ext_api_test.go Outdated Show resolved Hide resolved
service/jobs/ext_api_test.go Show resolved Hide resolved
@mgyucht mgyucht changed the title [Internal] Add customization for GetRun [Internal] Update Jobs GetRun API to support paginated responses for jobs and ForEach tasks with >100 runs Aug 19, 2024
@mgyucht mgyucht enabled auto-merge August 19, 2024 07:29
@mgyucht mgyucht disabled auto-merge August 19, 2024 07:30
@renaudhartert-db renaudhartert-db removed their request for review September 23, 2024 08:52
Copy link

github-actions bot commented Nov 7, 2024

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-go

Inputs:

  • PR number: 1009
  • Commit SHA: c900fc2f0587735dad1d9eea136f1b352e5bf7b5

Checks will be approved automatically on success.

@eng-dev-ecosystem-bot
Copy link
Collaborator

Test Details: go/deco-tests/11730422764

@gkiko10
Copy link
Contributor Author

gkiko10 commented Nov 8, 2024

Closing in favour of #1089

@gkiko10 gkiko10 closed this Nov 8, 2024
auto-merge was automatically disabled November 8, 2024 14:02

Pull request was closed

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.

7 participants