]> git.proxmox.com Git - ceph.git/blame - ceph/src/script/ceph-debug-docker.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / script / ceph-debug-docker.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
c07f9fc5
FG
2
3# This can be run from e.g. the senta machines which have docker available. You
4# may need to run this script with sudo.
5#
6# Once you have booted into the image, you should be able to debug the core file:
7# $ gdb -q /ceph/teuthology-archive/.../coredump/1500013578.8678.core
8#
9# You may want to install other packages (yum) as desired.
10#
11# Once you're finished, please delete old images in a timely fashion.
12
13set -e
14
15CACHE=""
f67539c2 16FLAVOR="default"
c07f9fc5
FG
17
18function run {
19 printf "%s\n" "$*"
20 "$@"
21}
22
23function main {
f67539c2 24 eval set -- $(getopt --name "$0" --options 'h' --longoptions 'help,no-cache,flavor:' -- "$@")
c07f9fc5
FG
25
26 while [ "$#" -gt 0 ]; do
27 case "$1" in
28 -h|--help)
11fdf7f2 29 printf '%s: [--no-cache] <branch>[:sha1] <environment>\n' "$0"
c07f9fc5
FG
30 exit 0
31 ;;
32 --no-cache)
33 CACHE="--no-cache"
34 shift
35 ;;
f67539c2
TL
36 --flavor)
37 FLAVOR=$2
38 shift 2
39 ;;
c07f9fc5
FG
40 --)
41 shift
42 break
43 ;;
44 esac
45 done
46
47 if [ -z "$1" ]; then
11fdf7f2
TL
48 printf "specify the branch [default \"master:latest\"]: "
49 read source
50 if [ -z "$source" ]; then
51 source=master:latest
c07f9fc5
FG
52 fi
53 else
54 branch="$1"
55 fi
11fdf7f2
TL
56 if [ "${branch%%:*}" != "${branch}" ]; then
57 sha=${branch##*:}
58 else
59 sha=latest
60 fi
61 branch=${branch%%:*}
62 printf "branch: %s\nsha1: %s\n" "$branch" "$sha"
c07f9fc5
FG
63
64 if [ -z "$2" ]; then
f67539c2 65 printf "specify the build environment [default \"centos:8\"]: "
c07f9fc5
FG
66 read env
67 if [ -z "$env" ]; then
f67539c2 68 env=centos:8
c07f9fc5
FG
69 fi
70 else
71 env="$2"
72 fi
73 printf "env: %s\n" "$env"
74
75 if [ -n "$SUDO_USER" ]; then
76 user="$SUDO_USER"
77 elif [ -n "$USER" ]; then
78 user="$USER"
79 else
80 user="$(whoami)"
81 fi
82
11fdf7f2 83 tag="${user}:ceph-ci-${branch}-${sha}-${env/:/-}"
c07f9fc5
FG
84
85 T=$(mktemp -d)
86 pushd "$T"
f67539c2 87 repo_url="https://shaman.ceph.com/api/repos/ceph/${branch}/${sha}/${env/://}/flavors/${FLAVOR}/repo"
c07f9fc5
FG
88 if grep ubuntu <<<"$env" > /dev/null 2>&1; then
89 # Docker makes it impossible to access anything outside the CWD : /
90 cp -- /ceph/shaman/cephdev.asc .
91 cat > Dockerfile <<EOF
92FROM ${env}
93
94WORKDIR /root
95RUN apt-get update --yes --quiet && \
11fdf7f2 96 apt-get install --yes --quiet screen gdb software-properties-common apt-transport-https curl
c07f9fc5 97COPY cephdev.asc cephdev.asc
11fdf7f2 98RUN apt-key add cephdev.asc && \
f67539c2 99 curl -L $repo_url | tee /etc/apt/sources.list.d/ceph_dev.list && \
c07f9fc5 100 apt-get update --yes && \
11fdf7f2 101 DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get --assume-yes -q --no-install-recommends install -o Dpkg::Options::=--force-confnew --allow-unauthenticated ceph ceph-osd-dbg ceph-mds-dbg ceph-mgr-dbg ceph-mon-dbg ceph-common-dbg ceph-fuse-dbg ceph-test-dbg radosgw-dbg python3-cephfs python3-rados
c07f9fc5 102EOF
11fdf7f2 103 time run docker build $CACHE --tag "$tag" .
c07f9fc5 104 else # try RHEL flavor
f67539c2
TL
105 case "$env" in
106 centos:7)
107 python_bindings="python36-rados python36-cephfs"
108 ceph_debuginfo="ceph-debuginfo"
109 ;;
110 centos:8)
111 python_bindings="python3-rados python3-cephfs"
112 ceph_debuginfo="ceph-base-debuginfo"
113 ;;
114 esac
115 if [ "${FLAVOR}" = "crimson" ]; then
116 ceph_debuginfo+=" ceph-crimson-osd-debuginfo ceph-crimson-osd"
117 fi
11fdf7f2 118 time run docker build $CACHE --tag "$tag" - <<EOF
c07f9fc5
FG
119FROM ${env}
120
121WORKDIR /root
122RUN yum update -y && \
f67539c2
TL
123 yum install -y tmux epel-release wget psmisc ca-certificates gdb
124RUN wget -O /etc/yum.repos.d/ceph-dev.repo $repo_url && \
c07f9fc5
FG
125 yum clean all && \
126 yum upgrade -y && \
f67539c2 127 yum install -y ceph ${ceph_debuginfo} ceph-fuse ${python_bindings}
c07f9fc5
FG
128EOF
129 fi
130 popd
131 rm -rf -- "$T"
132
11fdf7f2 133 printf "built image %s\n" "$tag"
c07f9fc5 134
11fdf7f2 135 run docker run -ti -v /ceph:/ceph:ro "$tag"
c07f9fc5
FG
136 return 0
137}
138
139main "$@"