-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathceph-debug-docker.sh
executable file
·114 lines (98 loc) · 3.04 KB
/
ceph-debug-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# This can be run from e.g. the senta machines which have docker available. You
# may need to run this script with sudo.
#
# Once you have booted into the image, you should be able to debug the core file:
# $ gdb -q /ceph/teuthology-archive/.../coredump/1500013578.8678.core
#
# You may want to install other packages (yum) as desired.
#
# Once you're finished, please delete old images in a timely fashion.
set -e
CACHE=""
function run {
printf "%s\n" "$*"
"$@"
}
function main {
eval set -- $(getopt --name "$0" --options 'h' --longoptions 'help,no-cache' -- "$@")
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help)
printf '%s: [--no-cache] <branch> <enviornment>\n' "$0"
exit 0
;;
--no-cache)
CACHE="--no-cache"
shift
;;
--)
shift
break
;;
esac
done
if [ -z "$1" ]; then
printf "specify the branch [default \"master\"]: "
read branch
if [ -z "$branch" ]; then
branch=master
fi
else
branch="$1"
fi
printf "branch: %s\n" "$branch"
if [ -z "$2" ]; then
printf "specify the build environment [default \"centos:7\"]: "
read env
if [ -z "$env" ]; then
env=centos:7
fi
else
env="$2"
fi
printf "env: %s\n" "$env"
if [ -n "$SUDO_USER" ]; then
user="$SUDO_USER"
elif [ -n "$USER" ]; then
user="$USER"
else
user="$(whoami)"
fi
image="${user}/ceph-ci:${branch}-${env/:/-}"
T=$(mktemp -d)
pushd "$T"
if grep ubuntu <<<"$env" > /dev/null 2>&1; then
# Docker makes it impossible to access anything outside the CWD : /
cp -- /ceph/shaman/cephdev.asc .
cat > Dockerfile <<EOF
FROM ${env}
WORKDIR /root
RUN apt-get update --yes --quiet && \
apt-get install --yes --quiet screen wget gdb software-properties-common python-software-properties apt-transport-https
COPY cephdev.asc cephdev.asc
RUN apt-key add cephdev.asc
RUN add-apt-repository "\$(wget --quiet -O - https://shaman.ceph.com/api/repos/ceph/${branch}/latest/${env/://}/repo)" && \
apt-get update --yes && \
apt-get install --yes --allow-unauthenticated ceph ceph-osd-dbg ceph-mds-dbg ceph-mgr-dbg ceph-mon-dbg ceph-fuse-dbg ceph-test-dbg radosgw-dbg
EOF
time run docker build $CACHE --tag "$image" .
else # try RHEL flavor
time run docker build $CACHE --tag "$image" - <<EOF
FROM ${env}
WORKDIR /root
RUN yum update -y && \
yum install -y screen epel-release wget psmisc ca-certificates gdb
RUN wget -O /etc/yum.repos.d/ceph-dev.repo https://shaman.ceph.com/api/repos/ceph/${branch}/latest/centos/7/repo && \
yum clean all && \
yum upgrade -y && \
yum install -y ceph ceph-debuginfo ceph-fuse
EOF
fi
popd
rm -rf -- "$T"
printf "built image %s\n" "$image"
run docker run -ti -v /ceph:/ceph:ro "$image"
return 0
}
main "$@"