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

Fix unused proto import warnings in api #13401

Merged
merged 1 commit into from
Feb 4, 2021

Conversation

cheister
Copy link
Contributor

@cheister cheister commented Oct 6, 2020

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Commit Message: api: fix unused proto import warnings
Additional Description: Fixing "warning: Import ... but not used" warnings from protoc
Risk Level: Low
Testing: manually built protos
Docs Changes: None
Release Notes: None

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy[\w/]*/(v1alpha\d?|v1|v2alpha\d?|v2))|(api/envoy/type/(matcher/)?\w+.proto).
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #13401 was opened by cheister.

see: more, trace.

@rojkov
Copy link
Member

rojkov commented Oct 6, 2020

To fix the CI failure you need to generate the API shadow with ./tools/proto_format/proto_format.sh fix first and include it in the PR with git add api/ generated_api_shadow/. Ideally after running the unit tests.

@phlax
Copy link
Member

phlax commented Oct 6, 2020

great @cheister i started to do this, but didnt get very far. (see #13284)

ill close my PR in favour of yours

it might be a bit more complex than it first seems, i hit some errors removing some of the imports, but i might just have been a bit sloppy about how i did it. It will be good to see if tests pass

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks great. Please follow the advice in the comments to fix format. Also, I think it would be great having a CI check to ensure that we don't regress after these improvements. Would you be able to add this or maybe just file an issue if you don't have cycles? Thanks.
/wait

@cheister
Copy link
Contributor Author

cheister commented Oct 7, 2020

Thanks, I didn't know about ./tools/proto_format/proto_format.sh fix, I just ran this and updated the PR.

@cheister
Copy link
Contributor Author

cheister commented Oct 7, 2020

A CI check would be nice. The easiest thing would be protocolbuffers/protobuf#3980 if it was done. I probably won't have any time soon to write something for CI.

@cheister cheister force-pushed the fix-proto-import-warnings branch from 7935e21 to 9d2a198 Compare October 7, 2020 04:28
@cheister
Copy link
Contributor Author

cheister commented Oct 7, 2020

I can't tell if this error is related to this PR or not?

bazel-out/k8-opt/bin/source/extensions/filters/http/grpc_json_transcoder/_virtual_includes/json_transcoder_filter_lib/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h:120:55: error: no member named 'api' in namespace 'google'
                                        const google::api::HttpRule& http_rule,
                                              ~~~~~~~~^
1 error generated.

@phlax
Copy link
Member

phlax commented Oct 7, 2020

I can't tell if this error is related to this PR or not?

i hit similar problems - ie errors that were hard to track - so i started removing the lines one by one - which was why it was taking so long

@github-actions
Copy link

github-actions bot commented Dec 9, 2020

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 9, 2020
@mattklein123 mattklein123 removed the stale stalebot believes this issue/PR has not been touched recently label Dec 9, 2020
@htuch
Copy link
Member

htuch commented Dec 9, 2020

@cheister anything we can do to unblock?

@mattklein123 mattklein123 assigned mattklein123 and unassigned htuch Dec 18, 2020
Base automatically changed from master to main January 15, 2021 23:01
@cheister
Copy link
Contributor Author

So I started looking at this again and now I'm getting an error when I try to run

FORCE_PROTO_FORMAT=yes ./tools/proto_format/proto_format.sh fix

on the latest main branch. It fails when it runs

bazel build --remote_download_outputs=all --//tools/api_proto_plugin:default_type_db_target=@envoy_api_canonical//versioning:active_protos @envoy_api_canonical//versioning:active_protos --aspects //tools/protoxform:protoxform.bzl%protoxform_aspect --output_groups=proto

and gives the error

  File "/Users/cheister/.cache/bazel/9d68f171b1e2407d88fb2358d1b40dce/sandbox/darwin-sandbox/662/execroot/envoy/bazel-out/darwin-opt-exec-2B5CBBC6/bin/tools/protoxform/protoxform.runfiles/envoy/tools/protoxform/migrate.py", line 14, in <module>
    from google.api import annotations_pb2
ModuleNotFoundError: No module named 'google.api'
--api_proto_plugin_out: protoc-gen-api_proto_plugin: Plugin failed with status code 1.
Aspect //tools/protoxform:protoxform.bzl%protoxform_aspect of @envoy_api_canonical//versioning:active_protos failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.957s, Critical Path: 1.00s
INFO: 9 processes: 9 internal.
FAILED: Build did NOT complete successfully

I'm not sure why migrate.py can't find google.api since @com_google_googleapis//google/api:annotations_py_proto is a dependency of the protoxform py_binary in tools/protoxform/BUILD

@cheister cheister force-pushed the fix-proto-import-warnings branch from 9d2a198 to b5229bb Compare January 19, 2021 06:54
@cheister cheister force-pushed the fix-proto-import-warnings branch from b5229bb to 02caf59 Compare January 19, 2021 06:56
@mattklein123
Copy link
Member

Sorry no idea about the build error. cc @htuch @adisuissa @lizan

/wait

@htuch
Copy link
Member

htuch commented Jan 20, 2021

@cheister this works fine for me on latest main. I'm not sure if there is some strange artifact of being on Mac OS for you or the local environment. Does ./ci/run_envoy_docker.sh 'FORCE_PROTO_FORMAT=yes ./ci/do_ci.sh check_format' work?

The other thing you might want to try is ensuring you are starting with a clean build cache, bazel clean --expunge.

@cheister cheister force-pushed the fix-proto-import-warnings branch from 02caf59 to 9e5efed Compare January 21, 2021 07:25
@cheister cheister force-pushed the fix-proto-import-warnings branch 4 times, most recently from bb6f218 to 1ae5185 Compare February 1, 2021 21:46
@cheister cheister requested a review from lizan as a code owner February 1, 2021 21:46
Signed-off-by: Chris Heisterkamp <[email protected]>
@cheister cheister force-pushed the fix-proto-import-warnings branch from 1ae5185 to 18c522e Compare February 1, 2021 22:24
@cheister
Copy link
Contributor Author

cheister commented Feb 2, 2021

@htuch Do you mind taking a look at the test failure?

FAIL: //test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test (see /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/execroot/envoy/bazel-out/k8-fastbuild/testlogs/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test/test.log)
INFO: From Testing //test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test:
stdout (/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/execroot/envoy/bazel-out/_tmp/actions/stdout-23732) exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping
[19,673 / 20,472] 459 / 723 tests, 1 failed; Testing //test/extensions/filters/http/grpc_web:grpc_web_integration_test; 64s remote-cache, processwrapper-sandbox ... (58 actions running)

I don't know how to access the test log from CI. Is there a link I'm missing?
Locally bazel test //test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test fails for me with

Executing tests from //test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test
-----------------------------------------------------------------------------
dyld: Symbol not found: _program_invocation_name
  Referenced from: /private/var/tmp/_bazel_square/c17d6315d705aff163f0d9a22306271d/sandbox/darwin-sandbox/2023/execroot/envoy/bazel-out/darwin-fastbuild/bin/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.runfiles/envoy/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test
  Expected in: flat namespace
 in /private/var/tmp/_bazel_square/c17d6315d705aff163f0d9a22306271d/sandbox/darwin-sandbox/2023/execroot/envoy/bazel-out/darwin-fastbuild/bin/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.runfiles/envoy/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test

but passes if I add char *program_invocation_name; to test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc. I assume this is related to #10478 since I'm on a Mac locally. I'm not sure if that is the same error that CI is getting though.

@mattklein123 mattklein123 assigned htuch and unassigned mattklein123 Feb 2, 2021
@htuch
Copy link
Member

htuch commented Feb 3, 2021

Not sure, I kicked the job again, could be a flake. I don't think I can help much with Mac OS specific link issues, best to work through the existing issue.

@@ -37,8 +37,23 @@ def AdjustReservedRange(target_proto, previous_reserved_range, skip_reserved_num
target_proto.reserved_range.add().MergeFrom(rr)


# Add dependencies for envoy.annotations.disallowed_by_default
def AddDeprecationDependencies(target_proto_dependencies, proto_field, is_enum):
Copy link
Member

Choose a reason for hiding this comment

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

Why is this part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is needed when the shadow proto brings a deprecated field that uses envoy.annotations.disallowed_by_default and the original proto does include the import for envoy/annotations/deprecation.proto.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. What about the struct.proto below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

struct.proto was needed when the merge shadow added something like

  map<string, google.protobuf.Struct> hidden_envoy_deprecated_per_filter_config = 12
      [deprecated = true];

e.g. from api/envoy/config/route/v3/route_components.proto to generated_api_shadow/envoy/config/route/v3/route_components.proto and struct was not already in the imports.

@cheister
Copy link
Contributor Author

cheister commented Feb 4, 2021

Looks like on the rerun that FAIL: //test/integration:health_check_integration_test failed and //test/extensions/filters/http/grpc_json_transcoder:grpc_json_transcoder_integration_test PASSED in 84.2s, Can you run them again? Seems like maybe there are two flaky tests?

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! I kicked the tests, I think this failure is unrelated.

@@ -37,8 +37,23 @@ def AdjustReservedRange(target_proto, previous_reserved_range, skip_reserved_num
target_proto.reserved_range.add().MergeFrom(rr)


# Add dependencies for envoy.annotations.disallowed_by_default
def AddDeprecationDependencies(target_proto_dependencies, proto_field, is_enum):
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. What about the struct.proto below?

@repokitteh-read-only repokitteh-read-only bot removed the api label Feb 4, 2021
@htuch
Copy link
Member

htuch commented Feb 4, 2021

/lgtm v2-freeze

@htuch htuch merged commit 209b8f9 into envoyproxy:main Feb 4, 2021
@cheister cheister deleted the fix-proto-import-warnings branch February 5, 2021 00:14
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.

5 participants