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

AIP-157 Partial response implementation #717

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

sayan-biswas
Copy link
Contributor

@sayan-biswas sayan-biswas commented Feb 21, 2024

In the present implementation, a user cannot filter the data in the response message, a feature provided by modern API implementations. This is particularly needed for the List APIs as these APIs return the whole object in the list. In scenario where the list and object definition are big, there's a lot network bandwidth wasted because the response of the List API is mostly used to display a list of resources and the Get API is then used to fetch the individual resource.
This feature provides an easy and basic way to filter the response message across all APIs, which reduces the size of the payload and hence allows faster transfer over network.

Changes

This feature add capabilities to filter the response message from across all APIs.
AIP detail:
https://google.aip.dev/157

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Tested your changes locally (if this is a code change)
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user-facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contain the string "action required" if the change requires additional action from users switching to the new release

Release Notes

API: Request message allows an additional parameter `fields` to filter the response message.

@sayan-biswas sayan-biswas added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 21, 2024
@sayan-biswas sayan-biswas self-assigned this Feb 21, 2024
@tekton-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 21, 2024
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 21, 2024
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 28, 2024
@sayan-biswas sayan-biswas force-pushed the partial-response branch 2 times, most recently from 32027d4 to 08b524b Compare February 28, 2024 19:57
@sayan-biswas
Copy link
Contributor Author

/test all

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
internal/fieldmask/fieldmask.go Do not exist 70.1%

@sayan-biswas sayan-biswas marked this pull request as ready for review February 28, 2024 20:45
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 28, 2024
@sayan-biswas
Copy link
Contributor Author

/test all

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
internal/fieldmask/fieldmask.go Do not exist 70.1%

@sayan-biswas
Copy link
Contributor Author

/test pull-tekton-results-integration-tests

1 similar comment
@sayan-biswas
Copy link
Contributor Author

/test pull-tekton-results-integration-tests

Copy link
Contributor

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

finally got around to taking a pass at this @sayan-biswas

of course, being brand new / a novice to all this, consider that perspective when reviewing my feedback ;-)

mask := make(FieldMask)
for _, path := range paths {
current := mask
fields := strings.Split(path, ".")
Copy link
Contributor

Choose a reason for hiding this comment

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

put a comment above this split with some sample paths to illustrate why we are splitting on .

Copy link
Contributor

Choose a reason for hiding this comment

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

let's not make the coder have to do up to your README change to undersatand what is going on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added reference and an example in godoc format.

Copy link
Contributor

Choose a reason for hiding this comment

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

awesome thanks

cmd/api/main.go Outdated
@@ -169,6 +171,7 @@ func main() {
grpc_zap.UnaryServerInterceptor(grpcLogger, zapOpts...),
grpc_auth.UnaryServerInterceptor(determineAuth),
prometheus.UnaryServerInterceptor,
fieldmask.UnaryServerInterceptor(),
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we have a feature enablement check of some sort ? presumably a client could send the extra headers or encoded data and it is OK to ignore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a feature flag implementation to handle all features control.

Copy link
Contributor

Choose a reason for hiding this comment

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

feature gate looks good @sayan-biswas good think .... in looking at it though I raised some questions around changes you made to my recently added tuning options

I'll submit a separate review for those

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
internal/fieldmask/fieldmask.go Do not exist 70.1%

@sayan-biswas sayan-biswas force-pushed the partial-response branch 2 times, most recently from 0acbbac to 840e4cc Compare May 2, 2024 22:40
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 9.3% 9.1% -0.2
internal/fieldmask/fieldmask.go Do not exist 70.1%
pkg/api/server/config/config.go Do not exist 0.0%
pkg/api/server/config/config.go Do not exist 0.0%
pkg/api/server/features/features.go Do not exist 85.3%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/config/config.go Do not exist 0.0%
pkg/api/server/config/config.go Do not exist 0.0%
pkg/api/server/features/features.go Do not exist 85.3%

@khrm khrm force-pushed the partial-response branch 2 times, most recently from f383686 to ee9cd28 Compare February 19, 2025 06:50
@khrm
Copy link
Contributor

khrm commented Feb 19, 2025

/assign @enarha

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/features/features.go Do not exist 85.3%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/features/features.go Do not exist 85.3%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/features/features.go Do not exist 85.3%

@khrm
Copy link
Contributor

khrm commented Feb 19, 2025

/test pull-tekton-results-unit-tests

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/features/features.go Do not exist 85.3%

@khrm
Copy link
Contributor

khrm commented Feb 20, 2025

/hold retesting this after rebase.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 20, 2025
khrm and others added 3 commits February 20, 2025 16:34
This feature add capabilities to filter the response message from all the APIs.
AIP detail:
https://google.aip.dev/157

Co-authored-by: Sayan Biswas <[email protected]>
This sets the protojson marshaller to omit the empty fields.
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-results-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/api/main.go 8.4% 8.3% -0.2
internal/fieldmask/fieldmask.go Do not exist 67.9%
pkg/api/server/features/features.go Do not exist 85.3%

@khrm
Copy link
Contributor

khrm commented Feb 20, 2025

/hold cancel

Tested this. It's working fine.

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 20, 2025
@enarha
Copy link
Contributor

enarha commented Feb 20, 2025

/approve

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enarha

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 20, 2025
Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2025
@tekton-robot tekton-robot merged commit f4a98d7 into tektoncd:main Feb 20, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants