]>
Commit | Line | Data |
---|---|---|
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 | ||
13 | set -e | |
14 | ||
15 | CACHE="" | |
f67539c2 | 16 | FLAVOR="default" |
c07f9fc5 FG |
17 | |
18 | function run { | |
19 | printf "%s\n" "$*" | |
20 | "$@" | |
21 | } | |
22 | ||
23 | function 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 | |
92 | FROM ${env} | |
93 | ||
94 | WORKDIR /root | |
95 | RUN apt-get update --yes --quiet && \ | |
11fdf7f2 | 96 | apt-get install --yes --quiet screen gdb software-properties-common apt-transport-https curl |
c07f9fc5 | 97 | COPY cephdev.asc cephdev.asc |
11fdf7f2 | 98 | RUN 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 | 102 | EOF |
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 |
119 | FROM ${env} |
120 | ||
121 | WORKDIR /root | |
122 | RUN yum update -y && \ | |
f67539c2 TL |
123 | yum install -y tmux epel-release wget psmisc ca-certificates gdb |
124 | RUN 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 |
128 | EOF |
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 | ||
139 | main "$@" |