From 04592e4770d32abc881b96a59d9769d17652e954 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 10 Sep 2018 10:33:30 +0000 Subject: [PATCH 01/23] Note how to make an EC2 AMI public --- site/ami.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/ami.md b/site/ami.md index 409670891..ce95986b9 100644 --- a/site/ami.md +++ b/site/ami.md @@ -250,6 +250,12 @@ that region when invoking the script: ONLY_REGION=us-east-1 AWS_ACCSS_KEY_ID=XXXX AWS_SECRET_ACCESS_KEY=YYYY ./build-all-amis.sh ~~~ +To make an AMI public: + +~~~bash +aws ec2 modify-image-attribute --region=us-east-2 --image-id ami-6a0b350f --launch-permission "{\"Add\": [{\"Group\":\"all\"}]}" +~~~ + ## Further Reading Read the From 8d33d8b4d1e63ad47889b4404a5c46b11facdb4b Mon Sep 17 00:00:00 2001 From: visualapps Date: Fri, 14 Sep 2018 14:55:30 +0530 Subject: [PATCH 02/23] import missing terminal.scss in contrast.scss --- client/app/styles/contrast.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/client/app/styles/contrast.scss b/client/app/styles/contrast.scss index 2862d3842..7533c1d9d 100644 --- a/client/app/styles/contrast.scss +++ b/client/app/styles/contrast.scss @@ -1,3 +1,4 @@ @import "variables"; @import "contrast-overrides"; @import "base"; +@import "terminal"; From cea74c6280ebf2f3989bebb5aba26bae0cabac8c Mon Sep 17 00:00:00 2001 From: Julien Garcia Gonzalez Date: Wed, 26 Sep 2018 11:19:09 +0200 Subject: [PATCH 03/23] example k8s: add support for PodSecurityPolicy This add a psp file with needed right to work on kubernetes. Signed-off-by: Julien Garcia Gonzalez --- examples/k8s/cluster-role.yaml | 8 ++++++++ examples/k8s/psp.yaml | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 examples/k8s/psp.yaml diff --git a/examples/k8s/cluster-role.yaml b/examples/k8s/cluster-role.yaml index f51d9a7bd..323d818b5 100644 --- a/examples/k8s/cluster-role.yaml +++ b/examples/k8s/cluster-role.yaml @@ -51,3 +51,11 @@ rules: verbs: - list - watch +- apigroups: + - extensions + resourcenames: + - weave-scope + resources: + - podsecuritypolicies + verbs: + - use diff --git a/examples/k8s/psp.yaml b/examples/k8s/psp.yaml new file mode 100644 index 000000000..555a7c027 --- /dev/null +++ b/examples/k8s/psp.yaml @@ -0,0 +1,21 @@ +apiVersion: extensions/v1beta1 +kind: PodSecurityPolicy +metadata: + name: weave-scope +spec: + privileged: true + hostPID: true + hostNetwork: true + allowedCapabilities: + - 'NET_ADMIN' + fsGroup: + rule: RunAsAny + runAsUser: + rule: RunAsAny + seLinux: + rule: RunAsAny + supplementalGroups: + rule: RunAsAny + volumes: + - secret + - hostPath \ No newline at end of file From c03e6a0e50930fc5f7358177a32a092fc45272ca Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Mon, 24 Sep 2018 14:26:27 +0100 Subject: [PATCH 04/23] Rework UI build to improve caching and fix packaging issue Stop baking the toolchain and dependencies into the build image. Instead, run the install step each time, but use volume mounts or CircleCI caching to keep the happy path fast. Previously, some parts of the client (UI) directory were baked into the build image, and some parts were mounted or copied into the build environment. As a result, files baked into the build image require a two-step update for changes to take effect in CI. Now, for dockerised builds, we pre-install very little into the build image and mount the whole directory into the build environment. However, we do overlay a volume on the node_modules folder to allow the standard build toolchain to be separate from the host build toolchain. Non-dockerised builds (e.g. CI) are now more similar to the dockerised versions. --- .circleci/config.yml | 29 +++++++++++++++++++++-------- Makefile | 43 ++++++++++++++++++++++++++++--------------- client/Dockerfile | 14 ++++++++------ client/package.json | 2 +- 4 files changed, 58 insertions(+), 30 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index abbf4c81c..f5f11e2c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,11 +62,19 @@ jobs: <<: *client-defaults steps: - checkout - # Convoluted set of steps here to mimic Makefile actions of bind-mounting different dirs into container - - run: mv client/app /home/weave/ - - run: cd /home/weave; mkdir build ; yarn run build ; mv build scope/client - - run: cd /home/weave; mkdir build-external; yarn run build-external; mv build-external scope/client - - run: cd /home/weave; mkdir tmp ; yarn run bundle ; mv tmp scope + - restore_cache: + keys: + - yarn-cache-{{ checksum "client/yarn.lock" }} + - run: cd client; yarn install + - save_cache: + key: yarn-cache-{{ checksum "client/yarn.lock" }} + paths: + - "/home/weave/scope/.cache/yarn" + - run: | + cd client + yarn run build + yarn run build-external + yarn run bundle - persist_to_workspace: root: /home/weave/scope paths: @@ -74,14 +82,19 @@ jobs: - client/build-external/ - tmp/weave-scope.tgz + client-test: <<: *client-defaults steps: - checkout + - restore_cache: + keys: + - yarn-cache-{{ checksum "client/yarn.lock" }} - run: | - mv client/app client/test /home/weave/ - cd /home/weave; yarn run lint - cd /home/weave; yarn test + cd client + yarn install + yarn run lint + yarn test xplatform-build: <<: *defaults diff --git a/Makefile b/Makefile index f42be4121..5930f8055 100644 --- a/Makefile +++ b/Makefile @@ -146,39 +146,52 @@ ifeq ($(BUILD_IN_CONTAINER),true) client/build/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) mkdir -p client/build if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/client/build:/home/weave/build \ - $(SCOPE_UI_BUILD_IMAGE) yarn run build; \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + $(SCOPE_UI_BUILD_IMAGE) sh -c 'yarn install && yarn run build'; \ fi client/build-external/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) mkdir -p client/build-external if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/client/build-external:/home/weave/build-external \ - $(SCOPE_UI_BUILD_IMAGE) yarn run build-external; \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + $(SCOPE_UI_BUILD_IMAGE) sh -c 'yarn install && yarn run build-external'; \ fi client-test: $(shell find client/app/scripts -type f) $(SCOPE_UI_BUILD_UPTODATE) - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/client/test:/home/weave/test \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ $(SCOPE_UI_BUILD_IMAGE) yarn test client-lint: $(SCOPE_UI_BUILD_UPTODATE) - $(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/client/test:/home/weave/test \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ $(SCOPE_UI_BUILD_IMAGE) yarn run lint client-start: $(SCOPE_UI_BUILD_UPTODATE) - $(SUDO) docker run $(RM) $(RUN_FLAGS) --net=host -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/client/build:/home/weave/build -e WEBPACK_SERVER_HOST \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) --net=host \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -e WEBPACK_SERVER_HOST \ $(SCOPE_UI_BUILD_IMAGE) yarn start tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) $(sudo) docker run $(RUN_FLAGS) \ - -v $(shell pwd)/client/app:/home/weave/app \ - -v $(shell pwd)/tmp:/home/weave/tmp \ - $(SCOPE_UI_BUILD_IMAGE) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -v $(shell pwd)/tmp:/home/weave/tmp \ + $(SCOPE_UI_BUILD_IMAGE) \ yarn run bundle else diff --git a/client/Dockerfile b/client/Dockerfile index 4c19dc2f2..f13d44c73 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,13 +1,15 @@ +# Changes to this file will not take effect in CI +# until the image version in the CI config is updated. See +# https://github.com/weaveworks/scope/blob/master/.circleci/config.yml#L11 FROM node:8.11 -WORKDIR /home/weave -COPY package.json yarn.lock /home/weave/ -ENV NPM_CONFIG_LOGLEVEL=warn NPM_CONFIG_PROGRESS=false -RUN yarn --pure-lockfile -COPY webpack.local.config.js webpack.production.config.js server.js .babelrc .eslintrc .eslintignore .stylelintrc .sass-lint.yml /home/weave/ +ENV NPM_CONFIG_LOGLEVEL=warn +ENV NPM_CONFIG_PROGRESS=false +ENV XDG_CACHE_HOME=/home/weave/scope/.cache +WORKDIR /home/weave/scope/client ARG revision LABEL maintainer="Weaveworks " \ - org.opencontainers.image.title="client" \ + org.opencontainers.image.title="scope-ui-build" \ org.opencontainers.image.source="https://github.com/weaveworks/scope" \ org.opencontainers.image.revision="${revision}" \ org.opencontainers.image.vendor="Weaveworks" diff --git a/client/package.json b/client/package.json index 84358a277..97169f7ba 100644 --- a/client/package.json +++ b/client/package.json @@ -102,7 +102,7 @@ "build-external": "EXTERNAL=true webpack --config webpack.production.config.js", "copy-pkg-files": "cp package.json build-pkg/ && cp -R app/styles build-pkg/", "build-pkg": "mkdir -p build-pkg && node node_modules/.bin/babel app/scripts --ignore __tests__ --out-dir build-pkg && yarn run copy-pkg-files", - "bundle": "yarn run build-pkg && cd ./build-pkg && yarn pack --filename ../tmp/weave-scope.tgz", + "bundle": "mkdir -p tmp && yarn run build-pkg && cd ./build-pkg && yarn pack --filename ../tmp/weave-scope.tgz", "start": "node server.js", "start-production": "NODE_ENV=production node server.js", "test": "jest", From aafab27c74b5e29b84762823cbf0b4d44fcc9fe3 Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Tue, 25 Sep 2018 10:24:26 +0100 Subject: [PATCH 05/23] Add Makefile target for UI build toolchain --- Makefile | 58 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 5930f8055..f9e0d3aa9 100644 --- a/Makefile +++ b/Makefile @@ -143,64 +143,83 @@ endif ifeq ($(BUILD_IN_CONTAINER),true) -client/build/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) +SCOPE_UI_TOOLCHAIN=.cache/build_node_modules +SCOPE_UI_TOOLCHAIN_UPTODATE=$(SCOPE_UI_TOOLCHAIN)/.uptodate + +$(SCOPE_UI_TOOLCHAIN_UPTODATE): client/yarn.lock $(SCOPE_UI_BUILD_UPTODATE) + if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ + $(SUDO) docker run $(RM) $(RUN_FLAGS) \ + -v $(shell pwd)/.cache:/home/weave/scope/.cache \ + -v $(shell pwd)/client:/home/weave/scope/client \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + $(SCOPE_UI_BUILD_IMAGE) yarn install; \ + fi + touch $(SCOPE_UI_TOOLCHAIN_UPTODATE) + +client/build/index.html: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) mkdir -p client/build if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ - $(SCOPE_UI_BUILD_IMAGE) sh -c 'yarn install && yarn run build'; \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + $(SCOPE_UI_BUILD_IMAGE) yarn run build; \ fi -client/build-external/index.html: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) +client/build-external/index.html: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) mkdir -p client/build-external if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ - $(SCOPE_UI_BUILD_IMAGE) sh -c 'yarn install && yarn run build-external'; \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + $(SCOPE_UI_BUILD_IMAGE) yarn run build-external; \ fi -client-test: $(shell find client/app/scripts -type f) $(SCOPE_UI_BUILD_UPTODATE) +client-test: $(shell find client/app/scripts -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ $(SCOPE_UI_BUILD_IMAGE) yarn test -client-lint: $(SCOPE_UI_BUILD_UPTODATE) +client-lint: $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ $(SCOPE_UI_BUILD_IMAGE) yarn run lint -client-start: $(SCOPE_UI_BUILD_UPTODATE) +client-start: $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(SUDO) docker run $(RM) $(RUN_FLAGS) --net=host \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ -e WEBPACK_SERVER_HOST \ $(SCOPE_UI_BUILD_IMAGE) yarn start -tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) +tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(sudo) docker run $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ - -v $(shell pwd)/.cache/build_node_modules:/home/weave/scope/client/node_modules \ + -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ -v $(shell pwd)/tmp:/home/weave/tmp \ - $(SCOPE_UI_BUILD_IMAGE) \ - yarn run bundle + $(SCOPE_UI_BUILD_IMAGE) yarn run bundle else -client/build/index.html: +SCOPE_UI_TOOLCHAIN=client/node_modules +SCOPE_UI_TOOLCHAIN_UPTODATE=$(SCOPE_UI_TOOLCHAIN)/.uptodate + +$(SCOPE_UI_TOOLCHAIN_UPTODATE): client/yarn.lock + if test "true" = "$(SCOPE_SKIP_UI_ASSETS)"; then mkdir -p $(SCOPE_UI_TOOLCHAIN); else cd client && yarn install; fi + touch $(SCOPE_UI_TOOLCHAIN_UPTODATE) + +client/build/index.html: $(SCOPE_UI_TOOLCHAIN_UPTODATE) mkdir -p client/build if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then cd client && yarn run build; fi -client/build-external/index.html: +client/build-external/index.html: $(SCOPE_UI_TOOLCHAIN_UPTODATE) mkdir -p client/build-external if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then cd client && yarn run build-external; fi @@ -233,7 +252,7 @@ ui-pkg-upload: tmp/weave-scope.tgz # rmi'ng images is desirable sometimes. Invoke `realclean` for that. clean: $(GO) clean ./... - rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \ + rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \ $(SCOPE_EXE) $(RUNSVINIT) prog/staticui/staticui.go prog/externalui/externalui.go client/build/*.js client/build-external/*.js docker/weave .pkg \ $(CODECGEN_TARGETS) $(CODECGEN_DIR)/bin @@ -249,6 +268,7 @@ clean-codecgen: # # Doing this is important for release builds. realclean: clean + rm -rf $(SCOPE_UI_TOOLCHAIN) $(SUDO) docker rmi -f $(SCOPE_UI_BUILD_IMAGE) $(SCOPE_BACKEND_BUILD_IMAGE) \ $(DOCKERHUB_USER)/scope $(DOCKERHUB_USER)/cloud-agent \ $(DOCKERHUB_USER)/scope:$(IMAGE_TAG) $(DOCKERHUB_USER)/cloud-agent:$(IMAGE_TAG) \ From 3a0dc3c34fb659fde0766e4db4152e5cf18db522 Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Wed, 26 Sep 2018 10:39:09 +0100 Subject: [PATCH 06/23] Fix CI by removing Dockerfile workdir --- Makefile | 7 +++++++ client/Dockerfile | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f9e0d3aa9..3708f23d9 100644 --- a/Makefile +++ b/Makefile @@ -152,6 +152,7 @@ $(SCOPE_UI_TOOLCHAIN_UPTODATE): client/yarn.lock $(SCOPE_UI_BUILD_UPTODATE) -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn install; \ fi touch $(SCOPE_UI_TOOLCHAIN_UPTODATE) @@ -163,6 +164,7 @@ client/build/index.html: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_U -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn run build; \ fi @@ -173,6 +175,7 @@ client/build-external/index.html: $(shell find client/app -type f) $(SCOPE_UI_TO -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn run build-external; \ fi @@ -181,6 +184,7 @@ client-test: $(shell find client/app/scripts -type f) $(SCOPE_UI_TOOLCHAIN_UPTOD -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn test client-lint: $(SCOPE_UI_TOOLCHAIN_UPTODATE) @@ -188,6 +192,7 @@ client-lint: $(SCOPE_UI_TOOLCHAIN_UPTODATE) -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn run lint client-start: $(SCOPE_UI_TOOLCHAIN_UPTODATE) @@ -196,6 +201,7 @@ client-start: $(SCOPE_UI_TOOLCHAIN_UPTODATE) -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ -e WEBPACK_SERVER_HOST \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn start tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) @@ -204,6 +210,7 @@ tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTOD -v $(shell pwd)/client:/home/weave/scope/client \ -v $(shell pwd)/$(SCOPE_UI_TOOLCHAIN):/home/weave/scope/client/node_modules \ -v $(shell pwd)/tmp:/home/weave/tmp \ + -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn run bundle else diff --git a/client/Dockerfile b/client/Dockerfile index f13d44c73..c71ea6327 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -5,7 +5,6 @@ FROM node:8.11 ENV NPM_CONFIG_LOGLEVEL=warn ENV NPM_CONFIG_PROGRESS=false ENV XDG_CACHE_HOME=/home/weave/scope/.cache -WORKDIR /home/weave/scope/client ARG revision LABEL maintainer="Weaveworks " \ From 3f37ec011b6f07fe477186df50ea4144c83d81e4 Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Wed, 26 Sep 2018 10:54:24 +0100 Subject: [PATCH 07/23] Also cache the client/node_modules --- .circleci/config.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f5f11e2c8..c899fa7bb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,13 +63,23 @@ jobs: steps: - checkout - restore_cache: - keys: - - yarn-cache-{{ checksum "client/yarn.lock" }} + name: Restoring Yarn Cache + key: yarn-cache-{{ checksum "client/yarn.lock" }} + - restore_cache: + name: Restoring client/node_modules + key: node-modules-{{ checksum "client/yarn.lock" }}-{{ checksum ".circleci/config.yml" }} - run: cd client; yarn install - save_cache: + name: Saving Yarn Cache key: yarn-cache-{{ checksum "client/yarn.lock" }} paths: - "/home/weave/scope/.cache/yarn" + - save_cache: + name: Saving client/node_modules + # include the CI config in the checksum because it will change when the docker image changes + key: node-modules-{{ checksum "client/yarn.lock" }}-{{ checksum ".circleci/config.yml" }} + paths: + - "/home/weave/scope/client/node_modules" - run: | cd client yarn run build @@ -88,8 +98,11 @@ jobs: steps: - checkout - restore_cache: - keys: - - yarn-cache-{{ checksum "client/yarn.lock" }} + name: Restoring Yarn Cache + key: yarn-cache-{{ checksum "client/yarn.lock" }} + - restore_cache: + name: Restoring client/node_modules + key: node-modules-{{ checksum "client/yarn.lock" }}-{{ checksum ".circleci/config.yml" }} - run: | cd client yarn install From 041ebed8a35b98ea3b9256bae6a2e2923fa8d891 Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Wed, 26 Sep 2018 12:16:49 +0100 Subject: [PATCH 08/23] Fix path confusion in bundle building --- .circleci/config.yml | 2 +- .gitignore | 1 + Makefile | 6 +++--- client/package.json | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c899fa7bb..2d5a78346 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,7 +90,7 @@ jobs: paths: - client/build/ - client/build-external/ - - tmp/weave-scope.tgz + - client/bundle/weave-scope.tgz client-test: diff --git a/.gitignore b/.gitignore index 061010ce1..5a0d74c59 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ client/build-external/* prog/staticui/* prog/externalui/* client/build-pkg +client/bundle # Website site-build diff --git a/Makefile b/Makefile index 3708f23d9..bde1bfbef 100644 --- a/Makefile +++ b/Makefile @@ -204,7 +204,7 @@ client-start: $(SCOPE_UI_TOOLCHAIN_UPTODATE) -w /home/weave/scope/client \ $(SCOPE_UI_BUILD_IMAGE) yarn start -tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) +client/bundle/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_TOOLCHAIN_UPTODATE) $(sudo) docker run $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ -v $(shell pwd)/client:/home/weave/scope/client \ @@ -247,10 +247,10 @@ ui-upload: client/build-external/index.html AWS_SECRET_ACCESS_KEY=$$UI_BUCKET_KEY_SECRET \ aws s3 cp client/build-external/ s3://static.weave.works/scope-ui/ --recursive --exclude '*.html' -ui-pkg-upload: tmp/weave-scope.tgz +ui-pkg-upload: client/bundle/weave-scope.tgz AWS_ACCESS_KEY_ID=$$UI_BUCKET_KEY_ID \ AWS_SECRET_ACCESS_KEY=$$UI_BUCKET_KEY_SECRET \ - aws s3 cp tmp/weave-scope.tgz s3://weaveworks-js-modules/weave-scope/$(shell echo $(SCOPE_VERSION))/weave-scope.tgz + aws s3 cp client/bundle/weave-scope.tgz s3://weaveworks-js-modules/weave-scope/$(shell echo $(SCOPE_VERSION))/weave-scope.tgz # We don't rmi images here; rm'ing the .uptodate files is enough to # get the build images rebuilt, and rm'ing the scope exe is enough to diff --git a/client/package.json b/client/package.json index 97169f7ba..ee9b7c574 100644 --- a/client/package.json +++ b/client/package.json @@ -102,7 +102,7 @@ "build-external": "EXTERNAL=true webpack --config webpack.production.config.js", "copy-pkg-files": "cp package.json build-pkg/ && cp -R app/styles build-pkg/", "build-pkg": "mkdir -p build-pkg && node node_modules/.bin/babel app/scripts --ignore __tests__ --out-dir build-pkg && yarn run copy-pkg-files", - "bundle": "mkdir -p tmp && yarn run build-pkg && cd ./build-pkg && yarn pack --filename ../tmp/weave-scope.tgz", + "bundle": "mkdir -p bundle && yarn run build-pkg && cd ./build-pkg && yarn pack --filename ../bundle/weave-scope.tgz", "start": "node server.js", "start-production": "NODE_ENV=production node server.js", "test": "jest", From c8878c736b0fddbf04cf2ac1594a7666179ab3fb Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Fri, 28 Sep 2018 09:26:09 +0100 Subject: [PATCH 09/23] Update CI UI build container to master-c0b60a16 --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d5a78346..50392b166 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ defaults: &defaults client-defaults: &client-defaults working_directory: /home/weave/scope docker: - - image: weaveworks/scope-ui-build:master-fda40b83 + - image: weaveworks/scope-ui-build:master-c0b60a16 workflows: version: 2 @@ -64,14 +64,14 @@ jobs: - checkout - restore_cache: name: Restoring Yarn Cache - key: yarn-cache-{{ checksum "client/yarn.lock" }} + key: yarn-cache-2-{{ checksum "client/yarn.lock" }} - restore_cache: name: Restoring client/node_modules key: node-modules-{{ checksum "client/yarn.lock" }}-{{ checksum ".circleci/config.yml" }} - run: cd client; yarn install - save_cache: name: Saving Yarn Cache - key: yarn-cache-{{ checksum "client/yarn.lock" }} + key: yarn-cache-2-{{ checksum "client/yarn.lock" }} paths: - "/home/weave/scope/.cache/yarn" - save_cache: @@ -99,7 +99,7 @@ jobs: - checkout - restore_cache: name: Restoring Yarn Cache - key: yarn-cache-{{ checksum "client/yarn.lock" }} + key: yarn-cache-2-{{ checksum "client/yarn.lock" }} - restore_cache: name: Restoring client/node_modules key: node-modules-{{ checksum "client/yarn.lock" }}-{{ checksum ".circleci/config.yml" }} From 27a0b2460d8374e0b988c63e439ec1cea0400bf9 Mon Sep 17 00:00:00 2001 From: Ajay Kelkar Date: Mon, 1 Oct 2018 21:26:26 +0530 Subject: [PATCH 10/23] Absolute basic UT --- probe/cri/registry_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 probe/cri/registry_test.go diff --git a/probe/cri/registry_test.go b/probe/cri/registry_test.go new file mode 100644 index 000000000..7b1ba7cbb --- /dev/null +++ b/probe/cri/registry_test.go @@ -0,0 +1,27 @@ +package cri_test + +import ( + "testing" + + "github.com/weaveworks/scope/probe/cri" +) + +func TestParseHttpEndpointUrl(t *testing.T) { + _, err := cri.NewCRIClient("http://xyz.com") + + if err == nil { + t.Fatal("Should not create client with Http protocol") + } +} + +func TestParseTcpEndpointUrl(t *testing.T) { + client, err := cri.NewCRIClient("127.0.0.1") + + if err != nil { + t.Fatal("Should have created service client") + } + + if client == nil { + t.Fatal("Should have created service client") + } +} From 9c2fe36c0e1436df2c8f19b21244b6e1456b6c9c Mon Sep 17 00:00:00 2001 From: Bhavin Gandhi Date: Tue, 2 Oct 2018 10:59:51 +0530 Subject: [PATCH 11/23] Remove weaveutil and weave from Dockerfile.cloud-agent - Moves the weave and weaveutil from Dockerfile.cloud-agent to Dockerfile.scope Signed-off-by: Bhavin Gandhi --- docker/Dockerfile.cloud-agent | 1 - docker/Dockerfile.scope | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.cloud-agent b/docker/Dockerfile.cloud-agent index 627fcfa2b..8f7434854 100644 --- a/docker/Dockerfile.cloud-agent +++ b/docker/Dockerfile.cloud-agent @@ -2,7 +2,6 @@ FROM alpine:3.7 WORKDIR /home/weave RUN apk add --update bash conntrack-tools iproute2 util-linux curl && \ rm -rf /var/cache/apk/* -ADD ./weave ./weaveutil /usr/bin/ COPY ./scope /home/weave/ ENTRYPOINT ["/home/weave/scope", "--mode=probe", "--no-app", "--probe.docker=true"] diff --git a/docker/Dockerfile.scope b/docker/Dockerfile.scope index 9f2dc2851..7e0af4571 100644 --- a/docker/Dockerfile.scope +++ b/docker/Dockerfile.scope @@ -2,6 +2,7 @@ FROM weaveworks/cloud-agent RUN apk add --update runit && \ rm -rf /var/cache/apk/* ADD ./demo.json / +ADD ./weave ./weaveutil /usr/bin/ COPY ./runsvinit ./entrypoint.sh /home/weave/ COPY ./run-app /etc/service/app/run COPY ./run-probe /etc/service/probe/run From 68bce4f57c3e34d091de02c8ed4937900c0a37e6 Mon Sep 17 00:00:00 2001 From: Ajay Kelkar Date: Wed, 3 Oct 2018 14:19:54 +0530 Subject: [PATCH 12/23] Using assert for equality checks --- probe/cri/registry_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/probe/cri/registry_test.go b/probe/cri/registry_test.go index 7b1ba7cbb..916f06e4f 100644 --- a/probe/cri/registry_test.go +++ b/probe/cri/registry_test.go @@ -3,25 +3,19 @@ package cri_test import ( "testing" + "github.com/bmizerany/assert" "github.com/weaveworks/scope/probe/cri" ) func TestParseHttpEndpointUrl(t *testing.T) { _, err := cri.NewCRIClient("http://xyz.com") - if err == nil { - t.Fatal("Should not create client with Http protocol") - } + assert.Equal(t, "protocol \"http\" not supported", err.Error()) } func TestParseTcpEndpointUrl(t *testing.T) { client, err := cri.NewCRIClient("127.0.0.1") - if err != nil { - t.Fatal("Should have created service client") - } - - if client == nil { - t.Fatal("Should have created service client") - } + assert.Equal(t, nil, err) + assert.NotEqual(t, nil, client) } From 2df3a6c875a89dfd66d233b6f00bfe7848e2ac0c Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 5 Oct 2018 13:10:45 +0000 Subject: [PATCH 13/23] Put the correct version info in for AMIs --- site/ami.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/ami.md b/site/ami.md index ce95986b9..3b8993471 100644 --- a/site/ami.md +++ b/site/ami.md @@ -54,8 +54,8 @@ The latest Weave ECS AMIs are based on Amazon's [ECS-Optimized Amazon Linux AMI](https://aws.amazon.com/marketplace/pp/B06XS8WHGJ), version `2017.03.f` and also includes: -* [Weave Net 2.0.4](https://github.com/weaveworks/weave/blob/master/CHANGELOG.md#release-204) -* [Weave Scope 1.6.4](https://github.com/weaveworks/scope/blob/master/CHANGELOG.md#release-164) +* [Weave Net 2.3.0](https://github.com/weaveworks/weave/blob/master/CHANGELOG.md#release-230) +* [Weave Scope 1.9.0](https://github.com/weaveworks/scope/blob/master/CHANGELOG.md#release-190) ## Deployment Requirements From e68e99f84f2f5ac312278cf41e7f9f416a2cbb30 Mon Sep 17 00:00:00 2001 From: Siddhant Sharma Date: Sun, 7 Oct 2018 20:56:25 +0530 Subject: [PATCH 14/23] Updated license year to 2018. Writing test scripts to automatically update license dates! --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index e21766f6d..0eb9687b6 100644 --- a/LICENSE +++ b/LICENSE @@ -176,7 +176,7 @@ END OF TERMS AND CONDITIONS - Copyright 2014-2017 Weaveworks Ltd. + Copyright 2014-2018 Weaveworks Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 2ec58da1cf11c1eeac76636ce8faffda08fbc71c Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 9 Oct 2018 14:25:06 +0000 Subject: [PATCH 15/23] Don't report dead processes If the state is reported as dead or zombie, return an error so the process will be skipped. --- probe/process/walker_linux.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/probe/process/walker_linux.go b/probe/process/walker_linux.go index 05240bd97..b0cad69cd 100644 --- a/probe/process/walker_linux.go +++ b/probe/process/walker_linux.go @@ -3,6 +3,7 @@ package process import ( "bytes" "encoding/binary" + "errors" "fmt" "os" "path" @@ -31,6 +32,8 @@ var ( // key: filename in /proc. Example: "42" // value: two strings separated by a '\0' cmdlineCache = freecache.NewCache(1024 * 16) + + errDeadProcess = errors.New("The process is dead") ) const ( @@ -75,6 +78,7 @@ func readStats(path string) (ppid, threads int, jiffies, rss, rssLimit uint64, e const ( // /proc//stat field positions, counting from zero // see "man 5 proc" + procStatFieldState int = 2 procStatFieldPpid int = 3 procStatFieldUserJiffies int = 13 procStatFieldSysJiffies int = 14 @@ -94,7 +98,16 @@ func readStats(path string) (ppid, threads int, jiffies, rss, rssLimit uint64, e // Parse the file without using expensive extra string allocations pos := 0 - skipNSpaces(&buf, &pos, procStatFieldPpid) + skipNSpaces(&buf, &pos, procStatFieldState) + + // Error on processes which are in zombie (defunct) or dead state, so they will be skipped + switch buf[pos] { + case 'Z', 'X', 'x': + err = errDeadProcess + return + } + + pos += 2 // Move past state and space after state ppid = parseIntWithSpaces(&buf, &pos) skipNSpaces(&buf, &pos, procStatFieldUserJiffies-procStatFieldPpid) From 724ccd982646addf70f774ae8204156aae496a8e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 9 Oct 2018 15:50:59 +0000 Subject: [PATCH 16/23] Use the Context in the request --- app/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/router.go b/app/router.go index 28ad84c5a..c3347092c 100644 --- a/app/router.go +++ b/app/router.go @@ -43,7 +43,7 @@ type CtxHandlerFunc func(context.Context, http.ResponseWriter, *http.Request) func requestContextDecorator(f CtxHandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - ctx := context.WithValue(context.Background(), RequestCtxKey, r) + ctx := context.WithValue(r.Context(), RequestCtxKey, r) f(ctx, w, r) } } From 9c4f6b5544bff64b55b4bba930aa70fed6d57f9a Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 9 Oct 2018 18:21:01 -0500 Subject: [PATCH 17/23] Update README.md Minor punctuation and capitalization edits --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 051887fee..2d79c3245 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ [![GoDoc](https://godoc.org/github.com/weaveworks/scope?status.svg)](https://godoc.org/github.com/weaveworks/scope) Weave Scope automatically generates a map of your application, enabling you to -intuitively understand, monitor, and control your containerized, microservices based application. +intuitively understand, monitor, and control your containerized, microservices-based application. -### Understand your Docker containers in real-time +### Understand your Docker containers in real time Map you architecture @@ -20,19 +20,19 @@ Choose an overview of your container infrastructure, or focus on a specific micr Focus on a single container -View contextual metrics, tags and metadata for your containers. Effortlessly navigate between processes inside your container to hosts your containers run on, arranged in expandable, sortable tables. Easily find the container using the most CPU or memory for a given host or service. +View contextual metrics, tags, and metadata for your containers. Effortlessly navigate between processes inside your container to hosts your containers run on, arranged in expandable, sortable tables. Easily find the container using the most CPU or memory for a given host or service. ### Interact with and manage containers Launch a command line. -Interact with your containers directly: pause, restart and stop containers. Launch a command line. All without leaving the scope browser window. +Interact with your containers directly: pause, restart, and stop containers. Launch a command line. All without leaving the scope browser window. ### Extend and customize via plugins -Add custom details or interactions for your hosts, containers and/or processes by creating Scope plugins; or just choose from some that others have already written at the Github [Weaveworks Scope Plugins](https://github.com/weaveworks-plugins/) organization. +Add custom details or interactions for your hosts, containers, and/or processes by creating Scope plugins. Or, just choose from some that others have already written at the GitHub [Weaveworks Scope Plugins](https://github.com/weaveworks-plugins/) organization. -## Getting started +## Getting Started ```console sudo curl -L git.io/scope -o /usr/local/bin/scope @@ -44,18 +44,18 @@ This script downloads and runs a recent Scope image from Docker Hub. Now, open your web browser to **http://localhost:4040**. (If you're using boot2docker, replace localhost with the output of `boot2docker ip`.) -For instructions on installing Scope on [Kubernetes](https://www.weave.works/docs/scope/latest/installing/#k8s), [DCOS](https://www.weave.works/docs/scope/latest/installing/#dcos) or [ECS](https://www.weave.works/docs/scope/latest/installing/#ecs), see [the docs](https://www.weave.works/docs/scope/latest/introducing/). +For instructions on installing Scope on [Kubernetes](https://www.weave.works/docs/scope/latest/installing/#k8s), [DCOS](https://www.weave.works/docs/scope/latest/installing/#dcos), or [ECS](https://www.weave.works/docs/scope/latest/installing/#ecs), see [the docs](https://www.weave.works/docs/scope/latest/introducing/). -## Getting help +## Getting Help -If you have any questions about, feedback for or problems with Scope: +If you have any questions, feedback, or problems with Scope: - Read [the Weave Scope docs](https://www.weave.works/docs/scope/latest/introducing/). -- Invite yourself to the Weave community slack. -- Ask a question on the [#scope](https://weave-community.slack.com/messages/scope/) slack channel. +- Invite yourself to the Weave community Slack. +- Ask a question on the [#scope](https://weave-community.slack.com/messages/scope/) Slack channel. - Join the [Weave User Group](https://www.meetup.com/pro/Weave/) and get invited to online talks, hands-on training and meetups in your area. - Send an email to [Scope community group](https://groups.google.com/forum/#!forum/scope-community). - Join (and read up on) the regular [Scope community meetings](https://docs.google.com/document/d/103_60TuEkfkhz_h2krrPJH8QOx-vRnPpbcCZqrddE1s/edit). - [File an issue](https://github.com/weaveworks/scope/issues/new). -Your feedback is always welcome! \ No newline at end of file +Your feedback is always welcome! From 4dd6f4cd2bdaa3ade85ce79e6e70b2c039156e0b Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Wed, 10 Oct 2018 15:56:33 +0100 Subject: [PATCH 18/23] Create UI toolchain dirs from Makefile To prevent docker from creating it with root as the owner --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index bde1bfbef..608b00e90 100644 --- a/Makefile +++ b/Makefile @@ -147,6 +147,7 @@ SCOPE_UI_TOOLCHAIN=.cache/build_node_modules SCOPE_UI_TOOLCHAIN_UPTODATE=$(SCOPE_UI_TOOLCHAIN)/.uptodate $(SCOPE_UI_TOOLCHAIN_UPTODATE): client/yarn.lock $(SCOPE_UI_BUILD_UPTODATE) + mkdir -p $(SCOPE_UI_TOOLCHAIN) client/node_modules if test "true" != "$(SCOPE_SKIP_UI_ASSETS)"; then \ $(SUDO) docker run $(RM) $(RUN_FLAGS) \ -v $(shell pwd)/.cache:/home/weave/scope/.cache \ From 64197d15bebcc668480523cde465953780fe10d1 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 13 Oct 2018 12:46:14 +0000 Subject: [PATCH 19/23] Rate limit report publishing So that, if many shortcut reports are produced in quick succession, they will tend to get merged together. Expand the queue size for shortcut reports, to avoid holding up the producer so much. --- probe/probe.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/probe/probe.go b/probe/probe.go index b34f21cde..1e386850d 100644 --- a/probe/probe.go +++ b/probe/probe.go @@ -1,17 +1,20 @@ package probe import ( + "context" "sync" "time" "github.com/armon/go-metrics" log "github.com/sirupsen/logrus" + "golang.org/x/time/rate" "github.com/weaveworks/scope/report" ) const ( - reportBufferSize = 16 + spiedReportBufferSize = 16 + shortcutReportBufferSize = 1024 ) // ReportPublisher publishes reports, probably to a remote collector. @@ -23,6 +26,7 @@ type ReportPublisher interface { type Probe struct { spyInterval, publishInterval time.Duration publisher ReportPublisher + rateLimiter *rate.Limiter noControls bool tickers []Ticker @@ -79,10 +83,11 @@ func New( spyInterval: spyInterval, publishInterval: publishInterval, publisher: publisher, + rateLimiter: rate.NewLimiter(rate.Every(publishInterval)*10, 1), noControls: noControls, quit: make(chan struct{}), - spiedReports: make(chan report.Report, reportBufferSize), - shortcutReports: make(chan report.Report, reportBufferSize), + spiedReports: make(chan report.Report, spiedReportBufferSize), + shortcutReports: make(chan report.Report, shortcutReportBufferSize), } return result } @@ -197,6 +202,7 @@ func (p *Probe) tag(r report.Report) report.Report { } func (p *Probe) drainAndPublish(rpt report.Report, rs chan report.Report) { + p.rateLimiter.Wait(context.Background()) ForLoop: for { select { From b6d4538663225d0f3ea6088494a3e408dcd8c05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Skowro=C5=84ski?= Date: Sat, 13 Oct 2018 19:13:52 +0200 Subject: [PATCH 20/23] scripts: replace share icon with sitemap (graph) fix confusing graph icon Fixes #2511 --- client/app/scripts/components/view-mode-selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/scripts/components/view-mode-selector.js b/client/app/scripts/components/view-mode-selector.js index b915bae3a..0451ae0bf 100644 --- a/client/app/scripts/components/view-mode-selector.js +++ b/client/app/scripts/components/view-mode-selector.js @@ -29,7 +29,7 @@ class ViewModeSelector extends React.Component {
From 52024d8b482a1016021692f2fb6866988472981b Mon Sep 17 00:00:00 2001 From: "Timm, Christopher" Date: Sat, 13 Oct 2018 17:48:19 -0500 Subject: [PATCH 21/23] build: Fix import for golint The import path for golint has changed Fixes #3388 --- backend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 48d932d43..952a30643 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -19,7 +19,7 @@ RUN go clean -i net && \ fi; \ go get -tags netgo \ github.com/fzipp/gocyclo \ - github.com/golang/lint/golint \ + golang.org/x/lint/golint \ github.com/kisielk/errcheck \ github.com/fatih/hclfmt \ github.com/mjibson/esc \ From 195c4e030ef18ea22bdbbc257a216665a55f9a4b Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 14 Oct 2018 12:04:03 +0000 Subject: [PATCH 22/23] Raise report publishing rate to 30ms default --- probe/probe.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probe/probe.go b/probe/probe.go index 1e386850d..4e9bac59e 100644 --- a/probe/probe.go +++ b/probe/probe.go @@ -83,7 +83,7 @@ func New( spyInterval: spyInterval, publishInterval: publishInterval, publisher: publisher, - rateLimiter: rate.NewLimiter(rate.Every(publishInterval)*10, 1), + rateLimiter: rate.NewLimiter(rate.Every(publishInterval/100), 1), noControls: noControls, quit: make(chan struct{}), spiedReports: make(chan report.Report, spiedReportBufferSize), From b82aff121068e4c1cd16b968723bc2e631dd360d Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 14 Oct 2018 15:24:34 +0000 Subject: [PATCH 23/23] Discard pod updates for other nodes We were filtering pods to those on the local node already, for regular reports, so we should also filter events that come in asynchronously. --- probe/kubernetes/reporter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/probe/kubernetes/reporter.go b/probe/kubernetes/reporter.go index 3dfa8c793..dffccfdf5 100644 --- a/probe/kubernetes/reporter.go +++ b/probe/kubernetes/reporter.go @@ -193,6 +193,10 @@ func (r *Reporter) Stop() { func (Reporter) Name() string { return "K8s" } func (r *Reporter) podEvent(e Event, pod Pod) { + // filter out non-local pods, if we have been given a node name to report on + if r.nodeName != "" && pod.NodeName() != r.nodeName { + return + } switch e { case ADD: rpt := report.MakeReport()