Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Stable 1.5.1 rc #1281

Merged
merged 16 commits into from
Feb 28, 2019
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
43 changes: 0 additions & 43 deletions .pullapprove.yml

This file was deleted.

13 changes: 13 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#
# Define any code owners for this repository.
# The code owners lists are used to help automatically enforce
# reviews and acks of the right groups on the right PRs.

# Order in this file is important. Only the last match will be
# used. See https://help.github.com/articles/about-code-owners/

*.md @kata-containers/documentation

28 changes: 17 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ ifeq ($(SKIP_GO_VERSION_CHECK),)
include golang.mk
endif

#Get ARCH.
ifneq ($(GOPATH),)
GOARCH=$(shell go env GOARCH)
ifeq ($(ARCH),)
ARCH = $(GOARCH)
endif
else
ARCH = $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH = amd64
endif
endif

ARCH_DIR = arch
ARCH_FILE_SUFFIX = -options.mk
ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX)
ARCH_FILES = $(wildcard arch/*$(ARCH_FILE_SUFFIX))
ALL_ARCHES = $(patsubst $(ARCH_DIR)/%$(ARCH_FILE_SUFFIX),%,$(ARCH_FILES))
ARCH_DIR = arch
ARCH_FILE_SUFFIX = -options.mk
ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX)
ARCH_FILES = $(wildcard arch/*$(ARCH_FILE_SUFFIX))
ALL_ARCHES = $(patsubst $(ARCH_DIR)/%$(ARCH_FILE_SUFFIX),%,$(ARCH_FILES))

# Load architecture-dependent settings
include $(ARCH_FILE)
endif
# Load architecture-dependent settings
include $(ARCH_FILE)

PROJECT_TYPE = kata
PROJECT_NAME = Kata Containers
Expand Down Expand Up @@ -248,11 +254,11 @@ ifeq (,$(findstring $(DEFAULT_HYPERVISOR),$(KNOWN_HYPERVISORS)))
endif

ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_QEMU))
DEFAULT_HYPERVISOR_CONFIG_PATH = $(CONFIG_PATH_QEMU)
DEFAULT_HYPERVISOR_CONFIG = $(CONFIG_FILE_QEMU)
endif

ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_FC))
DEFAULT_HYPERVISOR_CONFIG_PATH = $(CONFIG_PATH_FC)
DEFAULT_HYPERVISOR_CONFIG = $(CONFIG_FILE_FC)
endif

CONFDIR := $(DEFAULTSDIR)/$(PROJECT_DIR)
Expand Down Expand Up @@ -546,7 +552,7 @@ install-bin-libexec: $(BINLIBEXECLIST)

install-configs: $(CONFIGS)
$(QUIET_INST)$(foreach f,$(CONFIGS),$(call INSTALL_CONFIG,$f,$(dir $(CONFIG_PATH))))
$(QUIET_INST)ln -sf $(DEFAULT_HYPERVISOR_CONFIG_PATH) $(CONFIG_PATH)
$(QUIET_INST)ln -sf $(DEFAULT_HYPERVISOR_CONFIG) $(DESTDIR)/$(CONFIG_PATH)

install-scripts: $(SCRIPTS)
$(QUIET_INST)$(foreach f,$(SCRIPTS),$(call INSTALL_EXEC,$f,$(SCRIPTS_DIR)))
Expand Down
4 changes: 4 additions & 0 deletions cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func delete(ctx context.Context, containerID string, force bool) error {
// Checks the MUST and MUST NOT from OCI runtime specification
status, sandboxID, err := getExistingContainerInfo(ctx, containerID)
if err != nil {
if force {
kataLog.Warnf("Failed to get container, force will not fail: %s", err)
return nil
}
return err
}

Expand Down
4 changes: 4 additions & 0 deletions cli/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func TestDeleteInvalidContainer(t *testing.T) {
err = delete(context.Background(), testContainerID, false)
assert.Error(err)
assert.False(vcmock.IsMockError(err))

// Force to delete missing container
err = delete(context.Background(), "non-existing-test", true)
assert.NoError(err)
}

func TestDeleteMissingContainerTypeAnnotation(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions cli/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ var statusFactoryCommand = cli.Command{
},
}
kataLog.WithField("factory", factoryConfig).Info("load vm factory")
f, err := vf.NewFactory(ctx, factoryConfig, true)
_, err := vf.NewFactory(ctx, factoryConfig, true)
if err != nil {
fmt.Fprintln(defaultOutputFile, "vm factory is off")
} else {
f.CloseFactory(ctx)
fmt.Fprintln(defaultOutputFile, "vm factory is on")
}
} else {
Expand Down
6 changes: 3 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"
genericCPUVendorField = "vendor_id"
genericCPUModelField = "model name"
genericCPUFlagsTag = "flags" // nolint: varcheck, unused
genericCPUVendorField = "vendor_id" // nolint: varcheck, unused
genericCPUModelField = "model name" // nolint: varcheck, unused
)

// variables rather than consts to allow tests to modify them
Expand Down
9 changes: 1 addition & 8 deletions cli/kata-check_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,6 @@ func TestKvmIsUsable(t *testing.T) {
assert.Error(err)
}

type TestDataa struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}

func TestGetCPUDetails(t *testing.T) {
const validVendorName = "a vendor"
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)
Expand All @@ -505,7 +498,7 @@ foo : bar
%s
`, validVendor, validModel)

data := []TestDataa{
data := []testCPUDetail{
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
Expand Down
10 changes: 5 additions & 5 deletions cli/kata-check_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ func normalizeArmModel(model string) string {
return model
}

func getCPUDetails() (vendor, model string, err error) {
if vendor, model, err := genericGetCPUDetails(); err == nil {
func getCPUDetails() (string, string, error) {
vendor, model, err := genericGetCPUDetails()
if err == nil {
vendor = normalizeArmVendor(vendor)
model = normalizeArmModel(model)
return vendor, model, err
} else {
return vendor, model, err
}

return vendor, model, err
}
22 changes: 10 additions & 12 deletions cli/kata-check_arm64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,17 @@ func TestKvmIsUsable(t *testing.T) {
func TestGetCPUDetails(t *testing.T) {
type testData struct {
contents string
expectedVendor string
expectedModel string
expectedNormalizeVendor string
expectedNormalizeModel string
expectError bool
}

const validVendorName = "0x41"
const validNormalizeVendorName = "ARM Limited"
validVendorName := "0x41"
validNormalizeVendorName := "ARM Limited"
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)

const validModelName = "8"
const validNormalizeModelName = "v8"
validModelName := "8"
validNormalizeModelName := "v8"
validModel := fmt.Sprintf(`%s : %s`, archCPUModelField, validModelName)

validContents := fmt.Sprintf(`
Expand All @@ -152,12 +150,12 @@ foo : bar
`, validVendor, validModel)

data := []testData{
{"", "", "", "", "", true},
{"invalid", "", "", "", "", true},
{archCPUVendorField, "", "", "", "", true},
{validVendor, "", "", "", "", true},
{validModel, "", "", "", "", true},
{validContents, validVendorName, validModelName, validNormalizeVendorName, validNormalizeModelName, false},
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
{validVendor, "", "", true},
{validModel, "", "", true},
{validContents, validNormalizeVendorName, validNormalizeModelName, false},
}

tmpdir, err := ioutil.TempDir("", "")
Expand Down
9 changes: 1 addition & 8 deletions cli/kata-check_ppc64le_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,6 @@ func TestKvmIsUsable(t *testing.T) {
assert.Error(err)
}

type TestDataa struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}

func TestGetCPUDetails(t *testing.T) {

const validVendorName = ""
Expand All @@ -230,7 +223,7 @@ foo : bar
%s
`, validVendor, validModel)

data := []TestDataa{
data := []testCPUDetail{
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
Expand Down
16 changes: 1 addition & 15 deletions cli/kata-check_s390x_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,7 @@ func TestKvmIsUsable(t *testing.T) {
assert.Error(err)
}

type TestDataa struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}

func TestGetCPUDetails(t *testing.T) {
type testData struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}

const validVendorName = "a vendor"
validVendor := fmt.Sprintf(`%s : %s`, archCPUVendorField, validVendorName)

Expand All @@ -235,7 +221,7 @@ foo : bar
%s
`, validVendor, validModel)

data := []TestDataa{
data := []testCPUDetail{
{"", "", "", true},
{"invalid", "", "", true},
{archCPUVendorField, "", "", true},
Expand Down
12 changes: 11 additions & 1 deletion cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ type testModuleData struct {
contents string
}

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

// nolint: structcheck, unused
type testCPUDetail struct {
contents string
expectedVendor string
expectedModel string
expectError bool
}

func createFile(file, contents string) error {
return ioutil.WriteFile(file, []byte(contents), testFileMode)
}
Expand Down Expand Up @@ -138,7 +147,8 @@ func makeCPUInfoFile(path, vendorID, flags string) error {
return ioutil.WriteFile(path, contents.Bytes(), testFileMode)
}

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

// nolint: unused
func genericGetExpectedHostDetails(tmpdir string, expectedVendor string, expectedModel string) (HostInfo, error) {
type filesToCreate struct {
file string
Expand Down
4 changes: 2 additions & 2 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func beforeSubcommands(c *cli.Context) error {
var runtimeConfig oci.RuntimeConfig
var err error

katautils.SetConfigOptions(name, defaultRuntimeConfiguration, defaultSysConfRuntimeConfiguration)

handleShowConfig(c)

if userWantsUsage(c) || (c.NArg() == 1 && (c.Args()[0] == checkCmd)) {
Expand Down Expand Up @@ -302,8 +304,6 @@ func beforeSubcommands(c *cli.Context) error {
ignoreLogging = true
}

katautils.SetConfigOptions(name, defaultRuntimeConfiguration, defaultSysConfRuntimeConfiguration)

configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString(configFilePathOption), ignoreLogging, false)
if err != nil {
fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/device/drivers/vhost_user_blk.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (device *VhostUserBlkDevice) Attach(devReceiver api.DeviceReceiver) (err er
// Detach is standard interface of api.Device, it's used to remove device from some
// DeviceReceiver
func (device *VhostUserBlkDevice) Detach(devReceiver api.DeviceReceiver) error {
skip, err := device.bumpAttachCount(true)
skip, err := device.bumpAttachCount(false)
if err != nil {
return err
}
Expand Down
Loading