Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ os:
go_import_path: github.com/kata-containers/runtime

go:
- "1.10.x"
- "1.11.x"

env:
- target_branch=$TRAVIS_BRANCH
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ See the

## Architecture overview

See the [architecture overview](https://github.com/kata-containers/documentation/blob/master/architecture.md)
See the [architecture overview](https://github.com/kata-containers/documentation/blob/master/design/architecture.md)
for details on the Kata Containers design.

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ EXAMPLE:
}

args := context.Args()
if args.Present() == false {
if !args.Present() {
return fmt.Errorf("Missing container ID, should at least provide one")
}

Expand Down
1 change: 1 addition & 0 deletions cli/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var initFactoryCommand = cli.Command{
HypervisorConfig: runtimeConfig.HypervisorConfig,
AgentType: runtimeConfig.AgentType,
AgentConfig: runtimeConfig.AgentConfig,
ProxyType: runtimeConfig.ProxyType,
},
}
kataLog.WithField("factory", factoryConfig).Info("create vm factory")
Expand Down
7 changes: 7 additions & 0 deletions cli/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
vc "github.com/kata-containers/runtime/virtcontainers"
)

const testDisabledAsNonRoot = "Test disabled as requires root privileges"

func TestFactoryCLIFunctionNoRuntimeConfig(t *testing.T) {
assert := assert.New(t)

Expand Down Expand Up @@ -63,9 +65,14 @@ func TestFactoryCLIFunctionInit(t *testing.T) {
assert.Nil(err)

// With template
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}

runtimeConfig.FactoryConfig.Template = true
runtimeConfig.HypervisorType = vc.MockHypervisor
runtimeConfig.AgentType = vc.NoopAgentType
runtimeConfig.ProxyType = vc.NoopProxyType
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
fn, ok = initFactoryCommand.Action.(func(context *cli.Context) error)
assert.True(ok)
Expand Down
7 changes: 4 additions & 3 deletions cli/kata-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const (
kernelPropertyCorrect = "Kernel property value correct"

// these refer to fields in the procCPUINFO file
genericCPUFlagsTag = "flags" // nolint: varcheck, unused
genericCPUVendorField = "vendor_id" // nolint: varcheck, unused
genericCPUModelField = "model name" // nolint: varcheck, unused
genericCPUFlagsTag = "flags" // nolint: varcheck, unused, deadcode
genericCPUVendorField = "vendor_id" // nolint: varcheck, unused, deadcode
genericCPUModelField = "model name" // nolint: varcheck, unused, deadcode
)

// variables rather than consts to allow tests to modify them
Expand Down Expand Up @@ -243,6 +243,7 @@ func checkKernelModules(modules map[string]kernelModule, handler kernelParamHand

// genericHostIsVMContainerCapable checks to see if the host is theoretically capable
// of creating a VM container.
//nolint: unused,deadcode
func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error {
cpuinfo, err := getCPUInfo(details.cpuInfoFile)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions cli/kata-check_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,50 +400,50 @@ func TestArchKernelParamHandler(t *testing.T) {

type testData struct {
onVMM bool
expectIgnore bool
fields logrus.Fields
msg string
expectIgnore bool
}

data := []testData{
{true, logrus.Fields{}, "", false},
{false, logrus.Fields{}, "", false},
{true, false, logrus.Fields{}, ""},
{false, false, logrus.Fields{}, ""},

{
false,
false,
logrus.Fields{
// wrong type
"parameter": 123,
},
"foo",
false,
},

{
false,
false,
logrus.Fields{
"parameter": "unrestricted_guest",
},
"",
false,
},

{
true,
true,
logrus.Fields{
"parameter": "unrestricted_guest",
},
"",
true,
},

{
false,
true,
logrus.Fields{
"parameter": "nested",
},
"",
true,
},
}

Expand Down
14 changes: 7 additions & 7 deletions cli/kata-check_ppc64le_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,50 +124,50 @@ func TestArchKernelParamHandler(t *testing.T) {

type testData struct {
onVMM bool
expectIgnore bool
fields logrus.Fields
msg string
expectIgnore bool
}

data := []testData{
{true, logrus.Fields{}, "", false},
{false, logrus.Fields{}, "", false},
{true, false, logrus.Fields{}, ""},
{false, false, logrus.Fields{}, ""},

{
false,
false,
logrus.Fields{
// wrong type
"parameter": 123,
},
"foo",
false,
},

{
false,
false,
logrus.Fields{
"parameter": "unrestricted_guest",
},
"",
false,
},

{
true,
true,
logrus.Fields{
"parameter": "unrestricted_guest",
},
"",
true,
},

{
false,
true,
logrus.Fields{
"parameter": "nested",
},
"",
true,
},
}

Expand Down
6 changes: 3 additions & 3 deletions cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ type testModuleData struct {
contents string
}

// nolint: structcheck, unused
// nolint: structcheck, unused, deadcode
type testCPUData struct {
vendorID string
flags string
expectError bool
}

// nolint: structcheck, unused
// nolint: structcheck, unused, deadcode
type testCPUDetail struct {
contents string
expectedVendor string
Expand Down Expand Up @@ -147,7 +147,7 @@ func makeCPUInfoFile(path, vendorID, flags string) error {
return ioutil.WriteFile(path, contents.Bytes(), testFileMode)
}

// nolint: unused
// nolint: unused, deadcode
func genericTestGetCPUDetails(t *testing.T, validVendor string, validModel string, validContents string, data []testCPUDetail) {
tmpdir, err := ioutil.TempDir("", "")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/kata-env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
}, nil
}

// nolint: unused
// nolint: unused, deadcode
func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expectedModel string, expectedVMContainerCapable bool) (HostInfo, error) {
type filesToCreate struct {
file string
Expand Down
2 changes: 1 addition & 1 deletion cli/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ EXAMPLE:
}

args := context.Args()
if args.Present() == false {
if !args.Present() {
return fmt.Errorf("Missing container ID")
}

Expand Down
2 changes: 1 addition & 1 deletion cli/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func validCreateParams(ctx context.Context, containerID, bundlePath string) (str
if err != nil {
return "", fmt.Errorf("Invalid bundle path '%s': %s", bundlePath, err)
}
if fileInfo.IsDir() == false {
if !fileInfo.IsDir() {
return "", fmt.Errorf("Invalid bundle path '%s', it should be a directory", bundlePath)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var psCLICommand = cli.Command{
return err
}

if context.Args().Present() == false {
if !context.Args().Present() {
return fmt.Errorf("Missing container ID, should at least provide one")
}

Expand Down
2 changes: 1 addition & 1 deletion cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var startCLICommand = cli.Command{
}

args := context.Args()
if args.Present() == false {
if !args.Present() {
return fmt.Errorf("Missing container ID, should at least provide one")
}

Expand Down
2 changes: 1 addition & 1 deletion cli/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ other options are ignored.
span, _ := katautils.Trace(ctx, "update")
defer span.Finish()

if context.Args().Present() == false {
if !context.Args().Present() {
return fmt.Errorf("Missing container ID, should at least provide one")
}

Expand Down
4 changes: 1 addition & 3 deletions containerd-shim-v2/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ func statsToMetrics(cgStats *vc.CgroupStats) *cgroups.Metrics {
}

var perCPU []uint64
for _, v := range cgStats.CPUStats.CPUUsage.PercpuUsage {
perCPU = append(perCPU, v)
}
perCPU = append(perCPU, cgStats.CPUStats.CPUUsage.PercpuUsage...)

metrics := &cgroups.Metrics{
Hugetlb: hugetlb,
Expand Down
6 changes: 2 additions & 4 deletions containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (*ptypes.E
}

s.send(&eventstypes.TaskPaused{
c.id,
ContainerID: c.id,
})

return empty, err
Expand Down Expand Up @@ -620,7 +620,7 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (*ptypes
}

s.send(&eventstypes.TaskResumed{
c.id,
ContainerID: c.id,
})

return empty, err
Expand Down Expand Up @@ -838,8 +838,6 @@ func (s *service) checkProcesses(e exit) {
ExitStatus: uint32(e.status),
ExitedAt: e.timestamp,
})

return
}

func (s *service) getContainer(id string) (*container, error) {
Expand Down
2 changes: 1 addition & 1 deletion containerd-shim-v2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func validBundle(containerID, bundlePath string) (string, error) {
if err != nil {
return "", fmt.Errorf("Invalid bundle path '%s': %s", bundlePath, err)
}
if fileInfo.IsDir() == false {
if !fileInfo.IsDir() {
return "", fmt.Errorf("Invalid bundle path '%s', it should be a directory", bundlePath)
}

Expand Down
16 changes: 11 additions & 5 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,13 @@ func (h hypervisor) getInitrdAndImage() (initrd string, image string, err error)
return
}

func (p proxy) path() string {
if p.Path == "" {
return defaultProxyPath
func (p proxy) path() (string, error) {
path := p.Path
if path == "" {
path = defaultProxyPath
}

return p.Path
return ResolvePath(path)
}

func (p proxy) debug() bool {
Expand Down Expand Up @@ -606,8 +607,13 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc
config.ProxyType = vc.KataProxyType
}

path, err := proxy.path()
if err != nil {
return err
}

config.ProxyConfig = vc.ProxyConfig{
Path: proxy.path(),
Path: path,
Debug: proxy.debug(),
}
}
Expand Down
Loading