Add ability for ubuntu to be tested

unfortunately the papr CI system cannot test ubuntu as a VM; therefore,
this PR still keeps travis.  but it does include fixes that will be required
for running on modern versions of ubuntu.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2018-10-01 12:10:46 -05:00
parent 230edff521
commit 14473270d7
9 changed files with 130 additions and 30 deletions

View File

@ -26,37 +26,14 @@ env:
jobs: jobs:
include: include:
- stage: Build and Verify
script:
- make gofmt
- make lint
go: 1.10.x
- script:
- make gofmt
- make lint
go: 1.10.x
os: osx
- script:
- make testunit
go: 1.9.x
- stage: Build and Verify - stage: Build and Verify
script: script:
- make testunit - make testunit
go: 1.10.x go: 1.10.x
- script:
- make --keep-going local-cross
go: 1.10.x
- script:
- make --keep-going local-cross
go: 1.10.x
os: osx
env: ALLOWED_TO_FAIL=true
- stage: Integration Test - stage: Integration Test
script: script:
- make integration - make integration
go: 1.9.x go: 1.9.x
allow_failures:
- env: ALLOWED_TO_FAIL=true
notifications: notifications:
irc: "chat.freenode.net#podman" irc: "chat.freenode.net#podman"

71
.ubuntu_prepare.sh Normal file
View File

@ -0,0 +1,71 @@
#!/bin/bash
set -xeuo pipefail
export GOPATH=/go
export PATH=$HOME/gopath/bin:$PATH:$GOPATH/bin
runc=0
conmon=0
cni=0
podman_conf=0
conmon_source=/go/src/github.com/containers/conmon
cni_source=/go/src/github.com/containernetworking/plugins
runc_source=/go/src/github.com/opencontainers/runc
podman_source=/var/tmp/checkout
while getopts "cnrf" opt; do
case "$opt" in
c) conmon=1
;;
f) podman_conf=1
;;
n) cni=1
;;
r) runc=1
;;
*) echo "Nothing to do ... exiting."
exit 0
;;
esac
done
if [ $conmon -eq 1 ]; then
# Build and install conmon from source
echo "Building conmon ..."
git clone http://github.com/containers/conmon $conmon_source
cd $conmon_source && make install PREFIX=/usr
fi
if [ $cni -eq 1 ]; then
# Build and install containernetworking plugins from source
echo "Building containernetworking-plugins..."
git clone http://github.com/containernetworking/plugins $cni_source
cd $cni_source
./build.sh
mkdir -p /usr/libexec/cni
cp -v bin/* /usr/libexec/cni/
fi
if [ $runc -eq 1 ]; then
# Build and install runc
echo "Building runc..."
git clone http://github.com/opencontainers/runc $runc_source
cd $runc_source
make install PREFIX=/usr
fi
if [ $podman_conf -eq 1 ]; then
# Install various configuration files required by libpod
# Install CNI conf file for podman
mkdir -p /etc/cni/net.d
cp -v $podman_source/cni/87-podman-bridge.conflist /etc/cni/net.d/
# Install registries.conf
mkdir -p /etc/containers
cp -v $podman_source/test/registries.conf /etc/containers/
cp -v $podman_source/test/policy.json /etc/containers/
fi

View File

@ -1342,3 +1342,10 @@ func (c *Container) unmount(force bool) error {
return nil return nil
} }
// getExcludedCGroups returns a string slice of cgroups we want to exclude
// because runc or other components are unaware of them.
func getExcludedCGroups() (excludes []string) {
excludes = []string{"rdma"}
return
}

View File

@ -265,7 +265,8 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
} }
case CgroupfsCgroupsManager: case CgroupfsCgroupsManager:
// Delete the cgroupfs cgroup // Delete the cgroupfs cgroup
cgroup, err := cgroups.Load(cgroups.V1, cgroups.StaticPath(p.state.CgroupPath)) v1CGroups := GetV1CGroups(getExcludedCGroups())
cgroup, err := cgroups.Load(v1CGroups, cgroups.StaticPath(p.state.CgroupPath))
if err != nil && err != cgroups.ErrCgroupDeleted { if err != nil && err != cgroups.ErrCgroupDeleted {
return err return err
} else if err == nil { } else if err == nil {

View File

@ -33,13 +33,14 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
if err != nil { if err != nil {
return nil, err return nil, err
} }
v1CGroups := GetV1CGroups(getExcludedCGroups())
cgroup, err := cgroups.Load(cgroups.V1, cgroups.StaticPath(cgroupPath)) cgroup, err := cgroups.Load(v1CGroups, cgroups.StaticPath(cgroupPath))
if err != nil { if err != nil {
return stats, errors.Wrapf(err, "unable to load cgroup at %s", cgroupPath) return stats, errors.Wrapf(err, "unable to load cgroup at %s", cgroupPath)
} }
cgroupStats, err := cgroup.Stat() // Ubuntu does not have swap memory in cgroups because swap is often not enabled.
cgroupStats, err := cgroup.Stat(cgroups.IgnoreNotExist)
if err != nil { if err != nil {
return stats, errors.Wrapf(err, "unable to obtain cgroup stats") return stats, errors.Wrapf(err, "unable to obtain cgroup stats")
} }

View File

@ -9,8 +9,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/containerd/cgroups"
"github.com/containers/image/signature" "github.com/containers/image/signature"
"github.com/containers/image/types" "github.com/containers/image/types"
"github.com/containers/libpod/pkg/util"
spec "github.com/opencontainers/runtime-spec/specs-go" spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -160,3 +162,26 @@ func validPodNSOption(p *Pod, ctrPod string) error {
} }
return nil return nil
} }
// GetV1CGroups gets the V1 cgroup subsystems and then "filters"
// out any subsystems that are provided by the caller. Passing nil
// for excludes will return the subsystems unfiltered.
//func GetV1CGroups(excludes []string) ([]cgroups.Subsystem, error) {
func GetV1CGroups(excludes []string) cgroups.Hierarchy {
return func() ([]cgroups.Subsystem, error) {
var filtered []cgroups.Subsystem
subSystem, err := cgroups.V1()
if err != nil {
return nil, err
}
for _, s := range subSystem {
// If the name of the subsystem is not in the list of excludes, then
// add it as a keeper.
if !util.StringInSlice(string(s.Name()), excludes) {
filtered = append(filtered, s)
}
}
return filtered, nil
}
}

View File

@ -63,6 +63,7 @@ type PodmanTest struct {
ArtifactPath string ArtifactPath string
TempDir string TempDir string
CgroupManager string CgroupManager string
Host HostOS
} }
// HostOS is a simple struct for the test os // HostOS is a simple struct for the test os
@ -126,6 +127,7 @@ func CreateTempDirInTempDir() (string, error) {
// PodmanCreate creates a PodmanTest instance for the tests // PodmanCreate creates a PodmanTest instance for the tests
func PodmanCreate(tempDir string) PodmanTest { func PodmanCreate(tempDir string) PodmanTest {
host := GetHostDistributionInfo()
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
podmanBinary := filepath.Join(cwd, "../../bin/podman") podmanBinary := filepath.Join(cwd, "../../bin/podman")
@ -149,7 +151,19 @@ func PodmanCreate(tempDir string) PodmanTest {
cgroupManager = os.Getenv("CGROUP_MANAGER") cgroupManager = os.Getenv("CGROUP_MANAGER")
} }
runCBinary := "/usr/bin/runc" // Ubuntu doesn't use systemd cgroups
if host.Distribution == "ubuntu" {
cgroupManager = "cgroupfs"
}
runCBinary, err := exec.LookPath("runc")
// If we cannot find the runc binary, setting to something static as we have no way
// to return an error. The tests will fail and point out that the runc binary could
// not be found nicely.
if err != nil {
runCBinary = "/usr/bin/runc"
}
CNIConfigDir := "/etc/cni/net.d" CNIConfigDir := "/etc/cni/net.d"
p := PodmanTest{ p := PodmanTest{
@ -164,6 +178,7 @@ func PodmanCreate(tempDir string) PodmanTest {
ArtifactPath: ARTIFACT_DIR, ArtifactPath: ARTIFACT_DIR,
TempDir: tempDir, TempDir: tempDir,
CgroupManager: cgroupManager, CgroupManager: cgroupManager,
Host: host,
} }
// Setup registries.conf ENV variable // Setup registries.conf ENV variable

View File

@ -45,7 +45,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
Specify("no --cgroup-parent", func() { Specify("no --cgroup-parent", func() {
cgroup := "/libpod_parent" cgroup := "/libpod_parent"
if !containerized() { if !containerized() && podmanTest.CgroupManager != "cgroupfs" {
cgroup = "/machine.slice" cgroup = "/machine.slice"
} }
run := podmanTest.Podman([]string{"run", fedoraMinimal, "cat", "/proc/self/cgroup"}) run := podmanTest.Podman([]string{"run", fedoraMinimal, "cat", "/proc/self/cgroup"})
@ -56,7 +56,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
}) })
Specify("valid --cgroup-parent using slice", func() { Specify("valid --cgroup-parent using slice", func() {
if containerized() { if containerized() || podmanTest.CgroupManager == "cgroupfs" {
Skip("Requires Systemd cgroup manager support") Skip("Requires Systemd cgroup manager support")
} }
cgroup := "aaaa.slice" cgroup := "aaaa.slice"

View File

@ -39,6 +39,9 @@ var _ = Describe("Podman run memory", func() {
}) })
It("podman run memory-reservation test", func() { It("podman run memory-reservation test", func() {
if podmanTest.Host.Distribution == "ubuntu" {
Skip("Unable to perform test on Ubuntu distributions due to memory management")
}
session := podmanTest.Podman([]string{"run", "--memory-reservation=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"}) session := podmanTest.Podman([]string{"run", "--memory-reservation=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))