[ 
https://issues.apache.org/jira/browse/BEAM-13939?focusedWorklogId=744436&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-744436
 ]

ASF GitHub Bot logged work on BEAM-13939:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Mar/22 21:25
            Start Date: 18/Mar/22 21:25
    Worklog Time Spent: 10m 
      Work Description: thempatel commented on a change in pull request #16961:
URL: https://github.com/apache/beam/pull/16961#discussion_r830357685



##########
File path: sdks/go/scripts/genmodel.sh
##########
@@ -0,0 +1,81 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+if [[ -z "$(which protoc)" ]]; then
+  echo "protoc not found on path"
+  exit 1
+fi
+
+SCRIPT_DIR="$( realpath "$( dirname "${BASH_SOURCE[0]}" )" )"
+if [[ -z $SCRIPT_DIR ]]; then
+  echo "unable to resolve path to script"
+  exit 1
+fi
+
+PROJECT_ROOT="$(realpath "$(dirname $SCRIPT_DIR)/../..")"
+if [[ -z "$PROJECT_ROOT" ]]; then
+  echo "unable to resolve path to project root"
+  exit 1
+fi
+
+if [[ -z "$(which go)" ]]; then
+  echo "go runtime missing"
+  exit 1
+fi
+
+if [[ -z "$GOPATH" ]]; then
+  export GOPATH="$(go env GOPATH)"

Review comment:
       I need help making a decision on this one, it looks like 
`protoc-gen-go-grpc` is released separately from 
https://github.com/grpc/grpc-go despite being in the same repository. When 
performing
   
   `go install google.golang.org/grpc/cmd/protoc-gen-go-grpc` without a version 
number, i.e. relying on what's in the go.mod file, the downloaded version is 
`v.1.10`.
   
   ```sh
   "$(go env GOPATH)/bin/protoc-gen-go-grpc" --versionprotoc-gen-go-grpc 1.1.0
   protoc-gen-go-grpc 1.1.0
   ```
   
   and the resulting generated files lose the version and path info:
   
   ```diff
   // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
   -// versions:
   -// - protoc-gen-go-grpc v1.1.0
   -// - protoc             v3.19.4
   -// source: org/apache/beam/model/pipeline/v1/beam_runner_api.proto
   ```
   
   if I add a dedicated version number to the go.mod file, like so:
   
   ```diff
        google.golang.org/api v0.45.0
        google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f
        google.golang.org/grpc v1.39.0
   +    google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 // indirect
        google.golang.org/protobuf v1.27.1
        gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
        gopkg.in/linkedin/goavro.v1 v1.0.5 // indirect
   ```
   
   then the version numbers come back. Same result if I replace the version 
number in go.mod with `ebf6a4b`. The question is, how do we want to handle the 
difference in release versions for this?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 744436)
    Time Spent: 17.5h  (was: 17h 20m)

> Go SDK: Protobuf namespace conflict
> -----------------------------------
>
>                 Key: BEAM-13939
>                 URL: https://issues.apache.org/jira/browse/BEAM-13939
>             Project: Beam
>          Issue Type: Improvement
>          Components: beam-model, sdk-go
>    Affects Versions: 2.36.0
>            Reporter: Milan Patel
>            Priority: P2
>         Attachments: demobug.zip
>
>          Time Spent: 17.5h
>  Remaining Estimate: 0h
>
> The Go SDK generated grpc protobufs are not namespaced with enough 
> granularity. If a user has another external dependency with the same protobuf 
> file registered with the proto runtime, their compiled binary will panic at 
> runtime pointing the user to this [doc 
> page|https://developers.google.com/protocol-buffers/docs/reference/go/faq#fix-namespace-conflict].
>  
> In the interim, following the instructions to add either ldflags to the 
> compiler or an environment var to the binary works, but this is an unideal 
> solution since only one of the duplicate proto specifications will be 
> accessible from a [global 
> registry|https://pkg.go.dev/google.golang.org/[email protected]/reflect/protoregistry].
>  
> Ask: Regenerate the go protos such that descriptors like 
> [these|https://github.com/apache/beam/blob/84353a7c973d3acaaa56d81c265dce7193a56be5/sdks/go/pkg/beam/model/pipeline_v1/metrics.pb.go#L797-L811]
>  are outputted with filenames that are more granular, such as a filename that 
> includes the directory structure of the repository.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to