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

Commit

Permalink
rootfs: Support agent tracing
Browse files Browse the repository at this point in the history
Add `AGENT_TRACE=yes` option to build a rootfs with agent tracing support.

Fixes #199.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Nov 29, 2018
1 parent 751f395 commit 909d373
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ IMAGE_BUILDER := $(MK_DIR)/image-builder/image_builder.sh

IMG_SIZE = 500
AGENT_INIT ?= no
AGENT_TRACE ?= no
DISTRO ?= centos
ROOTFS_BUILD_DEST := $(PWD)
IMAGES_BUILD_DEST := $(PWD)
Expand Down
14 changes: 14 additions & 0 deletions rootfs-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ To build a rootfs for your chosen distribution, run:
$ sudo ./rootfs.sh <distro>
```

### Enabling tracing

To build a rootfs with agent tracing support, specify the `AGENT_TRACE=yes`
option:

```
$ sudo AGENT_TRACE="yes" AGENT_INIT="no" ./rootfs.sh <distro>
```

> **NOTE:**:
>
> Tracing only works for non-initrd images.
> See https://github.com/kata-containers/agent/blob/master/TRACING.md for further details.
## Creating a rootfs with kernel modules

To build a rootfs with additional kernel modules, run:
Expand Down
1 change: 1 addition & 0 deletions rootfs-builder/alpine/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ INIT_PROCESS=kata-agent
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/centos/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ INIT_PROCESS=systemd
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/clearlinux/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ INIT_PROCESS=systemd
ARCH_EXCLUDE_LIST=(ppc64le)

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/debian/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ INIT_PROCESS=systemd
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp2"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/euleros/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ARCH_EXCLUDE_LIST=()
BUILD_CAN_FAIL=1

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/fedora/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ INIT_PROCESS=systemd
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
27 changes: 25 additions & 2 deletions rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AGENT_VERSION=${AGENT_VERSION:-}
GO_AGENT_PKG=${GO_AGENT_PKG:-github.com/kata-containers/agent}
AGENT_BIN=${AGENT_BIN:-kata-agent}
AGENT_INIT=${AGENT_INIT:-no}
AGENT_TRACE=${AGENT_TRACE:-no}
KERNEL_MODULES_DIR=${KERNEL_MODULES_DIR:-""}
OSBUILDER_VERSION="unknown"

Expand Down Expand Up @@ -71,6 +72,11 @@ AGENT_INIT When set to "yes", use ${AGENT_BIN} as init process in place
of systemd.
Default value: no
AGENT_TRACE When set to "yes", create a rootfs containing additional
elements to support tracing the agent using https://jaegertracing.io.
Incompatible with AGENT_INIT="yes".
Default value: no
AGENT_VERSION Version of the agent to include in the rootfs.
Default value: ${AGENT_VERSION:-<not set>}
Expand Down Expand Up @@ -336,6 +342,7 @@ if [ -n "${USE_DOCKER}" ] ; then
--env ROOTFS_DIR="/rootfs" \
--env AGENT_BIN="${AGENT_BIN}" \
--env AGENT_INIT="${AGENT_INIT}" \
--env AGENT_TRACE="${AGENT_TRACE}" \
--env GOPATH="${GOPATH_LOCAL}" \
--env KERNEL_MODULES_DIR="${KERNEL_MODULES_DIR}" \
--env EXTRA_PKGS="${EXTRA_PKGS}" \
Expand All @@ -362,6 +369,10 @@ build_rootfs ${ROOTFS_DIR}
AGENT_DIR="${ROOTFS_DIR}/usr/bin"
AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}"

# Assume that if the user wants trace, they want the ability to see the guest
# OS journal messages for debug purposes
TRACE_DEV_MODE=${AGENT_TRACE}

if [ -z "${AGENT_SOURCE_BIN}" ] ; then
info "Pull Agent source code"
go get -d "${GO_AGENT_PKG}" || true
Expand All @@ -371,8 +382,20 @@ if [ -z "${AGENT_SOURCE_BIN}" ] ; then
pushd "${GOPATH_LOCAL}/src/${GO_AGENT_PKG}"
[ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful"
make clean
make INIT=${AGENT_INIT}
make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT} SECCOMP=${SECCOMP}
make INIT=${AGENT_INIT} TRACE=${AGENT_TRACE} TRACE_DEV_MODE=${TRACE_DEV_MODE}
make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT} TRACE=${AGENT_TRACE} SECCOMP=${SECCOMP} TRACE_DEV_MODE=${TRACE_DEV_MODE}

# List of additional agent systemd services (from the agent repository)
services=()

[ "${AGENT_TRACE}" = "yes" ] && services+=("jaeger-client-socat-redirector.service")
[ "${TRACE_DEV_MODE}" = "yes" ] && services+=("kata-journald-host-redirect.service")

for service in "${services[@]}"
do
chroot "${ROOTFS_DIR}" systemctl enable "$service"
done

popd
else
cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}
Expand Down
1 change: 1 addition & 0 deletions rootfs-builder/suse/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ if [ -z "${REPO_URL:-}" ]; then
fi

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp2"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"
1 change: 1 addition & 0 deletions rootfs-builder/ubuntu/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ INIT_PROCESS=systemd
ARCH_EXCLUDE_LIST=()

[ "$SECCOMP" = "yes" ] && PACKAGES+=" libseccomp2"
[ "$AGENT_TRACE" = "yes" ] && PACKAGES+=" socat"

0 comments on commit 909d373

Please sign in to comment.