Skip to content

Commit f302936

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "C) Move swift defaults for config & data"
2 parents 9bab259 + 1e51c11 commit f302936

File tree

6 files changed

+82
-71
lines changed

6 files changed

+82
-71
lines changed

files/swift/account-server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mount_check = false
44
bind_port = %BIND_PORT%
55
user = %USER%
66
log_facility = LOG_LOCAL%LOG_FACILITY%
7-
swift_dir = %SWIFT_CONFIG_LOCATION%
7+
swift_dir = %SWIFT_CONFIG_DIR%
88

99
[pipeline:main]
1010
pipeline = account-server

files/swift/container-server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mount_check = false
44
bind_port = %BIND_PORT%
55
user = %USER%
66
log_facility = LOG_LOCAL%LOG_FACILITY%
7-
swift_dir = %SWIFT_CONFIG_LOCATION%
7+
swift_dir = %SWIFT_CONFIG_DIR%
88

99
[pipeline:main]
1010
pipeline = container-server

files/swift/object-server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mount_check = false
44
bind_port = %BIND_PORT%
55
user = %USER%
66
log_facility = LOG_LOCAL%LOG_FACILITY%
7-
swift_dir = %SWIFT_CONFIG_LOCATION%
7+
swift_dir = %SWIFT_CONFIG_DIR%
88

99
[pipeline:main]
1010
pipeline = object-server

files/swift/proxy-server.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22
bind_port = 8080
33
user = %USER%
4-
swift_dir = %SWIFT_CONFIG_LOCATION%
4+
swift_dir = %SWIFT_CONFIG_DIR%
55
workers = 1
66
log_name = swift
77
log_facility = LOG_LOCAL1

files/swift/rsyncd.conf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,74 @@ address = 127.0.0.1
66

77
[account6012]
88
max connections = 25
9-
path = %SWIFT_DATA_LOCATION%/1/node/
9+
path = %SWIFT_DATA_DIR%/1/node/
1010
read only = false
1111
lock file = /var/lock/account6012.lock
1212

1313
[account6022]
1414
max connections = 25
15-
path = %SWIFT_DATA_LOCATION%/2/node/
15+
path = %SWIFT_DATA_DIR%/2/node/
1616
read only = false
1717
lock file = /var/lock/account6022.lock
1818

1919
[account6032]
2020
max connections = 25
21-
path = %SWIFT_DATA_LOCATION%/3/node/
21+
path = %SWIFT_DATA_DIR%/3/node/
2222
read only = false
2323
lock file = /var/lock/account6032.lock
2424

2525
[account6042]
2626
max connections = 25
27-
path = %SWIFT_DATA_LOCATION%/4/node/
27+
path = %SWIFT_DATA_DIR%/4/node/
2828
read only = false
2929
lock file = /var/lock/account6042.lock
3030

3131

3232
[container6011]
3333
max connections = 25
34-
path = %SWIFT_DATA_LOCATION%/1/node/
34+
path = %SWIFT_DATA_DIR%/1/node/
3535
read only = false
3636
lock file = /var/lock/container6011.lock
3737

3838
[container6021]
3939
max connections = 25
40-
path = %SWIFT_DATA_LOCATION%/2/node/
40+
path = %SWIFT_DATA_DIR%/2/node/
4141
read only = false
4242
lock file = /var/lock/container6021.lock
4343

4444
[container6031]
4545
max connections = 25
46-
path = %SWIFT_DATA_LOCATION%/3/node/
46+
path = %SWIFT_DATA_DIR%/3/node/
4747
read only = false
4848
lock file = /var/lock/container6031.lock
4949

5050
[container6041]
5151
max connections = 25
52-
path = %SWIFT_DATA_LOCATION%/4/node/
52+
path = %SWIFT_DATA_DIR%/4/node/
5353
read only = false
5454
lock file = /var/lock/container6041.lock
5555

5656

5757
[object6010]
5858
max connections = 25
59-
path = %SWIFT_DATA_LOCATION%/1/node/
59+
path = %SWIFT_DATA_DIR%/1/node/
6060
read only = false
6161
lock file = /var/lock/object6010.lock
6262

6363
[object6020]
6464
max connections = 25
65-
path = %SWIFT_DATA_LOCATION%/2/node/
65+
path = %SWIFT_DATA_DIR%/2/node/
6666
read only = false
6767
lock file = /var/lock/object6020.lock
6868

6969
[object6030]
7070
max connections = 25
71-
path = %SWIFT_DATA_LOCATION%/3/node/
71+
path = %SWIFT_DATA_DIR%/3/node/
7272
read only = false
7373
lock file = /var/lock/object6030.lock
7474

7575
[object6040]
7676
max connections = 25
77-
path = %SWIFT_DATA_LOCATION%/4/node/
77+
path = %SWIFT_DATA_DIR%/4/node/
7878
read only = false
7979
lock file = /var/lock/object6040.lock

stack.sh

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}
376376
# TODO: add logging to different location.
377377

378378
# By default the location of swift drives and objects is located inside
379-
# the swift source directory. SWIFT_DATA_LOCATION variable allow you to redefine
379+
# the swift source directory. SWIFT_DATA_DIR variable allow you to redefine
380380
# this.
381-
SWIFT_DATA_LOCATION=${SWIFT_DATA_LOCATION:-${SWIFT_DIR}/data}
381+
SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DEST}/data/swift}
382382

383383
# We are going to have the configuration files inside the source
384-
# directory, change SWIFT_CONFIG_LOCATION if you want to adjust that.
385-
SWIFT_CONFIG_LOCATION=${SWIFT_CONFIG_LOCATION:-${SWIFT_DIR}/config}
384+
# directory, change SWIFT_CONFIG_DIR if you want to adjust that.
385+
SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift}
386386

387387
# devstack will create a loop-back disk formatted as XFS to store the
388388
# swift data. By default the disk size is 1 gigabyte. The variable
@@ -1129,39 +1129,39 @@ if is_service_enabled swift; then
11291129
# changing the permissions so we can run it as our user.
11301130

11311131
USER_GROUP=$(id -g)
1132-
sudo mkdir -p ${SWIFT_DATA_LOCATION}/drives
1133-
sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_LOCATION}
1132+
sudo mkdir -p ${SWIFT_DATA_DIR}/drives
1133+
sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
11341134

11351135
# We then create a loopback disk and format it to XFS.
11361136
# TODO: Reset disks on new pass.
1137-
if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]]; then
1138-
mkdir -p ${SWIFT_DATA_LOCATION}/drives/images
1139-
sudo touch ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1140-
sudo chown $USER: ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1137+
if [[ ! -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
1138+
mkdir -p ${SWIFT_DATA_DIR}/drives/images
1139+
sudo touch ${SWIFT_DATA_DIR}/drives/images/swift.img
1140+
sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img
11411141

1142-
dd if=/dev/zero of=${SWIFT_DATA_LOCATION}/drives/images/swift.img \
1142+
dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \
11431143
bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
1144-
mkfs.xfs -f -i size=1024 ${SWIFT_DATA_LOCATION}/drives/images/swift.img
1144+
mkfs.xfs -f -i size=1024 ${SWIFT_DATA_DIR}/drives/images/swift.img
11451145
fi
11461146

11471147
# After the drive being created we mount the disk with a few mount
11481148
# options to make it most efficient as possible for swift.
1149-
mkdir -p ${SWIFT_DATA_LOCATION}/drives/sdb1
1150-
if ! egrep -q ${SWIFT_DATA_LOCATION}/drives/sdb1 /proc/mounts; then
1149+
mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1
1150+
if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
11511151
sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \
1152-
${SWIFT_DATA_LOCATION}/drives/images/swift.img ${SWIFT_DATA_LOCATION}/drives/sdb1
1152+
${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1
11531153
fi
11541154

11551155
# We then create link to that mounted location so swift would know
11561156
# where to go.
11571157
for x in $(seq ${SWIFT_REPLICAS}); do
1158-
sudo ln -sf ${SWIFT_DATA_LOCATION}/drives/sdb1/$x ${SWIFT_DATA_LOCATION}/$x; done
1158+
sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$x ${SWIFT_DATA_DIR}/$x; done
11591159

11601160
# We now have to emulate a few different servers into one we
11611161
# create all the directories needed for swift
11621162
for x in $(seq ${SWIFT_REPLICAS}); do
1163-
drive=${SWIFT_DATA_LOCATION}/drives/sdb1/${x}
1164-
node=${SWIFT_DATA_LOCATION}/${x}/node
1163+
drive=${SWIFT_DATA_DIR}/drives/sdb1/${x}
1164+
node=${SWIFT_DATA_DIR}/${x}/node
11651165
node_device=${node}/sdb1
11661166
[[ -d $node ]] && continue
11671167
[[ -d $drive ]] && continue
@@ -1170,17 +1170,23 @@ if is_service_enabled swift; then
11701170
sudo chown -R $USER: ${node}
11711171
done
11721172

1173-
sudo mkdir -p ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server /var/run/swift
1174-
sudo chown -R $USER: ${SWIFT_CONFIG_LOCATION} /var/run/swift
1173+
sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server /var/run/swift
1174+
sudo chown -R $USER: ${SWIFT_CONFIG_DIR} /var/run/swift
11751175

1176-
# swift-init has a bug using /etc/swift until bug #885595 is fixed
1177-
# we have to create a link
1178-
sudo ln -sf ${SWIFT_CONFIG_LOCATION} /etc/swift
1176+
if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then
1177+
# Some swift tools are hard-coded to use /etc/swift and are apparenty not going to be fixed.
1178+
# Create a symlink if the config dir is moved
1179+
sudo ln -sf ${SWIFT_CONFIG_DIR} /etc/swift
1180+
fi
11791181

1180-
# Swift use rsync to syncronize between all the different
1181-
# partitions (which make more sense when you have a multi-node
1182-
# setup) we configure it with our version of rsync.
1183-
sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_DATA_LOCATION%,$SWIFT_DATA_LOCATION," $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
1182+
# Swift use rsync to syncronize between all the different
1183+
# partitions (which make more sense when you have a multi-node
1184+
# setup) we configure it with our version of rsync.
1185+
sed -e "
1186+
s/%GROUP%/${USER_GROUP}/;
1187+
s/%USER%/$USER/;
1188+
s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,;
1189+
" $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
11841190
sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
11851191

11861192
# By default Swift will be installed with the tempauth middleware
@@ -1195,7 +1201,7 @@ if is_service_enabled swift; then
11951201
# We do the install of the proxy-server and swift configuration
11961202
# replacing a few directives to match our configuration.
11971203
sed -e "
1198-
s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},g;
1204+
s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},g;
11991205
s,%USER%,$USER,g;
12001206
s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
12011207
s,%SERVICE_USERNAME%,swift,g;
@@ -1210,35 +1216,40 @@ if is_service_enabled swift; then
12101216
s,%KEYSTONE_AUTH_PROTOCOL%,${KEYSTONE_AUTH_PROTOCOL},g;
12111217
s/%AUTH_SERVER%/${swift_auth_server}/g;
12121218
" $FILES/swift/proxy-server.conf | \
1213-
sudo tee ${SWIFT_CONFIG_LOCATION}/proxy-server.conf
1214-
1215-
sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_LOCATION}/swift.conf
1216-
1217-
# We need to generate a object/account/proxy configuration
1218-
# emulating 4 nodes on different ports we have a little function
1219-
# that help us doing that.
1220-
function generate_swift_configuration() {
1221-
local server_type=$1
1222-
local bind_port=$2
1223-
local log_facility=$3
1224-
local node_number
1225-
1226-
for node_number in $(seq ${SWIFT_REPLICAS}); do
1227-
node_path=${SWIFT_DATA_LOCATION}/${node_number}
1228-
sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \
1229-
$FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_LOCATION}/${server_type}-server/${node_number}.conf
1230-
bind_port=$(( ${bind_port} + 10 ))
1231-
log_facility=$(( ${log_facility} + 1 ))
1232-
done
1233-
}
1234-
generate_swift_configuration object 6010 2
1235-
generate_swift_configuration container 6011 2
1236-
generate_swift_configuration account 6012 2
1219+
sudo tee ${SWIFT_CONFIG_DIR}/proxy-server.conf
1220+
1221+
sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_DIR}/swift.conf
1222+
1223+
# We need to generate a object/account/proxy configuration
1224+
# emulating 4 nodes on different ports we have a little function
1225+
# that help us doing that.
1226+
function generate_swift_configuration() {
1227+
local server_type=$1
1228+
local bind_port=$2
1229+
local log_facility=$3
1230+
local node_number
1231+
1232+
for node_number in $(seq ${SWIFT_REPLICAS}); do
1233+
node_path=${SWIFT_DATA_DIR}/${node_number}
1234+
sed -e "
1235+
s,%SWIFT_CONFIG_DIR%,${SWIFT_CONFIG_DIR},;
1236+
s,%USER%,$USER,;
1237+
s,%NODE_PATH%,${node_path},;
1238+
s,%BIND_PORT%,${bind_port},;
1239+
s,%LOG_FACILITY%,${log_facility},
1240+
" $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf
1241+
bind_port=$(( ${bind_port} + 10 ))
1242+
log_facility=$(( ${log_facility} + 1 ))
1243+
done
1244+
}
1245+
generate_swift_configuration object 6010 2
1246+
generate_swift_configuration container 6011 2
1247+
generate_swift_configuration account 6012 2
12371248

12381249

12391250
# We have some specific configuration for swift for rsyslog. See
12401251
# the file /etc/rsyslog.d/10-swift.conf for more info.
1241-
swift_log_dir=${SWIFT_DATA_LOCATION}/logs
1252+
swift_log_dir=${SWIFT_DATA_DIR}/logs
12421253
rm -rf ${swift_log_dir}
12431254
mkdir -p ${swift_log_dir}/hourly
12441255
sudo chown -R syslog:adm ${swift_log_dir}
@@ -1248,7 +1259,7 @@ if is_service_enabled swift; then
12481259

12491260
# This is where we create three different rings for swift with
12501261
# different object servers binding on different ports.
1251-
pushd ${SWIFT_CONFIG_LOCATION} >/dev/null && {
1262+
pushd ${SWIFT_CONFIG_DIR} >/dev/null && {
12521263

12531264
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
12541265

@@ -1644,7 +1655,7 @@ screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_
16441655
screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
16451656
screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
16461657
screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log"
1647-
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_LOCATION}/proxy-server.conf -v"
1658+
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"
16481659

16491660
# Starting the nova-objectstore only if swift service is not enabled.
16501661
# Swift will act as s3 objectstore.

0 commit comments

Comments
 (0)