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(make): run UI build container as current user to avoid yarn build fail after make. #3635

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

shovanmaity
Copy link
Contributor

@shovanmaity shovanmaity commented Jun 12, 2019

We are building ui-dist in make using docker image of nodejs after building dist it put those dist in build or build-external folder. These folders are created by docker run under root user. After make if we try to build it locally by yarn build it tries to delete build folder from $USER user thats why we are getting permission error.

shovan@probot:~/Desktop/workspace/src/github.com/weaveworks/scope/client$ ls -l
total 420
drwxr-xr-x    7 shovan shovan   4096 Jun 12 15:46 app
drwxr-xr-x    2 root   root     4096 Jun 13 00:42 build
drwxr-xr-x    2 root   root     4096 Jun 13 00:37 build-external
-rw-r--r--    1 shovan shovan    608 Jun 12 15:46 Dockerfile
drwxr-xr-x 1016 shovan shovan  36864 Jun 13 00:36 node_modules
-rw-r--r--    1 shovan shovan   4642 Jun 13 00:29 package.json
-rw-r--r--    1 shovan shovan   1764 Jun 12 15:46 README.md
-rw-r--r--    1 shovan shovan   2623 Jun 12 15:46 server.js
drwxr-xr-x    5 shovan shovan   4096 Jun 12 16:14 test
-rw-r--r--    1 shovan shovan   4239 Jun 12 15:46 webpack.local.config.js
-rw-r--r--    1 shovan shovan   3856 Jun 13 00:27 webpack.production.config.js
-rw-r--r--    1 shovan shovan 334991 Jun 12 15:46 yarn.lock

Fixes #3612

Signed-off-by: Shovan Maity shovan.cse91@gmail.com

@satyamz
Copy link
Contributor

satyamz commented Jun 13, 2019

Hi @imazik Thanks for the PR. I have triggered build for this.

@satyamz satyamz requested a review from fbarl June 13, 2019 06:12
@satyamz
Copy link
Contributor

satyamz commented Jun 13, 2019

Integration tests are still failing.
Hi @bboreham do you any idea on this? Result of the tests:

#!/bin/bash -eo pipefail
goveralls -repotoken $COVERALLS_REPO_TOKEN -coverprofile=profile.cov -service=circleci
exit status 2: warning: no packages being tested depend on github.com/weaveworks/scope/app/multitenant
warning: no packages being tested depend on github.com/weaveworks/scope/cri/runtime
warning: no packages being tested depend on github.com/weaveworks/scope/extras/copyreport
warning: no packages being tested depend on github.com/weaveworks/scope/extras/dialer/src
warning: no packages being tested depend on github.com/weaveworks/scope/extras/example/searchapp
warning: no packages being tested depend on github.com/weaveworks/scope/extras/example/shout
warning: no packages being tested depend on github.com/weaveworks/scope/extras/fixprobe
warning: no packages being tested depend on github.com/weaveworks/scope/probe/appclient
warning: no packages being tested depend on github.com/weaveworks/scope/probe/cri
warning: no packages being tested depend on github.com/weaveworks/scope/probe/plugins
warning: no packages being tested depend on github.com/weaveworks/scope/prog
warning: no packages being tested depend on github.com/weaveworks/scope/prog/externalui
warning: no packages being tested depend on github.com/weaveworks/scope/prog/staticui
warning: no packages being tested depend on github.com/weaveworks/scope/render/expected
warning: no packages being tested depend on github.com/weaveworks/scope/test
warning: no packages being tested depend on github.com/weaveworks/scope/test/fixture
warning: no packages being tested depend on github.com/weaveworks/scope/test/utils
warning: no packages being tested depend on github.com/weaveworks/scope/test/weave
warning: no packages being tested depend on github.com/weaveworks/scope/tools/cover
warning: no packages being tested depend on github.com/weaveworks/scope/tools/runner
warning: no packages being tested depend on github.com/weaveworks/scope/tools/socks
# github.com/weaveworks/scope/probe/docker
/tmp/go-build105652850/github.com/weaveworks/scope/probe/docker/_obj/container.go:328:17: undefined: namespaceIPAddresses
# github.com/weaveworks/scope/vendor/sigs.k8s.io/yaml
vendor/sigs.k8s.io/yaml/yaml.go:42:48: undefined: DisallowUnknownFields
# github.com/weaveworks/scope/vendor/k8s.io/client-go/transport
vendor/k8s.io/client-go/transport/round_trippers.go:437:9: undefined: strings.Builder
# github.com/weaveworks/scope/vendor/github.com/weaveworks/tcptracer-bpf/vendor/github.com/iovisor/gobpf/elf
In file included from vendor/github.com/weaveworks/tcptracer-bpf/vendor/github.com/iovisor/gobpf/elf/elf.go:52:0:
./include/bpf.h:12:30: fatal error: linux/bpf_common.h: No such file or directory
 #include <linux/bpf_common.h>
                              ^
compilation terminated.
# github.com/weaveworks/scope/vendor/github.com/google/gopacket/pcap
vendor/github.com/google/gopacket/pcap/pcap.go:22:18: fatal error: pcap.h: No such file or directory
 #include <pcap.h>
                  ^
compilation terminated.
FAIL	github.com/weaveworks/scope/app [build failed]

Exited with code 1

@bboreham
Copy link
Collaborator

The integration tests are not supposed to run for external pull requests - they would gain access to credentials which could then be used for botnets, etc. The fact that something does run which then fails in an odd way is accidental.

Makefile Outdated
if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \
rm -rf client/build; \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be deleting the cache on every build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes @bboreham .

Copy link
Contributor

Choose a reason for hiding this comment

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

@bboreham That's actually what CleanWebpackPlugin is already doing in our current setup and I imagine that's exactly the first point of failure which makes #3612 occur in the first place.

Copy link
Contributor

@fbarl fbarl left a comment

Choose a reason for hiding this comment

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

Thanks for your PR @imazik and for capturing the issue!

I suggested we keep things simple and omit introducing new build folders if possible, let us know what you think :)

.gitignore Outdated
@@ -59,7 +59,7 @@ extras/copyreport/copyreport
app/static.go
vendor/github.com/ugorji/go/codec/codecgen/bin/*
*.codecgen.go
client/build-external/*
client/build*
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Makefile Outdated
$(SCOPE_UI_BUILD_IMAGE) yarn run build-external; \
$(SCOPE_UI_BUILD_IMAGE) yarn run build-external-docker; \
mkdir client/build-external; \
cp -r client/build-docker-external/* client/build-external; \
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think having 4 different build output dirs might be a bit of an overkill, especially given the docker ones are just temporary in a sense :)

Would your commands with rm -rf above be enough to fix #3612? If yes, maybe we can just keep things as simple as possible and only keep those lines, wdyt @imazik?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I can clean build directory created by root user so that we will have 2 different build dirs only. It will be simple then. 👍

Makefile Outdated
if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \
rm -rf client/build; \
Copy link
Contributor

Choose a reason for hiding this comment

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

@bboreham That's actually what CleanWebpackPlugin is already doing in our current setup and I imagine that's exactly the first point of failure which makes #3612 occur in the first place.

Makefile Outdated
if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \
rm -rf client/build-external; \
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to re-use yarn clean-build-external here if possible..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup I was thinking like that. Will add. Thanks.

Makefile Outdated
$(SCOPE_UI_BUILD_IMAGE) yarn run build; \
$(SCOPE_UI_BUILD_IMAGE) yarn run build-docker; \
mkdir -p client/build; \
cp -r client/build-docker/* client/build; \
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment below

@shovanmaity
Copy link
Contributor Author

@bboreham and @fbarl I have added cleanup steps after build PTAL.
Thank You.

@bboreham
Copy link
Collaborator

I feel this is very complicated. Is it possible to run as the current user? (mentioned at #3612 (comment))

pass user and group id in docker run command to run it as current user

Signed-off-by: Shovan Maity <shovan.cse91@gmail.com>
@shovanmaity
Copy link
Contributor Author

I feel this is very complicated. Is it possible to run as the current user? (mentioned at #3612 (comment))

Please check it.

Copy link
Contributor

@fbarl fbarl left a comment

Choose a reason for hiding this comment

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

Great improvement @imazik, LGTM! 👍

Copy link
Contributor

@qiell qiell left a comment

Choose a reason for hiding this comment

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

Nice improvement
Thanks @imazik for fixing it.
LGTM 🎉

@fbarl fbarl merged commit 83f9d4e into weaveworks:master Oct 14, 2019
@bboreham bboreham changed the title [fix] [make] update ui build to avoid yarn build fail after make. fix(make): run UI build container as current user to avoid yarn build fail after make. Oct 22, 2019
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.

client/build asset files sometimes have too strict permissions
5 participants