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 the run goal #35

Merged
merged 1 commit into from
Sep 21, 2018
Merged

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Sep 20, 2018

Instead of relying on the binary being present, we just use go run.
We also set all the necessary compilation flags, environment variables
and trap the interrupt signal in order to avoid having Make fail when
the execution of the goal is interrupted

Signed-off-by: Georgios Andrianakis [email protected]

@jpkrohling
Copy link
Contributor

This change is Reviewable

@codecov
Copy link

codecov bot commented Sep 20, 2018

Codecov Report

Merging #35 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #35   +/-   ##
=======================================
  Coverage   99.16%   99.16%           
=======================================
  Files          16       16           
  Lines         599      599           
=======================================
  Hits          594      594           
  Misses          5        5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 347bcb0...c0e6b66. Read the comment docs.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @geoand)


Makefile, line 56 at r1 (raw file):

run: crd
	@OPERATOR_NAME=$(OPERATOR_NAME) KUBERNETES_CONFIG=$(KUBERNETES_CONFIG) WATCH_NAMESPACE=$(WATCH_NAMESPACE) go run main.go start

Interesting: a side effect of this is that go run will exit with a return code 1, causing make to complain about it:

^CINFO[0001] Jaeger Operator finished                     
make: *** [Makefile:56: run] Error 1

If it's not possible to get go run to return the appropriate return code, it would probably make sense then to add something like || true to the end of the command, so that make is happy.

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

Sounds good, I'll take a look

@jpkrohling
Copy link
Contributor

You might want also to add the -ldflags, as mentioned on #37

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

Sure thing

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

@jpkrohling Issues should be addressed now :)

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @geoand)


Makefile, line 56 at r2 (raw file):

run: crd
	bash -c 'trap "exit 0" INT; OPERATOR_NAME=${OPERATOR_NAME} KUBERNETES_CONFIG=${KUBERNETES_CONFIG} WATCH_NAMESPACE=${WATCH_NAMESPACE} go run -ldflags $(LD_FLAGS) main.go start'

I got to admit that it's close to magic to me :) Why are some vars wrapped in brackets and others in parenthesis? Also, are you developing on Mac OS or on Linux? I tested this on Linux and it works, but I wonder if would work the same on Mac OS.

A simpler version could be to just add "|| true" to the end, like (untested):

@OPERATOR_NAME=$(OPERATOR_NAME) KUBERNETES_CONFIG=$(KUBERNETES_CONFIG) WATCH_NAMESPACE=$(WATCH_NAMESPACE) go run -ldflags $(LD_FLAGS) main.go start || true

That said, this does LGTM. Once you confirm that it works on Mac OS, I'm ready to merge, unless you want to proceed with the "|| true" I mentioned.

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

@jpkrohling The parenthesis are wrong, I need to update to use brackets :)

Unfortunately the || true does not work when the goal is interrupted (it's the first thing I tried), hence the need to trap that signal explicitly

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

I fixed the parenthesis issue.

Also I am also on Linux, so I don't really know how this will behave on MacOS, although I would be surprised if it didn't work :P

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @jpkrohling and @geoand)


Makefile, line 56 at r3 (raw file):

run: crd
	bash -c 'trap "exit 0" INT; OPERATOR_NAME=${OPERATOR_NAME} KUBERNETES_CONFIG=${KUBERNETES_CONFIG} WATCH_NAMESPACE=${WATCH_NAMESPACE} go run -ldflags ${LD_FLAGS} main.go start'

Sorry for not noticing this before, but it would be better to have a @ in front of the bash command, so that it doesn't get printed out when doing a make run:

$ make run
bash -c 'trap "exit 0" INT; OPERATOR_NAME=jaeger-operator KUBERNETES_CONFIG="/home/jpkroehling/.kube/config" WATCH_NAMESPACE=default go run -ldflags "-X "github.com/jaegertracing/jaeger-operator/pkg/version".commit=1a1c7f52ff549df06e0f475c1b951e9e29c64ea4 -X "github.com/jaegertracing/jaeger-operator/pkg/version".buildDate=2018-09-21T11:05:39Z -X "github.com/jaegertracing/jaeger-operator/pkg/version".defaultJaeger="1.6"" main.go start'
INFO[0000] Versions used by this operator: Version(Operator='1.6', GitCommit='1a1c7f52ff549df06e0f475c1b951e9e29c64ea4', BuildDate='2018-09-21T11:05:39Z', Jaeger='1.6', Go='go1.10.4', OperatorSDK='0.0.5+git') 
INFO[0000] Metrics service jaeger-operator created      
INFO[0000] Watching io.jaegertracing/v1alpha1, Jaeger, default, 5 
^CINFO[0005] Jaeger Operator finished                     

vs.

$ make run
INFO[0000] Versions used by this operator: Version(Operator='1.6', GitCommit='1a1c7f52ff549df06e0f475c1b951e9e29c64ea4', BuildDate='2018-09-21T11:05:58Z', Jaeger='1.6', Go='go1.10.4', OperatorSDK='0.0.5+git') 
INFO[0000] Metrics service jaeger-operator created      
INFO[0000] Watching io.jaegertracing/v1alpha1, Jaeger, default, 5 
^CINFO[0001] Jaeger Operator finished                     

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @geoand)

Instead of relying on the binary being present, we just use go run.
We also set all the necessary compilation flags, environment variables
and trap the interrupt signal in order to avoid having Make fail when
the execution of the goal is interrupted

Signed-off-by: Georgios Andrianakis <[email protected]>
@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

Ah yes, good catch! Fixed :)

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @geoand)

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@jpkrohling jpkrohling merged commit 5d0920e into jaegertracing:master Sep 21, 2018
@jpkrohling
Copy link
Contributor

Thanks!

@geoand
Copy link
Contributor Author

geoand commented Sep 21, 2018

You're welcome!

@geoand geoand deleted the contributing-fix2 branch September 21, 2018 12:24
dt-cloner bot pushed a commit to IshwarKanse/jaeger-operator that referenced this pull request Aug 22, 2024
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.

2 participants