-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathboot
More file actions
executable file
·64 lines (52 loc) · 2.42 KB
/
boot
File metadata and controls
executable file
·64 lines (52 loc) · 2.42 KB
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
#!/bin/bash
# Borrows heavily from Seán C. McCord's https://github.com/Ulexus/docker-ceph repository
ETCD_PORT=${ETCD_PORT:-4001}
ETCD="$HOST:$ETCD_PORT"
ETCD_PATH=${ETCD_PATH:-/deis/store}
HOSTNAME=`hostname`
MDS_NAME=$HOSTNAME
until confd -onetime -node $ETCD -config-file /app/confd.toml >/dev/null 2>&1 ; do
echo "store-metadata: waiting for confd to write initial templates..."
sleep 5
done
if ! etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupComplete >/dev/null 2>&1 ; then
echo "store-metadata: The Ceph filesystem hasn't been created. Trying to obtain the lock to set up..."
# let's rock and roll. we need to obtain a lock so we can ensure only one machine is trying to deploy the cluster
if etcdctl --no-sync -C $ETCD mk ${ETCD_PATH}/filesystemSetupLock $HOSTNAME >/dev/null 2>&1 \
|| [[ `etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupLock` == "$HOSTNAME" ]] ; then
echo "store-metadata: obtained the lock to proceed with setting up."
PG_NUM=`etcdctl --no-sync -C $ETCD get /deis/store/pgNum`
# even though we know setup hasn't completed, we could be upgrading an older cluster which
# has the pools but not the filesystemSetupComplete key
if ! ceph osd lspools | grep " data," ; then
ceph osd pool create data ${PG_NUM}
fi
if ! ceph osd lspools | grep metadata ; then
ceph osd pool create metadata ${PG_NUM}
fi
if ceph fs ls | grep "No filesystems enabled" ; then
ceph fs new deis metadata data
fi
# mark setup as complete
echo "store-metadata: filesystem setup complete."
etcdctl --no-sync -C $ETCD set ${ETCD_PATH}/filesystemSetupComplete youBetcha >/dev/null
else
until etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupComplete >/dev/null 2>&1 ; do
echo "store-metadata: waiting for another metadata to complete setup..."
sleep 5
done
fi
fi
# Check to see if we are a new MDS
if [ ! -e /var/lib/ceph/mds/ceph-$MDS_NAME/keyring ]; then
mkdir -p /var/lib/ceph/mds/ceph-${MDS_NAME}
# See if we need to generate a key for the MDS
if [ -e /etc/ceph/ceph.mds.keyring ]; then
cp /etc/ceph/ceph.mds.keyring /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring
else
# Generate the new MDS key
ceph auth get-or-create mds.$MDS_NAME mds 'allow' osd 'allow *' mon 'allow profile mds' > /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring
fi
fi
echo "store-metadata: running..."
exec /usr/bin/ceph-mds -d -i ${MDS_NAME}