Merge branch 'master' of github.com:kubernetes-incubator/cri-o into RemoveAllContainers
This commit is contained in:
commit
c07780a328
7 changed files with 126 additions and 81 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
/.artifacts/
|
/.artifacts/
|
||||||
|
/_output/
|
||||||
/conmon/conmon
|
/conmon/conmon
|
||||||
/conmon/conmon.o
|
/conmon/conmon.o
|
||||||
/docs/*.[158]
|
/docs/*.[158]
|
||||||
|
|
85
Makefile
85
Makefile
|
@ -14,6 +14,17 @@ ETCDIR_OCID ?= ${ETCDIR}/ocid
|
||||||
BUILDTAGS := selinux seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh)
|
BUILDTAGS := selinux seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh)
|
||||||
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
||||||
|
|
||||||
|
# If GOPATH not specified, use one in the local directory
|
||||||
|
ifeq ($(GOPATH),)
|
||||||
|
export GOPATH := $(CURDIR)/_output
|
||||||
|
unexport GOBIN
|
||||||
|
endif
|
||||||
|
GOPKGDIR := $(GOPATH)/src/$(PROJECT)
|
||||||
|
GOPKGBASEDIR := $(shell dirname "$(GOPKGDIR)")
|
||||||
|
|
||||||
|
# Update VPATH so make finds .gopathok
|
||||||
|
VPATH := $(VPATH):$(GOPATH)
|
||||||
|
|
||||||
all: binaries ocid.conf docs
|
all: binaries ocid.conf docs
|
||||||
|
|
||||||
default: help
|
default: help
|
||||||
|
@ -28,14 +39,14 @@ help:
|
||||||
@echo " * 'lint' - Execute the source code linter"
|
@echo " * 'lint' - Execute the source code linter"
|
||||||
@echo " * 'gofmt' - Verify the source code gofmt"
|
@echo " * 'gofmt' - Verify the source code gofmt"
|
||||||
|
|
||||||
.PHONY: check-gopath
|
.gopathok:
|
||||||
|
ifeq ("$(wildcard $(GOPKGDIR))","")
|
||||||
check-gopath:
|
mkdir -p "$(GOPKGBASEDIR)"
|
||||||
ifndef GOPATH
|
ln -s "$(CURDIR)" "$(GOPKGBASEDIR)"
|
||||||
$(error GOPATH is not set)
|
|
||||||
endif
|
endif
|
||||||
|
touch "$(GOPATH)/.gopathok"
|
||||||
|
|
||||||
lint: check-gopath
|
lint: .gopathok
|
||||||
@echo "checking lint"
|
@echo "checking lint"
|
||||||
@./.tool/lint
|
@./.tool/lint
|
||||||
|
|
||||||
|
@ -48,30 +59,34 @@ conmon:
|
||||||
pause:
|
pause:
|
||||||
$(MAKE) -C $@
|
$(MAKE) -C $@
|
||||||
|
|
||||||
bin2img:
|
bin2img: .gopathok $(wildcard test/bin2img/*.go)
|
||||||
$(MAKE) -C test/$@ BUILDTAGS="$(BUILDTAGS)"
|
go build -tags "$(BUILDTAGS)" -o test/bin2img/$@ $(PROJECT)/test/bin2img
|
||||||
|
|
||||||
copyimg:
|
copyimg: .gopathok $(wildcard test/copyimg/*.go)
|
||||||
$(MAKE) -C test/$@ BUILDTAGS="$(BUILDTAGS)"
|
go build -tags "$(BUILDTAGS)" -o test/copyimg/$@ $(PROJECT)/test/copyimg
|
||||||
|
|
||||||
checkseccomp: check-gopath
|
checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
|
||||||
$(MAKE) -C test/$@
|
go build -o test/checkseccomp/$@ $(PROJECT)/test/checkseccomp
|
||||||
|
|
||||||
ocid: check-gopath
|
ocid: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/ocid $(PROJECT))
|
||||||
$(GO) build -o $@ \
|
$(GO) build -o $@ \
|
||||||
-tags "$(BUILDTAGS)" \
|
-tags "$(BUILDTAGS)" \
|
||||||
$(PROJECT)/cmd/ocid
|
$(PROJECT)/cmd/ocid
|
||||||
|
|
||||||
ocic: check-gopath
|
ocic: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/ocic $(PROJECT))
|
||||||
$(GO) build -o $@ $(PROJECT)/cmd/ocic
|
$(GO) build -o $@ $(PROJECT)/cmd/ocic
|
||||||
|
|
||||||
kpod: check-gopath
|
kpod: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/kpod $(PROJECT))
|
||||||
$(GO) build -o $@ $(PROJECT)/cmd/kpod
|
$(GO) build -o $@ $(PROJECT)/cmd/kpod
|
||||||
|
|
||||||
ocid.conf: ocid
|
ocid.conf: ocid
|
||||||
./ocid --config="" config --default > ocid.conf
|
./ocid --config="" config --default > ocid.conf
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
ifneq ($(GOPATH),)
|
||||||
|
rm -f "$(GOPATH)/.gopathok"
|
||||||
|
endif
|
||||||
|
rm -rf _output
|
||||||
rm -f docs/*.1 docs/*.5 docs/*.8
|
rm -f docs/*.1 docs/*.5 docs/*.8
|
||||||
rm -fr test/testdata/redis-image
|
rm -fr test/testdata/redis-image
|
||||||
find . -name \*~ -delete
|
find . -name \*~ -delete
|
||||||
|
@ -79,9 +94,9 @@ clean:
|
||||||
rm -f ocic ocid kpod
|
rm -f ocic ocid kpod
|
||||||
make -C conmon clean
|
make -C conmon clean
|
||||||
make -C pause clean
|
make -C pause clean
|
||||||
make -C test/bin2img clean
|
rm -f test/bin2img/bin2img
|
||||||
make -C test/copyimg clean
|
rm -f test/copyimg/copyimg
|
||||||
make -C test/checkseccomp clean
|
rm -f test/checkseccomp/checkseccomp
|
||||||
|
|
||||||
ocidimage:
|
ocidimage:
|
||||||
docker build -t ${OCID_IMAGE} .
|
docker build -t ${OCID_IMAGE} .
|
||||||
|
@ -100,18 +115,18 @@ binaries: ocid ocic kpod conmon pause bin2img copyimg checkseccomp
|
||||||
MANPAGES_MD := $(wildcard docs/*.md)
|
MANPAGES_MD := $(wildcard docs/*.md)
|
||||||
MANPAGES := $(MANPAGES_MD:%.md=%)
|
MANPAGES := $(MANPAGES_MD:%.md=%)
|
||||||
|
|
||||||
docs/%.1: docs/%.1.md check-gopath
|
docs/%.1: docs/%.1.md .gopathok
|
||||||
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
||||||
|
|
||||||
docs/%.5: docs/%.5.md check-gopath
|
docs/%.5: docs/%.5.md .gopathok
|
||||||
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
||||||
|
|
||||||
docs/%.8: docs/%.8.md check-gopath
|
docs/%.8: docs/%.8.md .gopathok
|
||||||
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
||||||
|
|
||||||
docs: $(MANPAGES)
|
docs: $(MANPAGES)
|
||||||
|
|
||||||
install: check-gopath
|
install: .gopathok
|
||||||
install -D -m 755 ocid $(BINDIR)/ocid
|
install -D -m 755 ocid $(BINDIR)/ocid
|
||||||
install -D -m 755 ocic $(BINDIR)/ocic
|
install -D -m 755 ocic $(BINDIR)/ocic
|
||||||
install -D -m 755 kpod $(BINDIR)/kpod
|
install -D -m 755 kpod $(BINDIR)/kpod
|
||||||
|
@ -153,26 +168,32 @@ uninstall:
|
||||||
|
|
||||||
.PHONY: .gitvalidation
|
.PHONY: .gitvalidation
|
||||||
# When this is running in travis, it will only check the travis commit range
|
# When this is running in travis, it will only check the travis commit range
|
||||||
.gitvalidation: check-gopath
|
.gitvalidation: .gopathok
|
||||||
ifeq ($(TRAVIS),true)
|
ifeq ($(TRAVIS),true)
|
||||||
git-validation -q -run DCO,short-subject
|
$(GOPATH)/bin/git-validation -q -run DCO,short-subject
|
||||||
else
|
else
|
||||||
git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
$(GOPATH)/bin/git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: install.tools
|
.PHONY: install.tools
|
||||||
|
|
||||||
install.tools: .install.gitvalidation .install.gometalinter .install.md2man
|
install.tools: .install.gitvalidation .install.gometalinter .install.md2man
|
||||||
|
|
||||||
.install.gitvalidation: check-gopath
|
.install.gitvalidation: .gopathok
|
||||||
go get -u github.com/vbatts/git-validation
|
if [ ! -x "$(GOPATH)/bin/git-validation" ]; then \
|
||||||
|
go get -u github.com/vbatts/git-validation; \
|
||||||
|
fi
|
||||||
|
|
||||||
.install.gometalinter: check-gopath
|
.install.gometalinter: .gopathok
|
||||||
go get -u github.com/alecthomas/gometalinter
|
if [ ! -x "$(GOPATH)/bin/gometalinter" ]; then \
|
||||||
$(GOPATH)/bin/gometalinter --install
|
go get -u github.com/alecthomas/gometalinter; \
|
||||||
|
$(GOPATH)/bin/gometalinter --install; \
|
||||||
|
fi
|
||||||
|
|
||||||
.install.md2man: check-gopath
|
.install.md2man: .gopathok
|
||||||
go get -u github.com/cpuguy83/go-md2man
|
if [ ! -x "$(GOPATH)/bin/go-md2man" ]; then \
|
||||||
|
go get -u github.com/cpuguy83/go-md2man; \
|
||||||
|
fi
|
||||||
|
|
||||||
.PHONY: \
|
.PHONY: \
|
||||||
bin2img \
|
bin2img \
|
||||||
|
|
41
hack/find-godeps.sh
Executable file
41
hack/find-godeps.sh
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# $1 - base path of the source tree
|
||||||
|
# $2 - subpath under $1 to find *.go dependencies for
|
||||||
|
# $3 - package name (eg, github.com/organization/project)
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# might be called from makefile before basepath is set up; just return
|
||||||
|
# empty deps. The make target will then ensure that GOPATH is set up
|
||||||
|
# correctly, and go build will build everything the first time around
|
||||||
|
# anyway. Next time we get here everything will be fine.
|
||||||
|
if [ ! -d "$1/$2" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
function find-deps() {
|
||||||
|
local basepath=$1
|
||||||
|
local srcdir=$2
|
||||||
|
local pkgname=$3
|
||||||
|
local deps=
|
||||||
|
|
||||||
|
# gather imports from cri-o
|
||||||
|
pkgs=$(cd ${basepath}/${srcdir} && go list -f "{{.Imports}}" . | tr ' ' '\n' | grep -v "/vendor/" | grep ${pkgname} | sed -e "s|${pkgname}/||g")
|
||||||
|
|
||||||
|
# add each Go import's sources to the deps list,
|
||||||
|
# and recursively get that imports's imports too
|
||||||
|
for dep in ${pkgs}; do
|
||||||
|
deps+="$(ls ${basepath}/${dep}/*.go | sed -e "s|${basepath}/||g") "
|
||||||
|
# add deps of this package too
|
||||||
|
deps+="$(find-deps ${basepath} ${dep} ${pkgname}) "
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${deps}" | sort | uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
# add Go sources from the current package at the end
|
||||||
|
echo "$(find-deps "$1" "$2" "$3" | xargs) $(cd $1 && ls $2/*.go | xargs)"
|
||||||
|
|
|
@ -39,8 +39,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type runtimeService struct {
|
type runtimeService struct {
|
||||||
image ImageServer
|
imageServer ImageServer
|
||||||
pauseImage string
|
pauseImage string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerInfo wraps a subset of information about a container: its ID and
|
// ContainerInfo wraps a subset of information about a container: its ID and
|
||||||
|
@ -159,22 +159,22 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have the specified image.
|
// Check if we have the specified image.
|
||||||
ref, err := istorage.Transport.ParseStoreReference(r.image.GetStore(), imageName)
|
ref, err := istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Maybe it's some other transport's copy of the image?
|
// Maybe it's some other transport's copy of the image?
|
||||||
otherRef, err2 := alltransports.ParseImageName(imageName)
|
otherRef, err2 := alltransports.ParseImageName(imageName)
|
||||||
if err2 == nil && otherRef.DockerReference() != nil {
|
if err2 == nil && otherRef.DockerReference() != nil {
|
||||||
ref, err = istorage.Transport.ParseStoreReference(r.image.GetStore(), otherRef.DockerReference().Name())
|
ref, err = istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), otherRef.DockerReference().Name())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Maybe the image ID is sufficient?
|
// Maybe the image ID is sufficient?
|
||||||
ref, err = istorage.Transport.ParseStoreReference(r.image.GetStore(), "@"+imageID)
|
ref, err = istorage.Transport.ParseStoreReference(r.imageServer.GetStore(), "@"+imageID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
img, err := istorage.Transport.GetStoreImage(r.image.GetStore(), ref)
|
img, err := istorage.Transport.GetStoreImage(r.imageServer.GetStore(), ref)
|
||||||
if img == nil && err == storage.ErrImageUnknown && imageName == r.pauseImage {
|
if img == nil && err == storage.ErrImageUnknown && imageName == r.pauseImage {
|
||||||
image := imageID
|
image := imageID
|
||||||
if imageName != "" {
|
if imageName != "" {
|
||||||
|
@ -184,11 +184,11 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
return ContainerInfo{}, ErrInvalidImageName
|
return ContainerInfo{}, ErrInvalidImageName
|
||||||
}
|
}
|
||||||
logrus.Debugf("couldn't find image %q, retrieving it", image)
|
logrus.Debugf("couldn't find image %q, retrieving it", image)
|
||||||
ref, err = r.image.PullImage(systemContext, image, options)
|
ref, err = r.imageServer.PullImage(systemContext, image, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
img, err = istorage.Transport.GetStoreImage(r.image.GetStore(), ref)
|
img, err = istorage.Transport.GetStoreImage(r.imageServer.GetStore(), ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
names = append(names, metadata.PodName)
|
names = append(names, metadata.PodName)
|
||||||
}
|
}
|
||||||
container, err := r.image.GetStore().CreateContainer(containerID, names, img.ID, "", string(mdata), nil)
|
container, err := r.imageServer.GetStore().CreateContainer(containerID, names, img.ID, "", string(mdata), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
logrus.Debugf("failed to create pod sandbox %s(%s): %v", metadata.PodName, metadata.PodID, err)
|
logrus.Debugf("failed to create pod sandbox %s(%s): %v", metadata.PodName, metadata.PodID, err)
|
||||||
|
@ -266,7 +266,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
// container before returning.
|
// container before returning.
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err2 := r.image.GetStore().DeleteContainer(container.ID); err2 != nil {
|
if err2 := r.imageServer.GetStore().DeleteContainer(container.ID); err2 != nil {
|
||||||
if metadata.Pod {
|
if metadata.Pod {
|
||||||
logrus.Infof("%v deleting partially-created pod sandbox %q", err2, container.ID)
|
logrus.Infof("%v deleting partially-created pod sandbox %q", err2, container.ID)
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,18 +281,18 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
// Add a name to the container's layer so that it's easier to follow
|
// Add a name to the container's layer so that it's easier to follow
|
||||||
// what's going on if we're just looking at the storage-eye view of things.
|
// what's going on if we're just looking at the storage-eye view of things.
|
||||||
layerName := metadata.ContainerName + "-layer"
|
layerName := metadata.ContainerName + "-layer"
|
||||||
names, err = r.image.GetStore().GetNames(container.LayerID)
|
names, err = r.imageServer.GetStore().GetNames(container.LayerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
names = append(names, layerName)
|
names = append(names, layerName)
|
||||||
err = r.image.GetStore().SetNames(container.LayerID, names)
|
err = r.imageServer.GetStore().SetNames(container.LayerID, names)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out where the container work directories are, so that we can return them.
|
// Find out where the container work directories are, so that we can return them.
|
||||||
containerDir, err := r.image.GetStore().GetContainerDirectory(container.ID)
|
containerDir, err := r.imageServer.GetStore().GetContainerDirectory(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ func (r *runtimeService) createContainerOrPodSandbox(systemContext *types.System
|
||||||
logrus.Debugf("container %q has work directory %q", container.ID, containerDir)
|
logrus.Debugf("container %q has work directory %q", container.ID, containerDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
containerRunDir, err := r.image.GetStore().GetContainerRunDirectory(container.ID)
|
containerRunDir, err := r.imageServer.GetStore().GetContainerRunDirectory(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ContainerInfo{}, err
|
return ContainerInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -329,14 +329,14 @@ func (r *runtimeService) CreateContainer(systemContext *types.SystemContext, pod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
||||||
container, err := r.image.GetStore().GetContainer(idOrName)
|
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidSandboxID
|
return ErrInvalidSandboxID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.image.GetStore().DeleteContainer(container.ID)
|
err = r.imageServer.GetStore().DeleteContainer(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to delete pod sandbox %q: %v", container.ID, err)
|
logrus.Debugf("failed to delete pod sandbox %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -345,14 +345,14 @@ func (r *runtimeService) RemovePodSandbox(idOrName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) DeleteContainer(idOrName string) error {
|
func (r *runtimeService) DeleteContainer(idOrName string) error {
|
||||||
container, err := r.image.GetStore().GetContainer(idOrName)
|
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidContainerID
|
return ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.image.GetStore().DeleteContainer(container.ID)
|
err = r.imageServer.GetStore().DeleteContainer(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to delete container %q: %v", container.ID, err)
|
logrus.Debugf("failed to delete container %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -366,12 +366,12 @@ func (r *runtimeService) SetContainerMetadata(idOrName string, metadata RuntimeC
|
||||||
logrus.Debugf("failed to encode metadata for %q: %v", idOrName, err)
|
logrus.Debugf("failed to encode metadata for %q: %v", idOrName, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return r.image.GetStore().SetMetadata(idOrName, string(mdata))
|
return r.imageServer.GetStore().SetMetadata(idOrName, string(mdata))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error) {
|
func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error) {
|
||||||
metadata := RuntimeContainerMetadata{}
|
metadata := RuntimeContainerMetadata{}
|
||||||
mdata, err := r.image.GetStore().GetMetadata(idOrName)
|
mdata, err := r.imageServer.GetStore().GetMetadata(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return metadata, err
|
return metadata, err
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ func (r *runtimeService) GetContainerMetadata(idOrName string) (RuntimeContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
container, err := r.image.GetStore().GetContainer(idOrName)
|
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
|
@ -393,7 +393,7 @@ func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
if err = json.Unmarshal([]byte(container.Metadata), &metadata); err != nil {
|
if err = json.Unmarshal([]byte(container.Metadata), &metadata); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
mountPoint, err := r.image.GetStore().Mount(container.ID, metadata.MountLabel)
|
mountPoint, err := r.imageServer.GetStore().Mount(container.ID, metadata.MountLabel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to mount container %q: %v", container.ID, err)
|
logrus.Debugf("failed to mount container %q: %v", container.ID, err)
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -403,14 +403,14 @@ func (r *runtimeService) StartContainer(idOrName string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) StopContainer(idOrName string) error {
|
func (r *runtimeService) StopContainer(idOrName string) error {
|
||||||
container, err := r.image.GetStore().GetContainer(idOrName)
|
container, err := r.imageServer.GetStore().GetContainer(idOrName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return ErrInvalidContainerID
|
return ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = r.image.GetStore().Unmount(container.ID)
|
err = r.imageServer.GetStore().Unmount(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("failed to unmount container %q: %v", container.ID, err)
|
logrus.Debugf("failed to unmount container %q: %v", container.ID, err)
|
||||||
return err
|
return err
|
||||||
|
@ -420,33 +420,33 @@ func (r *runtimeService) StopContainer(idOrName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetWorkDir(id string) (string, error) {
|
func (r *runtimeService) GetWorkDir(id string) (string, error) {
|
||||||
container, err := r.image.GetStore().GetContainer(id)
|
container, err := r.imageServer.GetStore().GetContainer(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return r.image.GetStore().GetContainerDirectory(container.ID)
|
return r.imageServer.GetStore().GetContainerDirectory(container.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *runtimeService) GetRunDir(id string) (string, error) {
|
func (r *runtimeService) GetRunDir(id string) (string, error) {
|
||||||
container, err := r.image.GetStore().GetContainer(id)
|
container, err := r.imageServer.GetStore().GetContainer(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == storage.ErrContainerUnknown {
|
if err == storage.ErrContainerUnknown {
|
||||||
return "", ErrInvalidContainerID
|
return "", ErrInvalidContainerID
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return r.image.GetStore().GetContainerRunDirectory(container.ID)
|
return r.imageServer.GetStore().GetContainerRunDirectory(container.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRuntimeService returns a RuntimeServer that uses the passed-in image
|
// GetRuntimeService returns a RuntimeServer that uses the passed-in image
|
||||||
// service to pull and manage images, and its store to manage containers based
|
// service to pull and manage images, and its store to manage containers based
|
||||||
// on those images.
|
// on those images.
|
||||||
func GetRuntimeService(image ImageServer, pauseImage string) RuntimeServer {
|
func GetRuntimeService(imageServer ImageServer, pauseImage string) RuntimeServer {
|
||||||
return &runtimeService{
|
return &runtimeService{
|
||||||
image: image,
|
imageServer: imageServer,
|
||||||
pauseImage: pauseImage,
|
pauseImage: pauseImage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
bin2img: $(wildcard *.go)
|
|
||||||
go build -tags "$(BUILDTAGS)" -o $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f bin2img
|
|
|
@ -1,6 +0,0 @@
|
||||||
checkseccomp: $(wildcard *.go)
|
|
||||||
go build -o $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f checkseccomp
|
|
|
@ -1,6 +0,0 @@
|
||||||
copyimg: $(wildcard *.go)
|
|
||||||
go build -tags "$(BUILDTAGS)" -o $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f copyimg
|
|
Loading…
Reference in a new issue