From 625998b91e46142f2d29b1a51b568ecb30027217 Mon Sep 17 00:00:00 2001 From: meghalidhoble Date: Wed, 20 Jun 2018 12:44:46 +0530 Subject: [PATCH] Change made to the listed files, to enable weaveworks-scope on Power(ppc64le) 1)backend/Dockerfile 2) probe/endpoint/dns_snooper.go 3) client/Dockerfile 4) docker/Dockerfile.cloud-agent 5) probe/process/walker_linux_test.go & 6) tools/lint 1)'backend/Dockerfile' : Conditional added so that the cross-compiling should be done on amd64. Also removed support for sh-lint for ppc64le for now. As the version for shfmt mentioned in the dockerfile is not available for ppc64le and the later version does't work fine with existing application. 2)'probe/endpoint/dns_snooper.go' : Renamed this file so as to reuse for ppc64le and added a build-constraint. Now this file will be build for amd64 on linux and ppc64le on linux. 3)'client/Dockerfile' : Modified the version of the base image for node from 8.4.0 to 8.11, as this version supports multiarch. 4)'docker/Dockerfile.cloud-agent' : Modified the version of the base image for golang from 1.10.2-strech to 1.10.2, which supports multiarch. 5) 'probe/process/walker_linux_test.go' : Test fixed to run for ppc64le, modified the code to accept RSSBytes based on pageSize value per architecture, instead of hard-coded values. 6)'tools/lint' : Modified the file to skip the sh-lint implementation for ppc64le. PR #3231 --- backend/Dockerfile | 32 ++++++++++++++----- client/Dockerfile | 2 +- docker/Dockerfile.cloud-agent | 2 +- ..._snooper_linux_amd64.go => dns_snooper.go} | 4 +++ probe/process/walker_linux_test.go | 5 ++- 5 files changed, 34 insertions(+), 11 deletions(-) rename probe/endpoint/{dns_snooper_linux_amd64.go => dns_snooper.go} (98%) diff --git a/backend/Dockerfile b/backend/Dockerfile index ed5a9c054..5bddcf8e3 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,14 +1,30 @@ -FROM golang:1.10.2-stretch +FROM golang:1.10.2 ENV SCOPE_SKIP_UI_ASSETS true -RUN apt-get update && \ - apt-get install -y libpcap-dev time file shellcheck git gcc-arm-linux-gnueabihf curl build-essential python-pip && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN set -eux; \ + export arch_val="$(dpkg --print-architecture)"; \ + apt-get update && \ + if [ "$arch_val" = "amd64" ]; then \ + apt-get install -y libpcap-dev python-requests time file shellcheck git gcc-arm-linux-gnueabihf curl build-essential python-pip; \ + else \ + apt-get install -y libpcap-dev python-requests time file shellcheck git curl build-essential python-pip; \ + fi; \ + \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + RUN go clean -i net && \ go install -tags netgo std && \ - go install -race -tags netgo std -RUN curl -fsSL -o shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \ - chmod +x shfmt && \ - mv shfmt /usr/bin + export arch_val="$(dpkg --print-architecture)"; \ + if [ "$arch_val" != "ppc64el" ]; then \ + go install -race -tags netgo std; \ + fi; +RUN export arch_val="$(dpkg --print-architecture)"; \ + if [ "$arch_val" = "amd64" ]; then \ + curl -fsSL -o shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \ + chmod +x shfmt && \ + mv shfmt /usr/bin; \ + fi; + # Skipped installing shfmt, as the version v1.3.0 isn't supported for ppc64le + # and the later version of shfmt doesn't work with the application well RUN go get -tags netgo \ github.com/fzipp/gocyclo \ github.com/golang/lint/golint \ diff --git a/client/Dockerfile b/client/Dockerfile index efaf52873..4c19dc2f2 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8.4.0 +FROM node:8.11 WORKDIR /home/weave COPY package.json yarn.lock /home/weave/ ENV NPM_CONFIG_LOGLEVEL=warn NPM_CONFIG_PROGRESS=false diff --git a/docker/Dockerfile.cloud-agent b/docker/Dockerfile.cloud-agent index edf768c86..627fcfa2b 100644 --- a/docker/Dockerfile.cloud-agent +++ b/docker/Dockerfile.cloud-agent @@ -1,4 +1,4 @@ -FROM alpine:3.5 +FROM alpine:3.7 WORKDIR /home/weave RUN apk add --update bash conntrack-tools iproute2 util-linux curl && \ rm -rf /var/cache/apk/* diff --git a/probe/endpoint/dns_snooper_linux_amd64.go b/probe/endpoint/dns_snooper.go similarity index 98% rename from probe/endpoint/dns_snooper_linux_amd64.go rename to probe/endpoint/dns_snooper.go index a755f364a..197b838fb 100644 --- a/probe/endpoint/dns_snooper_linux_amd64.go +++ b/probe/endpoint/dns_snooper.go @@ -1,3 +1,7 @@ +// +build linux,amd64 linux,ppc64le + +// Build constraint to use this file for amd64 & ppc64le on Linux + package endpoint import ( diff --git a/probe/process/walker_linux_test.go b/probe/process/walker_linux_test.go index cfa18d8d9..5de6fc9c4 100644 --- a/probe/process/walker_linux_test.go +++ b/probe/process/walker_linux_test.go @@ -1,6 +1,7 @@ package process_test import ( + "os" "reflect" "testing" @@ -79,9 +80,11 @@ var mockFS = fs.Dir("", func TestWalker(t *testing.T) { fs_hook.Mock(mockFS) defer fs_hook.Restore() + var pageSize uint64 + pageSize = (uint64)(os.Getpagesize() * 2) want := map[int]process.Process{ - 3: {PID: 3, PPID: 2, Name: "curl", Cmdline: "curl google.com", Threads: 1, RSSBytes: 8192, RSSBytesLimit: 2048, OpenFilesCount: 3, OpenFilesLimit: 32768}, + 3: {PID: 3, PPID: 2, Name: "curl", Cmdline: "curl google.com", Threads: 1, RSSBytes: pageSize, RSSBytesLimit: 2048, OpenFilesCount: 3, OpenFilesLimit: 32768}, 2: {PID: 2, PPID: 1, Name: "bash", Cmdline: "bash", Threads: 1, OpenFilesCount: 2}, 4: {PID: 4, PPID: 3, Name: "apache", Cmdline: "apache", Threads: 1, OpenFilesCount: 1}, 1: {PID: 1, PPID: 0, Name: "init", Cmdline: "init", Threads: 1, OpenFilesCount: 0},