diff --git a/.travis.yml b/.travis.yml index 70cadd641..4366ea465 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,13 +32,13 @@ jobs: - make install.tools - make .gitvalidation - make binaries - - make plugin + - make containerd go: 1.9.x - script: - make install.tools - make .gitvalidation - make binaries - - make plugin + - make containerd go: tip - stage: Test script: @@ -54,7 +54,9 @@ jobs: - cat /tmp/test-cri/containerd.log go: 1.9.x - script: - - make install.deps COOK_CONTAINERD=true + - make install.deps + - make containerd + - sudo make install-containerd - make test-integration STANDALONE_CRI_CONTAINERD=false - make test-cri STANDALONE_CRI_CONTAINERD=false after_script: diff --git a/Makefile b/Makefile index 6f4141eab..850e0bac0 100644 --- a/Makefile +++ b/Makefile @@ -40,24 +40,25 @@ default: help help: @echo "Usage: make " @echo - @echo " * 'install' - Install binaries to system locations" - @echo " * 'binaries' - Build cri-containerd and ctrcri" - @echo " * 'plugin' - Build cri-containerd as a plugin package" - @echo " * 'static-binaries - Build static cri-containerd and ctrcri" - @echo " * 'release' - Build release tarball" - @echo " * 'push' - Push release tarball to GCS" - @echo " * 'test' - Test cri-containerd with unit test" - @echo " * 'test-integration' - Test cri-containerd with integration test" - @echo " * 'test-cri' - Test cri-containerd with cri validation test" - @echo " * 'test-e2e-node' - Test cri-containerd with Kubernetes node e2e test" - @echo " * 'clean' - Clean artifacts" - @echo " * 'verify' - Execute the source code verification tools" - @echo " * 'proto' - Update protobuf of cri-containerd api" - @echo " * 'install.tools' - Install tools used by verify" - @echo " * 'install.deps' - Install dependencies of cri-containerd (containerd, runc, cni) Note: BUILDTAGS defaults to 'seccomp apparmor' for runc build" - @echo " * 'uninstall' - Remove installed binaries from system locations" - @echo " * 'version' - Print current cri-containerd release version" - @echo " * 'update-vendor' - Syncs containerd/vendor.conf -> vendor.conf and sorts vendor.conf" + @echo " * 'install' - Install binaries to system locations" + @echo " * 'binaries' - Build cri-containerd and ctrcri" + @echo " * 'static-binaries - Build static cri-containerd and ctrcri" + @echo " * 'release' - Build release tarball" + @echo " * 'push' - Push release tarball to GCS" + @echo " * 'containerd' - Build a customized containerd with CRI plugin for testing" + @echo " * 'install-containerd' - Install customized containerd to system location" + @echo " * 'test' - Test cri-containerd with unit test" + @echo " * 'test-integration' - Test cri-containerd with integration test" + @echo " * 'test-cri' - Test cri-containerd with cri validation test" + @echo " * 'test-e2e-node' - Test cri-containerd with Kubernetes node e2e test" + @echo " * 'clean' - Clean artifacts" + @echo " * 'verify' - Execute the source code verification tools" + @echo " * 'proto' - Update protobuf of cri-containerd api" + @echo " * 'install.tools' - Install tools used by verify" + @echo " * 'install.deps' - Install dependencies of cri-containerd (containerd, runc, cni) Note: BUILDTAGS defaults to 'seccomp apparmor' for runc build" + @echo " * 'uninstall' - Remove installed binaries from system locations" + @echo " * 'version' - Print current cri-containerd release version" + @echo " * 'update-vendor' - Syncs containerd/vendor.conf -> vendor.conf and sorts vendor.conf" verify: lint gofmt boiler @@ -102,6 +103,13 @@ $(BUILD_DIR)/ctrcri: $(SOURCES) -gcflags '$(GO_GCFLAGS)' \ $(PROJECT)/cmd/ctrcri +$(BUILD_DIR)/containerd: $(SOURCES) $(PLUGIN_SOURCES) + $(GO) build -o $@ \ + -tags '$(BUILD_TAGS)' \ + -ldflags '$(GO_LDFLAGS)' \ + -gcflags '$(GO_GCFLAGS)' \ + $(PROJECT)/cmd/containerd + test: $(GO) test -timeout=10m -race ./pkg/... \ -tags '$(BUILD_TAGS)' \ @@ -125,13 +133,6 @@ clean: binaries: $(BUILD_DIR)/cri-containerd $(BUILD_DIR)/ctrcri -# TODO(random-liu): Make this only build when source files change and -# add this to target all. -plugin: $(PLUGIN_SOURCES) $(SOURCES) - $(GO) build -tags '$(BUILD_TAGS)' \ - -ldflags '$(GO_LDFLAGS)' \ - -gcflags '$(GO_GCFLAGS)' \ - static-binaries: GO_LDFLAGS += -extldflags "-fno-PIC -static" static-binaries: $(BUILD_DIR)/cri-containerd $(BUILD_DIR)/ctrcri @@ -151,6 +152,11 @@ release: $(BUILD_DIR)/$(TARBALL) push: $(BUILD_DIR)/$(TARBALL) @BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/push.sh +containerd: $(BUILD_DIR)/containerd + +install-containerd: containerd + install -D -m 755 $(BUILD_DIR)/containerd $(BINDIR)/containerd + proto: @hack/update-proto.sh @@ -183,7 +189,6 @@ install.tools: .install.gitvalidation .install.gometalinter .PHONY: \ binaries \ static-binaries \ - plugin \ release \ push \ boiler \ @@ -193,6 +198,8 @@ install.tools: .install.gitvalidation .install.gometalinter help \ install \ lint \ + containerd \ + install-containerd \ test \ test-integration \ test-cri \ diff --git a/cmd/containerd/containerd.go b/cmd/containerd/containerd.go new file mode 100644 index 000000000..bea512838 --- /dev/null +++ b/cmd/containerd/containerd.go @@ -0,0 +1,56 @@ +/* +Copyright 2018 The containerd Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "fmt" + "os" + + _ "github.com/containerd/containerd/diff/walking/plugin" + _ "github.com/containerd/containerd/gc/scheduler" + _ "github.com/containerd/containerd/linux" + _ "github.com/containerd/containerd/metrics/cgroups" + _ "github.com/containerd/containerd/services/containers" + _ "github.com/containerd/containerd/services/content" + _ "github.com/containerd/containerd/services/diff" + _ "github.com/containerd/containerd/services/events" + _ "github.com/containerd/containerd/services/healthcheck" + _ "github.com/containerd/containerd/services/images" + _ "github.com/containerd/containerd/services/introspection" + _ "github.com/containerd/containerd/services/leases" + _ "github.com/containerd/containerd/services/namespaces" + _ "github.com/containerd/containerd/services/snapshots" + _ "github.com/containerd/containerd/services/tasks" + _ "github.com/containerd/containerd/services/version" + _ "github.com/containerd/containerd/snapshots/overlay" + _ "github.com/containerd/cri-containerd" + + "github.com/containerd/containerd/cmd/containerd/command" + "github.com/sirupsen/logrus" + + "github.com/containerd/cri-containerd/pkg/version" +) + +func main() { + app := command.App() + app.Version = version.CRIContainerdVersion + "-TEST-with-cri-plugin" + logrus.Warn("This customized containerd is only for CI test, DO NOT use it for distribution.") + if err := app.Run(os.Args); err != nil { + fmt.Fprintf(os.Stderr, "containerd: %s\n", err) + os.Exit(1) + } +} diff --git a/hack/install-deps.sh b/hack/install-deps.sh index 81d1d1524..7cd0d883f 100755 --- a/hack/install-deps.sh +++ b/hack/install-deps.sh @@ -51,11 +51,6 @@ fi # and configurations in cluster. INSTALL_CNI=${INSTALL_CNI:-true} -# COOK_CONTAINERD indicates whether to update containerd with newest -# cri plugin before install. This is mainly used for testing new cri -# plugin change. -COOK_CONTAINERD=${COOK_CONTAINERD:-false} - CONTAINERD_DIR=${DESTDIR}/usr/local RUNC_DIR=${DESTDIR} CNI_DIR=${DESTDIR}/opt/cni @@ -138,37 +133,6 @@ fi # Install containerd checkout_repo ${CONTAINERD_PKG} ${CONTAINERD_VERSION} ${CONTAINERD_REPO} cd ${GOPATH}/src/${CONTAINERD_PKG} -if ${COOK_CONTAINERD}; then - # Verify that vendor.conf is in sync with containerd before cook containerd, - # this is a hard requirement for now because of below overwrite of - # containerd's vendor tree. - # TODO(random-liu): Remove this and the below import code after containerd - # starts to vendor cri plugin. - if ! ${ROOT}/hack/sync-vendor.sh -only-verify; then - echo "Please run hack/sync-vendor.sh before cook containerd." - exit 1 - fi - # Import cri plugin into containerd. - echo "import _ \"${CRI_CONTAINERD_PKG}\"" >> cmd/containerd/builtins_linux.go - # 1. Copy all cri-containerd vendors into containerd vendor. This makes sure - # all dependencies introduced by cri-containerd will be updated. There might - # be unnecessary vendors introduced, but it still builds. - cp -rT ${ROOT}/vendor/ vendor/ - # 2. Remove containerd repo itself from vendor. - rm -rf vendor/${CONTAINERD_PKG} - # 3. Create cri-containerd vendor in containerd vendor, and copy the newest - # cri-containerd there. - if [ -d "vendor/${CRI_CONTAINERD_PKG}" ]; then - rm -rf vendor/${CRI_CONTAINERD_PKG}/* - else - mkdir -p vendor/${CRI_CONTAINERD_PKG} - fi - cp -rT ${ROOT} vendor/${CRI_CONTAINERD_PKG} - # 4. Remove the extra vendor in cri-containerd. - rm -rf vendor/${CRI_CONTAINERD_PKG}/vendor - # After the 4 steps above done, we have a containerd with newest cri-containerd - # plugin. -fi make BUILDTAGS="${BUILDTAGS}" # containerd make install requires `go` to work. Explicitly # set PATH to make sure it can find `go` even with `sudo`.