Skip to content

Building cAdvisor

aborkar-ibm edited this page Feb 4, 2019 · 53 revisions

Building cAdvisor

Below versions of cAdvisor are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 16.04 has 0.20.5
  • Ubuntu 18.04 has 0.27.1

The instructions provided below specify the steps to build cAdvisor version 0.32.0 on Linux on IBM Z for the following distributions:

  • RHEL (7.4, 7.5, 7.6)
  • SLES (12 SP3, 15)
  • Ubuntu (16.04, 18.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writeable directory anywhere you'd like to place it.
  • It is recommended to use cadvisor >= 0.23.9 on Kernel version >= 4.4 for SLES & Ubuntu, Kernel version >= 3.10.0-366 for RHEL in order to avoid inconsistent fs usage data from device thin pool. Click here for details.

Step 1: Build using script

If you want to build cAdvisor using manual steps, go to STEP 2.

Use the following commands to build cAdvisor using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/cAdvisor/build_cadvisor.sh

# Build cAdvisor
bash build_cadvisor.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 9. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install the dependencies

  • RHEL (7.4, 7.5, 7.6)

    sudo yum install -y curl git libseccomp-devel golang
  • SLES (12 SP3, 15)

    sudo zypper install -y curl git libseccomp-devel wget tar gcc
    • Install Go 1.10.5
      cd /<source_root>/
      wget https://dl.google.com/go/go1.10.5.linux-s390x.tar.gz
      sudo tar -C /usr/local -xzf go1.10.5.linux-s390x.tar.gz
      export PATH=$PATH:/usr/local/go/bin
      sudo ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc
      Note: Make sure to set GOROOT environment variable to point to GO Installation directory.
  • Ubuntu (16.04, 18.04)

    sudo apt-get update
    sudo apt-get install -y curl git golang-1.10 libseccomp-dev
    export PATH=/usr/lib/go-1.10/bin/:$PATH

Step 3: Export GO path

export GOPATH=/<source_root>/ 
export PATH=$PATH:$GOPATH/bin

Step 4: Install godep tool

cd /<source_root>/
go get github.com/tools/godep

Step 5: Checkout the source code from github

mkdir -p $GOPATH/src/github.com/google
cd $GOPATH/src/github.com/google
git clone https://github.com/google/cadvisor.git
cd cadvisor
git checkout v0.32.0

Step 6: Add below code at the end of the file

  • Append changes to the file $GOPATH/src/github.com/google/cadvisor/vendor/github.com/klauspost/crc32/crc32.go
    func updateCastagnoli(crc uint32, p []byte) uint32 {
            // only use slicing-by-8 when input is >= 16 Bytes
            if len(p) >= 16 {
                    return updateSlicingBy8(crc, castagnoliTable8, p)
            }
            return update(crc, castagnoliTable, p)
    }
    
    func updateIEEE(crc uint32, p []byte) uint32 {
            // only use slicing-by-8 when input is >= 16 Bytes
            if len(p) >= 16 {
                    iEEETable8Once.Do(func() {
                            iEEETable8 = makeTable8(IEEE)
                    })
                    return updateSlicingBy8(crc, iEEETable8, p)
            }
            return update(crc, IEEETable, p)
    }
    
    Note: cAdvisor uses 'klauspost/crc32' over standard crc32 library of golang which is optimized for x64 platform. We add the above code to align it with Go standard library hash/crc32.

Step 7: Build cAdvisor

cd $GOPATH/src/github.com/google/cadvisor
godep go build .
sudo cp ${GOPATH}/src/github.com/google/cadvisor/cadvisor /usr/bin/

Step 8: Run unit tests (Optional)

cd $GOPATH/src/github.com/google/cadvisor 
go test -short `go list ./... | grep -v Microsoft`

Notes:

  • Microsoft related tests will be skipped.
  • Ignore TestTopology failure as it is known issue on system Z.

Step 9: Run cAdvisor

sudo cadvisor

Step 10: Access cAdvisor web user interface from browser

http://<host-ip>:<http-port>/

Note: Default port number for cAdvisor is 8080

References:

Clone this wiki locally