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

Package static assets inside the query-service binary #918

Merged
merged 13 commits into from
Jul 9, 2018

Conversation

yurishkuro
Copy link
Member

@yurishkuro yurishkuro commented Jul 8, 2018

The Makefile target build_ui runs an additional command to package NPM-generated assets into a single Go file. The resulting file is huge (13Mb), so it is .gitignore-ed to prevent accidental check-ins. Instead, another placeholder file is generated and checked-in that packages a dummy index.html. When the build tag ui is provided, the real assets are used, cf.

$ go run ./cmd/standalone/main.go
$ go run -tags ui ./cmd/standalone/main.go

Another way to run with the real UI is by passing the assets path via --query.static-files flag:

$ go run ./cmd/standalone/main.go --query.static-files jaeger-ui/build

@ghost ghost assigned yurishkuro Jul 8, 2018
@ghost ghost added the review label Jul 8, 2018
@yurishkuro yurishkuro mentioned this pull request Jul 8, 2018
5 tasks
@codecov
Copy link

codecov bot commented Jul 8, 2018

Codecov Report

Merging #918 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #918   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         126    126           
  Lines        6073   6070    -3     
=====================================
- Hits         6073   6070    -3
Impacted Files Coverage Δ
cmd/query/app/flags.go 100% <100%> (ø) ⬆️
cmd/query/app/static_handler.go 100% <100%> (ø) ⬆️

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 5e2a192...8f9474c. Read the comment docs.

ADD jaeger-ui-build /go/jaeger-ui/
CMD ["/go/bin/query-linux", "--query.static-files=/go/jaeger-ui/"]

# TODO replace this with ENTRYPOINT
Copy link
Contributor

Choose a reason for hiding this comment

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

why cant this be done now?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did at first, but it would be a breaking change (existing docker-compose, helm/kubernetes configs won't work), so I think it's better to do for all binaries at once (#815).

if err != nil {
return nil, errors.Wrap(err, "Cannot read UI static assets")
return nil, errors.Wrap(err, "Cannot load index.html")
Copy link
Contributor

Choose a reason for hiding this comment

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

loadIndexHTML seems to return errors that are sufficient, don't think the wrap is necessary.

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.

If this proves to be an issue, a possible workaround is to have the real archive generated into a different file or directory that is included in .gitignore, to prevent accidental check-ins, and use build tags to switch between fake and real archive.

I'd rather have it now and not have any auto-generated code checked in. It will be a PITA to git checkout -- cmd/query/app/statik/statik.go every time we send a PR and then make build_ui whenever we need to browse the UI.

Another question: would this change affect the possibility (or inability) to have custom paths to the UI? People have expressed in the past that they need/want to access the UI under a specific path.

@@ -0,0 +1,20 @@
// Copyright (c) 2018 Uber Technologies, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright headers on new files should be "The Jaeger Authors", no?

COPY ./cmd/standalone/standalone-linux /go/bin/
COPY ./cmd/standalone/sampling_strategies.json /go/src/config/
COPY ./cmd/standalone/sampling_strategies.json /etc/jaeger/
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Yuri Shkuro added 9 commits July 9, 2018 12:05
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
@yurishkuro
Copy link
Member Author

I'd rather have it now

ok, done and updated the description.

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.

Looks almost good to me. I'm missing only an entry on the CONTRIBUTING.md, especially because the old way of running (go run ...) is not sufficient anymore. It's now required to run:

$ make build_ui
$ go run -tags ui ./cmd/standalone/main.go

Signed-off-by: Yuri Shkuro <ys@uber.com>
Yuri Shkuro added 2 commits July 9, 2018 13:08
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
echo "Cannot find UI assets, e.g. $INDEX_HTML. Aborting."
exit 1
fi

Copy link
Member Author

Choose a reason for hiding this comment

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

no longer needed since compile will fail if the ui packaged file is missing

Signed-off-by: Yuri Shkuro <ys@uber.com>
@yurishkuro yurishkuro merged commit bbf8b7a into master Jul 9, 2018
@ghost ghost removed the review label Jul 9, 2018
@yurishkuro yurishkuro deleted the embed-ui-assets branch July 9, 2018 18:13
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.

3 participants