diff --git a/src/runtime/virtcontainers/documentation/Developers.md b/src/runtime/virtcontainers/documentation/Developers.md index cbeeac3c46..3949a596bd 100644 --- a/src/runtime/virtcontainers/documentation/Developers.md +++ b/src/runtime/virtcontainers/documentation/Developers.md @@ -2,13 +2,9 @@ `virtcontainers` has a few prerequisites for development: -- docker - CNI - golang -A number of these can be installed using the -[virtcontainers-setup.sh](../utils/virtcontainers-setup.sh) script. - # Building To build `virtcontainers`, at the top level directory run: @@ -43,4 +39,3 @@ This will: For details on the format and how to submit changes, refer to the [Contributing](../../../../CONTRIBUTING.md) document. - diff --git a/src/runtime/virtcontainers/utils/utils.go b/src/runtime/virtcontainers/utils/utils.go index a709eb18ec..caf5965858 100644 --- a/src/runtime/virtcontainers/utils/utils.go +++ b/src/runtime/virtcontainers/utils/utils.go @@ -112,7 +112,7 @@ func WriteToFile(path string, data []byte) error { return nil } -//CalculateMilliCPUs converts CPU quota and period to milli-CPUs +// CalculateMilliCPUs converts CPU quota and period to milli-CPUs func CalculateMilliCPUs(quota int64, period uint64) uint32 { // If quota is -1, it means the CPU resource request is @@ -125,27 +125,12 @@ func CalculateMilliCPUs(quota int64, period uint64) uint32 { return 0 } -//CalculateVCpusFromMilliCpus converts from mCPU to CPU, taking the ceiling +// CalculateVCpusFromMilliCpus converts from mCPU to CPU, taking the ceiling // value when necessary func CalculateVCpusFromMilliCpus(mCPU uint32) uint32 { return (mCPU + 999) / 1000 } -// ConstraintsToVCPUs converts CPU quota and period to vCPUs -func ConstraintsToVCPUs(quota int64, period uint64) uint { - if quota != 0 && period != 0 { - // Use some math magic to round up to the nearest whole vCPU - // (that is, a partial part of a quota request ends up assigning - // a whole vCPU, for instance, a request of 1.5 'cpu quotas' - // will give 2 vCPUs). - // This also has the side effect that we will always allocate - // at least 1 vCPU. - return uint((uint64(quota) + (period - 1)) / period) - } - - return 0 -} - // GetVirtDriveName returns the disk name format for virtio-blk // Reference: https://github.com/torvalds/linux/blob/master/drivers/block/virtio_blk.c @c0aa3e0916d7e531e69b02e426f7162dfb1c6c0 func GetVirtDriveName(index int) (string, error) { diff --git a/src/runtime/virtcontainers/utils/utils_test.go b/src/runtime/virtcontainers/utils/utils_test.go index 99e533feee..7c50723d28 100644 --- a/src/runtime/virtcontainers/utils/utils_test.go +++ b/src/runtime/virtcontainers/utils/utils_test.go @@ -170,23 +170,6 @@ func TestCaluclateVCpusFromMilliCpus(t *testing.T) { assert.Equal(n, expected) } -func TestConstraintsToVCPUs(t *testing.T) { - assert := assert.New(t) - - vcpus := ConstraintsToVCPUs(0, 100) - assert.Zero(vcpus) - - vcpus = ConstraintsToVCPUs(100, 0) - assert.Zero(vcpus) - - expectedVCPUs := uint(4) - vcpus = ConstraintsToVCPUs(4000, 1000) - assert.Equal(expectedVCPUs, vcpus) - - vcpus = ConstraintsToVCPUs(4000, 1200) - assert.Equal(expectedVCPUs, vcpus) -} - func TestGetVirtDriveNameInvalidIndex(t *testing.T) { assert := assert.New(t) _, err := GetVirtDriveName(-1) diff --git a/src/runtime/virtcontainers/utils/virtcontainers-setup.sh b/src/runtime/virtcontainers/utils/virtcontainers-setup.sh deleted file mode 100755 index ef56c220a7..0000000000 --- a/src/runtime/virtcontainers/utils/virtcontainers-setup.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2017,2018 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -SCRIPT_PATH=$(dirname $(readlink -f $0)) - -if [ ! $(command -v go) ]; then - echo "This script requires go to be installed and executable" - exit 1 -fi - -GOPATH=$(go env "GOPATH") - -if [ ! $(command -v docker) ]; then - echo "This script requires docker to be installed and executable" - exit 1 -fi - -if [ ! $(command -v git) ]; then - echo "This script requires git to be installed and executable" - exit 1 -fi - -tmpdir=$(mktemp -d) -virtcontainers_build_dir="virtcontainers/build" -echo -e "Create temporary build directory ${tmpdir}/${virtcontainers_build_dir}" -mkdir -p ${tmpdir}/${virtcontainers_build_dir} - -TMPDIR="${SCRIPT_PATH}/supportfiles" -OPTDIR="/opt" -ETCDIR="/etc" - -echo -e "Create ${TMPDIR}/cni/bin (needed by testing)" -rm -rf ${TMPDIR}/cni/bin -mkdir -p ${TMPDIR}/cni/bin -echo -e "Create cni directories ${OPTDIR}/cni/bin and ${ETCDIR}/cni/net.d" -sudo mkdir -p ${OPTDIR}/cni/bin -sudo mkdir -p ${ETCDIR}/cni/net.d - -bundlesdir="${TMPDIR}/bundles" -echo -e "Create bundles in ${bundlesdir}" -rm -rf ${bundlesdir} -busybox_bundle="${bundlesdir}/busybox" -mkdir -p ${busybox_bundle} -docker pull busybox -pushd ${busybox_bundle} -rootfsdir="rootfs" -mkdir ${rootfsdir} -docker export $(docker create busybox) | tar -C ${rootfsdir} -xvf - -echo -e '#!/bin/sh\ncd "\"\n"sh"' > ${rootfsdir}/.containerexec -echo -e 'HOME=/root\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\nTERM=xterm' > ${rootfsdir}/.containerenv -popd - -echo -e "Move to ${tmpdir}/${virtcontainers_build_dir}" -pushd ${tmpdir}/${virtcontainers_build_dir} -echo "Clone cni" -git clone https://github.com/containernetworking/plugins.git -pushd plugins -git checkout 7f98c94613021d8b57acfa1a2f0c8d0f6fd7ae5a - -echo "Copy CNI config files" -cp $GOPATH/src/github.com/kata-containers/runtime/virtcontainers/test/cni/10-mynet.conf ${ETCDIR}/cni/net.d/ -cp $GOPATH/src/github.com/kata-containers/runtime/virtcontainers/test/cni/99-loopback.conf ${ETCDIR}/cni/net.d/ - -./build.sh -cp ./bin/bridge ${TMPDIR}/cni/bin/cni-bridge -cp ./bin/loopback ${TMPDIR}/cni/bin/loopback -cp ./bin/host-local ${TMPDIR}/cni/bin/host-local -popd -popd -sudo cp ${TMPDIR}/cni/bin/* ${OPTDIR}/cni/bin/ - -rm -rf ${tmpdir}