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

Commit

Permalink
Merge pull request #1619 from jcvenegas/1.5.4-fixes
Browse files Browse the repository at this point in the history
release: backport for 1.5.x
  • Loading branch information
ganeshmaharaj authored May 3, 2019
2 parents cd05be7 + c83fa28 commit 2111f21
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.o
*.patch
*.swp
.git-commit
.git-commit.tmp
/cli/config/configuration-fc.toml
/cli/config/configuration-qemu.toml
/cli/config-generated.go
Expand Down
106 changes: 26 additions & 80 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ BINLIBEXECLIST += $(NETMON_TARGET)

DESTDIR := /

installing = $(findstring install,$(MAKECMDGOALS))

ifeq ($(PREFIX),)
PREFIX := /usr
EXEC_PREFIX := $(PREFIX)/local
Expand All @@ -90,12 +88,6 @@ FCBINDIR := $(PREFIXDEPS)/bin
SYSCONFDIR := /etc
LOCALSTATEDIR := /var

ifeq (,$(installing))
# Force a rebuild to ensure version details are correct
# (but only for a non-install build phase).
EXTRA_DEPS = clean
endif

LIBEXECDIR := $(PREFIXDEPS)/libexec
SHAREDIR := $(PREFIX)/share
DEFAULTSDIR := $(SHAREDIR)/defaults
Expand Down Expand Up @@ -185,8 +177,16 @@ SHIMV2_DIR = $(CLI_DIR)/$(SHIMV2)

SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
VERSION := ${shell cat ./VERSION}
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})

# Targets that depend on .git-commit can use $(shell cat .git-commit) to get a
# git revision string. They will only be rebuilt if the revision string
# actually changes.
.PHONY: .git-commit.tmp
.git-commit: .git-commit.tmp
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
.git-commit.tmp:
@echo -n "$$(git rev-parse HEAD 2>/dev/null)" >$@
@test -n "$$(git status --porcelain --untracked-files=no)" && echo -n "-dirty" >>$@ || true

# List of configuration files to build and install
CONFIGS =
Expand Down Expand Up @@ -336,13 +336,12 @@ USER_VARS += BUILDFLAGS

V = @
Q = $(V:1=)
QUIET_BUILD = $(Q:@=@echo ' BUILD '$@;)
QUIET_CHECK = $(Q:@=@echo ' CHECK '$@;)
QUIET_CLEAN = $(Q:@=@echo ' CLEAN '$@;)
QUIET_CONFIG = $(Q:@=@echo ' CONFIG '$@;)
QUIET_BUILD = $(Q:@=@echo ' BUILD '$@;)
QUIET_CHECK = $(Q:@=@echo ' CHECK '$@;)
QUIET_CLEAN = $(Q:@=@echo ' CLEAN '$@;)
QUIET_GENERATE = $(Q:@=@echo ' GENERATE '$@;)
QUIET_INST = $(Q:@=@echo ' INSTALL '$@;)
QUIET_TEST = $(Q:@=@echo ' TEST '$@;)
QUIET_INST = $(Q:@=@echo ' INSTALL '$@;)
QUIET_TEST = $(Q:@=@echo ' TEST '$@;)

# go build common flags
BUILDFLAGS := -buildmode=pie
Expand All @@ -363,63 +362,14 @@ containerd-shim-v2: $(SHIMV2_OUTPUT)

netmon: $(NETMON_TARGET_OUTPUT)

$(NETMON_TARGET_OUTPUT): $(SOURCES)
$(NETMON_TARGET_OUTPUT): $(SOURCES) VERSION
$(QUIET_BUILD)(cd $(NETMON_DIR) && go build $(BUILDFLAGS) -o $@ -ldflags "-X main.version=$(VERSION)")

runtime: $(TARGET_OUTPUT) $(CONFIGS)
.DEFAULT: default

build: default

define GENERATED_CODE
// WARNING: This file is auto-generated - DO NOT EDIT!
//
// Note that some variables are "var" to allow them to be modified
// by the tests.
package main

import (
"fmt"
)

// name is the name of the runtime
const name = "$(TARGET)"

// name of the project
const project = "$(PROJECT_NAME)"

// prefix used to denote non-standard CLI commands and options.
const projectPrefix = "$(PROJECT_TYPE)"

// original URL for this project
const projectURL = "$(PROJECT_URL)"

const defaultRootDirectory = "$(PKGRUNDIR)"

// commit is the git commit the runtime is compiled from.
var commit = "$(COMMIT)"

// version is the runtime version.
var version = "$(VERSION)"

// project-specific command names
var envCmd = fmt.Sprintf("%s-env", projectPrefix)
var checkCmd = fmt.Sprintf("%s-check", projectPrefix)

// project-specific option names
var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix)
var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix)

// Default config file used by stateless systems.
var defaultRuntimeConfiguration = "$(CONFIG_PATH)"

// Alternate config file that takes precedence over
// defaultRuntimeConfiguration.
var defaultSysConfRuntimeConfiguration = "$(SYSCONFIG)"
endef

export GENERATED_CODE

#Install an executable file
# params:
# $1 : file to install
Expand All @@ -442,14 +392,9 @@ define MAKE_KERNEL_NAME
$(if $(findstring uncompressed,$1),vmlinux.container,vmlinuz.container)
endef

GENERATED_CONFIG = $(CLI_DIR)/config-generated.go

GENERATED_GO_FILES += $(GENERATED_CONFIG)

$(GENERATED_CONFIG): Makefile VERSION
$(QUIET_GENERATE)echo "$$GENERATED_CODE" >$@
GENERATED_FILES += $(CLI_DIR)/config-generated.go

$(TARGET_OUTPUT): $(EXTRA_DEPS) $(SOURCES) $(GENERATED_GO_FILES) $(GENERATED_FILES) Makefile | show-summary
$(TARGET_OUTPUT): $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST) | show-summary
$(QUIET_BUILD)(cd $(CLI_DIR) && go build $(BUILDFLAGS) -o $@ .)

$(SHIMV2_OUTPUT): $(TARGET_OUTPUT)
Expand All @@ -466,14 +411,14 @@ $(SHIMV2_OUTPUT): $(TARGET_OUTPUT)
show-summary \
show-variables

$(TARGET).coverage: $(SOURCES) $(GENERATED_FILES) Makefile
$(TARGET).coverage: $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST)
$(QUIET_TEST)go test -o $@ -covermode count

GENERATED_FILES += $(CONFIGS)

$(GENERATED_FILES): %: %.in Makefile VERSION
$(QUIET_CONFIG)$(SED) \
-e "s|@COMMIT@|$(COMMIT)|g" \
$(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit
$(QUIET_GENERATE)$(SED) \
-e "s|@COMMIT@|$(shell cat .git-commit)|g" \
-e "s|@VERSION@|$(VERSION)|g" \
-e "s|@CONFIG_QEMU_IN@|$(CONFIG_QEMU_IN)|g" \
-e "s|@CONFIG_FC_IN@|$(CONFIG_FC_IN)|g" \
Expand All @@ -489,6 +434,7 @@ $(GENERATED_FILES): %: %.in Makefile VERSION
-e "s|@KERNELPARAMS@|$(KERNELPARAMS)|g" \
-e "s|@LOCALSTATEDIR@|$(LOCALSTATEDIR)|g" \
-e "s|@PKGLIBEXECDIR@|$(PKGLIBEXECDIR)|g" \
-e "s|@PKGRUNDIR@|$(PKGRUNDIR)|g" \
-e "s|@PROXYPATH@|$(PROXYPATH)|g" \
-e "s|@NETMONPATH@|$(NETMONPATH)|g" \
-e "s|@PROJECT_BUG_URL@|$(PROJECT_BUG_URL)|g" \
Expand Down Expand Up @@ -561,7 +507,7 @@ install-completions:
$(QUIET_INST)install --mode 0644 -D $(BASH_COMPLETIONS) $(DESTDIR)/$(BASH_COMPLETIONSDIR)/$(notdir $(BASH_COMPLETIONS));

clean:
$(QUIET_CLEAN)rm -f $(TARGET) $(SHIMV2) $(NETMON_TARGET) $(CONFIGS) $(GENERATED_GO_FILES) $(GENERATED_FILES) $(COLLECT_SCRIPT)
$(QUIET_CLEAN)rm -f $(TARGET) $(SHIMV2) $(NETMON_TARGET) $(CONFIGS) $(GENERATED_FILES) .git-commit .git-commit.tmp

show-usage: show-header
@printf "• Overview:\n"
Expand Down Expand Up @@ -594,8 +540,8 @@ show-variables:
"$(foreach v,$(sort $(USER_VARS)),$(shell printf "\\t$(v)='$($(v))'\\\n"))"
@printf "\n"

show-header:
@printf "%s - version %s (commit %s)\n\n" $(TARGET) $(VERSION) $(COMMIT)
show-header: .git-commit
@printf "%s - version %s (commit %s)\n\n" $(TARGET) $(VERSION) $(shell cat .git-commit)

show-arches: show-header
@printf "Supported architectures (possible values for ARCH variable):\n\n"
Expand Down
49 changes: 49 additions & 0 deletions cli/config-generated.go.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright (c) 2018-2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
// WARNING: This file is auto-generated - DO NOT EDIT!
//
// Note that some variables are "var" to allow them to be modified
// by the tests.
package main

import (
"fmt"
)

// name is the name of the runtime
const name = "@RUNTIME_NAME@"

// name of the project
const project = "@PROJECT_NAME@"

// prefix used to denote non-standard CLI commands and options.
const projectPrefix = "@PROJECT_TYPE@"

// original URL for this project
const projectURL = "@PROJECT_URL@"

const defaultRootDirectory = "@PKGRUNDIR@"

// commit is the git commit the runtime is compiled from.
var commit = "@COMMIT@"

// version is the runtime version.
var version = "@VERSION@"

// project-specific command names
var envCmd = fmt.Sprintf("%s-env", projectPrefix)
var checkCmd = fmt.Sprintf("%s-check", projectPrefix)

// project-specific option names
var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix)
var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix)

// Default config file used by stateless systems.
var defaultRuntimeConfiguration = "@CONFIG_PATH@"

// Alternate config file that takes precedence over
// defaultRuntimeConfiguration.
var defaultSysConfRuntimeConfiguration = "@SYSCONFIG@"
3 changes: 2 additions & 1 deletion cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ func getContainers(ctx context.Context, context *cli.Context) ([]fullContainerSt

uid, err := getDirOwner(container.RootFs)
if err != nil {
return nil, err
fmt.Fprintf(os.Stderr, "WARNING: failed to get container %s rootfs: %s\n", ociState.ID, err)
continue
}

owner := fmt.Sprintf("#%v", uid)
Expand Down
63 changes: 58 additions & 5 deletions cli/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,6 @@ func TestListCLIFunctionFormatFail(t *testing.T) {

ctx.App.Metadata["runtimeConfig"] = runtimeConfig

_ = os.Remove(rootfs)

err = fn(ctx)
assert.Error(err)

err = os.MkdirAll(rootfs, testDirMode)
assert.NoError(err)

Expand Down Expand Up @@ -730,3 +725,61 @@ func TestListGetDirOwner(t *testing.T) {
assert.NoError(err)
assert.Equal(dirUID, uid)
}

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

tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)

sandbox := &vcmock.Sandbox{
MockID: testSandboxID,
}

rootfs := filepath.Join(tmpdir, "rootfs")
err = os.MkdirAll(rootfs, testDirMode)
assert.NoError(err)

testingImpl.ListSandboxFunc = func(ctx context.Context) ([]vc.SandboxStatus, error) {
return []vc.SandboxStatus{
{
ID: sandbox.ID(),
ContainersStatus: []vc.ContainerStatus{
{
ID: sandbox.ID(),
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
},
RootFs: rootfs,
},
},
},
}, nil
}

defer func() {
testingImpl.ListSandboxFunc = nil
}()

set := flag.NewFlagSet("test", 0)
set.String("format", "table", "")
ctx := createCLIContext(set)
ctx.App.Name = "foo"

runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
assert.NoError(err)

ctx.App.Metadata["runtimeConfig"] = runtimeConfig

fn, ok := listCLICommand.Action.(func(context *cli.Context) error)
assert.True(ok)

err = fn(ctx)
assert.NoError(err)

// remove container rootfs, check list command should also work
assert.NoError(os.RemoveAll(rootfs))
err = fn(ctx)
assert.NoError(err)
}
2 changes: 2 additions & 0 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,8 @@ func (k *kataAgent) handleEphemeralStorage(mounts []specs.Mount) []*grpc.Storage
if mnt.Type == kataEphemeralDevType {
// Set the mount source path to a path that resides inside the VM
mounts[idx].Source = filepath.Join(ephemeralPath, filepath.Base(mnt.Source))
// Set the mount type to "bind"
mounts[idx].Type = "bind"

// Create a storage struct so that kata agent is able to create
// tmpfs backed volume inside the VM
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/qemu_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
govmmQemu "github.com/intel/govmm/qemu"
"github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/kata-containers/runtime/virtcontainers/types"
"time"
)

type qemuS390x struct {
Expand Down

0 comments on commit 2111f21

Please sign in to comment.