diff --git a/build/Dockerfile.initcontainer b/build/Dockerfile.initcontainer index 1fdbac24..d927aa5f 100644 --- a/build/Dockerfile.initcontainer +++ b/build/Dockerfile.initcontainer @@ -4,7 +4,7 @@ RUN apk add --update \ bc \ build-base \ curl \ - libelf-dev \ + elfutils-dev \ linux-headers \ make diff --git a/build/init/fetch-linux-headers.sh b/build/init/fetch-linux-headers.sh index f45ab72a..95635d01 100755 --- a/build/init/fetch-linux-headers.sh +++ b/build/init/fetch-linux-headers.sh @@ -14,7 +14,11 @@ generate_headers() echo "Generating kernel headers" cd "${BUILD_DIR}" - zcat /proc/config.gz > .config + if [ -e /proc/config.gz ]; then + zcat /proc/config.gz > .config + elif [ -e "/boot.host/config-${KERNEL_VERSION}" ]; then + cp "/boot.host/config-${KERNEL_VERSION}" .config + fi make ARCH=x86 oldconfig > /dev/null make ARCH=x86 prepare > /dev/null @@ -32,7 +36,10 @@ fetch_cos_linux_sources() fetch_generic_linux_sources() { - kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS=+ '{ print $1 }')" + # 4.19.76-linuxkit -> 4.19.76 + # 4.14.154-128.181.amzn2.x86_64 -> 4.14.154 + # 4.19.76+gcp-something -> 4.19.76 + kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS='[-+]' '{ print $1 }')" major_version="$(echo "${KERNEL_VERSION}" | awk -vFS=. '{ print $1 }')" echo "Fetching upstream kernel sources for ${kernel_version}." diff --git a/pkg/tracejob/job.go b/pkg/tracejob/job.go index e9c1071a..cd529f92 100644 --- a/pkg/tracejob/job.go +++ b/pkg/tracejob/job.go @@ -349,7 +349,7 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) { } if nj.FetchHeaders { - // If we aren't downloading headers, add the initContainer and set up mounts + // If we are downloading headers, add the initContainer and set up mounts job.Spec.Template.Spec.InitContainers = []apiv1.Container{ apiv1.Container{ Name: "kubectl-trace-init", @@ -388,6 +388,10 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) { Name: "linux-headers-generated", MountPath: "/usr/src/", }, + apiv1.VolumeMount{ + Name: "boot-host", + MountPath: "/boot.host", + }, }, }, } @@ -424,6 +428,14 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) { Path: "/var/cache/linux-headers/generated", }, }, + }, + apiv1.Volume{ + Name: "boot-host", + VolumeSource: apiv1.VolumeSource{ + HostPath: &apiv1.HostPathVolumeSource{ + Path: "/boot", + }, + }, }) job.Spec.Template.Spec.Containers[0].VolumeMounts = append(job.Spec.Template.Spec.Containers[0].VolumeMounts,