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

Fixed make proto #747

Merged
merged 7 commits into from
Jan 24, 2019
Merged

Fixed make proto #747

merged 7 commits into from
Jan 24, 2019

Conversation

jojohappy
Copy link
Member

Signed-off-by: jojohappy sarahdj0917@gmail.com

Changes

We have a shortcut of make proto to generates golang files from Thanos proto files. But if people have not installed the standard protocol buffer implementation from https://github.com/google/protobuf, the command will be failed.

This PR will fix the bug for downloading the protoc binary and pinning the version at 3.4.0 we specified.

Verification

To run make proto locally.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, just super minor nits! Thanks!

Makefile Outdated
PROMU_VERSION ?= 264dc36af9ea3103255063497636bd5713e3e9c1
PROTOC ?= $(BIN_DIR)/protoc-$(PROTOC_VERSION)
PROTOC_VERSION ?= 3.4.0
PROTOC_PACKAGE ?= protoc-$(PROTOC_VERSION)-linux-x86_64.zip
Copy link
Member

Choose a reason for hiding this comment

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

I would put it to golang BIN_DIR if possible (: What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

em, actually it's possible in theory, but the package has sub bin dir, I should extract the binary only. That is why I put the package at the top of temporary dir.

Copy link
Member

Choose a reason for hiding this comment

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

what do you mean? You can use PATH to file.. it's even better

Copy link
Member

Choose a reason for hiding this comment

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

It's actually important, otherwise users can accidently commit this file

Copy link
Member Author

@jojohappy jojohappy Jan 18, 2019

Choose a reason for hiding this comment

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

I guess you make a mistake, I will put the package (protoc-$(PROTOC_VERSION)-linux-x86_64.zip) into the TMP_GOPATH dir.
cd -- $(TMP_GOPATH) && curl -OLSs $(PROTOC_DOWNLOAD_URL); and then move the binary protoc into golang BIN_DIR.

but I will also change the destination of package downloaded. Thanks for your suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

oh.. Yes I totally missed that! no... TMP is totally fine for protoc package..! sorry

Makefile Outdated
@go install ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast
@./scripts/genproto.sh
proto: deps $(GOIMPORTS) $(PROTOC)
@GOIMPORTS_BIN="$(GOIMPORTS)" PROTOC_BIN="$(PROTOC)" ./scripts/genproto.sh
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

Copy link
Member

Choose a reason for hiding this comment

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

but maybe positional arguments would work better? Not a blocker

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I can't catch your suggestion.

Makefile Outdated
@echo ">> installing protoc@${PROTOC_VERSION}"
@mv -- "$(TMP_GOPATH)/bin/protoc" "$(BIN_DIR)/protoc-$(PROTOC_VERSION)"
@echo ">> produced $(BIN_DIR)/protoc-$(PROTOC_VERSION)"
@go install ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast
Copy link
Member

Choose a reason for hiding this comment

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

Let's run thins in very beginning. Otherwise when you run protoc and it will get into to the 214 line and we abort this, protoc will be installed so running make proto will not install protoc, but protoc-gen-gogofast won't be there.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, my bad.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

One thing and LGTM

Makefile Outdated
PROMU_VERSION ?= 264dc36af9ea3103255063497636bd5713e3e9c1
PROTOC ?= $(BIN_DIR)/protoc-$(PROTOC_VERSION)
PROTOC_VERSION ?= 3.4.0
PROTOC_PACKAGE ?= protoc-$(PROTOC_VERSION)-linux-x86_64.zip
Copy link
Member

Choose a reason for hiding this comment

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

It's actually important, otherwise users can accidently commit this file

Makefile Outdated

$(PROTOC):
@echo ">> fetching protoc@${PROTOC_VERSION}"
@if [ ! -x '$(BIN_DIR)/protoc' ]; then \
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? makefile already checks if command in variable $(PROTOC) exists. Let's remove it to fetch it always, I think to simplify.

Makefile Outdated
$(PROTOC):
@echo ">> fetching protoc@${PROTOC_VERSION}"
@if [ ! -x '$(BIN_DIR)/protoc' ]; then \
curl -LSs $(PROTOC_DOWNLOAD_URL) -o $(BIN_DIR)/$(PROTOC_PACKAGE); \
Copy link
Member

Choose a reason for hiding this comment

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

I messed up... tmp packages in bin might be not ok... ): Can we move it back to tmp.
What I meant with my above comments is for $(PROTOC) itself - it should be in BIN_DIR as you already did it.

Sorry for confusion!

Copy link
Member Author

Choose a reason for hiding this comment

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

It's Ok, I'll rollback the code.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Perfect, once CI is read let's merge it.

I will checkout this and test on my machine as well.

@bwplotka
Copy link
Member

And it does not work:

curl: (23) Failed writing body (0 != 16360)
Makefile:209: recipe for target '/home/bartek/Repos/thanosGo/bin/protoc-3.4.0' failed
make: *** [/home/bartek/Repos/thanosGo/bin/protoc-3.4.0] Error 2

;p

@jojohappy
Copy link
Member Author

Because the temp dir does not exist... I'll fix it.

@bwplotka
Copy link
Member

We need mkdir -p $(TMP_GOPATH) in proto before doing curl and all works then 👍 @jojohappy

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice, thanks! Will merge on green.

@adrien-f
Copy link
Member

What about people on OSX ?

@bwplotka
Copy link
Member

bwplotka commented Jan 18, 2019 via email

@adrien-f
Copy link
Member

The whole PROTOC_PACKAGE ?= protoc-$(PROTOC_VERSION)-linux-x86_64.zip line. That would mean downloading a Linux binary for OSX ?

@jojohappy
Copy link
Member Author

Thanks @adrien-f , maybe we should download the protoc package base on the arch of system. I will try to catch the correct value of arch.

@jojohappy
Copy link
Member Author

I find that we can use the golang env $GOOS and $GOARCH to combine the full download url of protoc package.

The valid combinations of $GOOS and $GOARCH are from the section

Since the protoc packages provide three operation systems only, linux, darwin and windows. maybe we can support those systems only and drop errors for others, such as bsd, plan9, solaris etc...

what do you think? @adrien-f @bwplotka

@adrien-f
Copy link
Member

Seems much more sensible to me ! TIL about $GOOS 👍

@bwplotka
Copy link
Member

I feel like limiting dev to OSX and Linux for development is ok. Worth to mention this in CONTRIBUTING.md

@FUSAKLA
Copy link
Member

FUSAKLA commented Jan 21, 2019

It's 👍 from me but the architecture detection would be good. (tested on linux and it's working as expected)

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

So @jojohappy do we wait on you to do OS split for protoc installation now in this PR, right?

@jojohappy
Copy link
Member Author

Yes, it is WIP, I will update soon.

@jojohappy
Copy link
Member Author

@FUSAKLA @adrien-f @bwplotka I have updated the PR, PTAL, thanks!

Copy link
Member

@adrien-f adrien-f left a comment

Choose a reason for hiding this comment

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

Awesome !

esac
true
}
adjust_arch() {
Copy link
Member

Choose a reason for hiding this comment

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

New Line maybe?


is_supported_platform "$PLATFORM"
if [[ $? -eq 1 ]]; then
echo "platform $PLATFORM is not supported."
Copy link
Member

Choose a reason for hiding this comment

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

Maybe echo a link to protoc's download page ?

CONTRIBUTING.md Outdated
@@ -9,8 +9,9 @@ Please follow the [code of conduct](CODE_OF_CONDUCT.md) in all your interactions
## Pull Request Process

1. Read [getting started docs](docs/getting_started.md) and prepare Thanos.
2. Familarize yourself with [Makefile](Makefile) commands like `format`, `build`, `proto` and `test`.
3. Fork improbable-eng/thanos.git and start development from your own fork. Here are sample steps to setup your development environment:
2. It is strongly recommended that you can use MACOSX or popular Linux distributions systems e.g., ubuntu, redhat, and opensuse for development.
Copy link
Member

Choose a reason for hiding this comment

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

It is strongly recommended that you can use OS X

Maybe also capitalize distributions names

@jojohappy jojohappy force-pushed the fix_make_proto branch 2 times, most recently from 5845b2f to 040cb96 Compare January 23, 2019 14:03
@FUSAKLA
Copy link
Member

FUSAKLA commented Jan 23, 2019

Tested and still ok 👍

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Oh no...more bash ^^

But if the outcome is to have reproducible proto generation.. I am in! LGTM

CONTRIBUTING.md Outdated
@@ -9,8 +9,9 @@ Please follow the [code of conduct](CODE_OF_CONDUCT.md) in all your interactions
## Pull Request Process

1. Read [getting started docs](docs/getting_started.md) and prepare Thanos.
2. Familarize yourself with [Makefile](Makefile) commands like `format`, `build`, `proto` and `test`.
3. Fork improbable-eng/thanos.git and start development from your own fork. Here are sample steps to setup your development environment:
2. It is strongly recommended that you use OSX or popular Linux distributions systems e.g., Ubuntu, Redhat, and OpenSUSE for development.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
2. It is strongly recommended that you use OSX or popular Linux distributions systems e.g., Ubuntu, Redhat, and OpenSUSE for development.
2. It is strongly recommended that you use OSX or popular Linux distributions systems e.g. Ubuntu, Redhat, or OpenSUSE for development.

Copy link
Member

Choose a reason for hiding this comment

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

Can we move it outside of Pull Request Process in some Prerequisites section?

@bwplotka
Copy link
Member

Just small doc nit and we can merge. Thanks @jojohappy (:

Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
Signed-off-by: jojohappy <sarahdj0917@gmail.com>
@bwplotka bwplotka merged commit 71f4e25 into thanos-io:master Jan 24, 2019
@bwplotka
Copy link
Member

bwplotka commented Jan 24, 2019

I guess it's now time to hook it in CI to test if proto was generated, right? (:

@jojohappy jojohappy deleted the fix_make_proto branch January 24, 2019 14:50
@jojohappy
Copy link
Member Author

@bwplotka Yes, it is.

Could we keep working for #733? Or still broken by waiting for moving dependency to go mod?

@FUSAKLA
Copy link
Member

FUSAKLA commented Jan 24, 2019

Ugh we agreed with @bwplotka to leave that as it is right now and focus on more important things so I wouldn't wait for it probably and add it separately.

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.

None yet

4 participants