-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Refactor BackupItemAction to backupitemaction/v1 #4943
Refactor BackupItemAction to backupitemaction/v1 #4943
Conversation
@@ -1,6 +1,71 @@ | |||
// Code generated by protoc-gen-go. DO NOT EDIT. | |||
// source: DeleteItemAction.proto | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using a different version of protoc
with https://github.com/vmware-tanzu/velero/blob/main/hack/build-image/Dockerfile#L48 as there are some unexpected changes?
Please also update the version if the answer is yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywk253100 I just regenerated these via make update
and assuming the build-image dockerfile is the one used, the DeleteItemAction changes are the same for me as above. Perhaps it was something to do with the way the file was originally generated? Checking git history, the other generated plugin files have been modified more recently than this one. Perhaps something changed in a dependency somewhere along the way, or perhaps this particular file was generated manually instead of via make update
? In any case, running make update
right now on DeleteItemAction does result in these changes. I even removed my local protoc file just in case it was being used instead of the one in the Docker image, but the changes still came through.
hack/update-proto.sh
Outdated
@@ -18,6 +18,9 @@ HACK_DIR=$(dirname "${BASH_SOURCE}") | |||
|
|||
echo "Updating plugin proto" | |||
|
|||
protoc pkg/plugin/proto/backupitemaction/v1/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ -I pkg/plugin/proto/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out how to get the output files to generate properly. Replace the above line with this:
protoc pkg/plugin/proto/backupitemaction/v1/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ --go_opt=module=github.com/vmware-tanzu/velero/pkg/plugin/generated -I pkg/plugin/proto/
The required addition is --go_opt=module=github.com/vmware-tanzu/velero/pkg/plugin/generated
which tells protoc-gen-go to strip the module prefix from the go_package because we're already under the module root dir.
hack/update-proto.sh
Outdated
@@ -18,6 +18,9 @@ HACK_DIR=$(dirname "${BASH_SOURCE}") | |||
|
|||
echo "Updating plugin proto" | |||
|
|||
protoc pkg/plugin/proto/backupitemaction/v1/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ -I pkg/plugin/proto/ | |||
protoc pkg/plugin/proto/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ -I pkg/plugin/proto/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the above BIA code to generate properly locally, I had to add go_package to Shared.proto. For this protoc command to work on the other top level unversioned files, I needed that as well. Once added, the this protoc line needs the same --go_opt=module=github.com/vmware-tanzu/velero/pkg/plugin/generated
as the first one. The required go_package line to all files in pkg/plugin/generated
is this:
option go_package = "github.com/vmware-tanzu/velero/pkg/plugin/generated";
protoc pkg/plugin/proto/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ -I pkg/plugin/proto/ | ||
cp -rf pkg/plugin/generated/github.com/vmware-tanzu/velero/pkg/plugin/generated/* pkg/plugin/generated | ||
rm -rf pkg/plugin/generated/github.com | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the above changes, the cp
and rm
lines can be removed.
Verified on my environment according to @sseago comments. Need to |
Signed-off-by: Hoang, Phuong <[email protected]>
Signed-off-by: Hoang, Phuong <[email protected]>
Signed-off-by: Hoang, Phuong <[email protected]>
b567413
to
b483093
Compare
Rebased to main to resolve conflicts, and fixed the hack/update-*.sh files to make sure protoc generation happens before crd generation. |
b483093
to
50e3fde
Compare
If generating protoc go files from scratch, `make update` fails if CRD generation happens first, since the protoc-generated files are imported by the api go files. protoc generation needs to happen earlier. Signed-off-by: Scott Seago <[email protected]>
50e3fde
to
6b83530
Compare
Codecov Report
@@ Coverage Diff @@
## main #4943 +/- ##
=======================================
Coverage 41.03% 41.03%
=======================================
Files 231 231
Lines 19645 19645
=======================================
Hits 8062 8062
Misses 10993 10993
Partials 590 590
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Updated to newer protobug/protoc-gen-go since the module option isn't supported in the ancient 1.0.0 protoc-gen-go we're currently using. This is breaking tests now, so I'll need to fix some things now. Looks like some changes to generated code may need to be reflected in the velero code that references it. |
Signed-off-by: Scott Seago <[email protected]>
Signed-off-by: Scott Seago <[email protected]>
0000706
to
5a5a4c1
Compare
I have tested this PR with our existing OADP/OpenShift backup item action plugins. The only thing I had to do for this to work was to rebuild the image with the velero deps updated to include the code changes in this PR. Using the new code with an old plugin image (based on incompatible velero dependencies) will result in an error like the below when trying to run a backup:
|
Signed-off-by: Scott Seago <[email protected]>
9c4026d
to
91ac570
Compare
Signed-off-by: Hoang, Phuong [email protected]
Thank you for contributing to Velero!
Please add a summary of your change
Refactor BackupItemAction proto to backupitemaction/v1 and related code.
Does your change fix a particular issue?
This is part of the implementation for Plugin Versioning Design https://github.com/vmware-tanzu/velero/blob/main/design/plugin-versioning.md
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.