Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon: fix reuse of osd ids (clear osd info on osd deletion) #6900

Merged
merged 2 commits into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions qa/workunits/ceph-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,42 @@ function test_run_osd() {

#######################################################################

##
# Shutdown and remove all traces of the osd by the name osd.**id**.
#
# The OSD is shutdown with the TERM signal. It is then removed from
# the auth list, crush map, osd map etc and the files associated with
# it are also removed.
#
# @param dir path name of the environment
# @param id osd identifier
# @return 0 on success, 1 on error
#
function destroy_osd() {
local dir=$1
local id=$2

kill_daemons $dir TERM osd.$id || return 1
ceph osd out osd.$id || return 1
ceph auth del osd.$id || return 1
ceph osd crush remove osd.$id || return 1
ceph osd rm $id || return 1
rm -fr $dir/$id
}

function test_destroy_osd() {
local dir=$1

setup $dir || return 1
run_mon $dir a || return 1
run_osd $dir 0 || return 1
destroy_osd $dir 0 || return 1
! ceph osd dump | grep "osd.$id " || return 1
teardown $dir || return 1
}

#######################################################################

##
# Run (activate) an osd by the name osd.**id** with data in
# **dir**/**id**. The logs can be found in **dir**/osd.**id**.log,
Expand Down Expand Up @@ -1204,10 +1240,42 @@ function test_erasure_code_plugin_exists() {

#######################################################################

##
# Display all log files from **dir** on stdout.
#
# @param dir directory in which all data is stored
#

function display_logs() {
local dir=$1

find $dir -maxdepth 1 -name '*.log' | \
while read file ; do
echo "======================= $file"
cat $file
done
}

function test_display_logs() {
local dir=$1

setup $dir || return 1
run_mon $dir a || return 1
kill_daemons $dir || return 1
display_logs $dir > $dir/log.out
grep --quiet mon.a.log $dir/log.out || return 1
teardown $dir || return 1
}

#######################################################################

##
# Call the **run** function (which must be defined by the caller) with
# the **dir** argument followed by the caller argument list.
#
# If the **run** function returns on error, all logs found in **dir**
# are displayed for diagnostic purposes.
#
# **teardown** function is called when the **run** function returns
# (on success or on error), to cleanup leftovers. The CEPH_CONF is set
# to /dev/null and CEPH_ARGS is unset so that the tests are protected from
Expand Down Expand Up @@ -1240,6 +1308,7 @@ function main() {
if run $dir "$@" ; then
code=0
else
display_logs $dir
code=1
fi
teardown $dir || return 1
Expand Down
16 changes: 14 additions & 2 deletions src/osd/OSDMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1347,9 +1347,21 @@ int OSDMap::apply_incremental(const Incremental &inc)
osd_xinfo[i->first].down_stamp = modified;
}
if ((osd_state[i->first] & CEPH_OSD_EXISTS) &&
(s & CEPH_OSD_EXISTS))
(s & CEPH_OSD_EXISTS)) {
// osd is destroyed; clear out anything interesting.
(*osd_uuid)[i->first] = uuid_d();
osd_state[i->first] ^= s;
osd_info[i->first] = osd_info_t();
osd_xinfo[i->first] = osd_xinfo_t();
osd_weight[i->first] = CEPH_OSD_IN;
set_primary_affinity(i->first, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
osd_addrs->client_addr[i->first].reset(new entity_addr_t());
osd_addrs->cluster_addr[i->first].reset(new entity_addr_t());
osd_addrs->hb_front_addr[i->first].reset(new entity_addr_t());
osd_addrs->hb_back_addr[i->first].reset(new entity_addr_t());
osd_state[i->first] = 0;
} else {
osd_state[i->first] ^= s;
}
}
for (map<int32_t,entity_addr_t>::const_iterator i = inc.new_up_client.begin();
i != inc.new_up_client.end();
Expand Down
1 change: 1 addition & 0 deletions src/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ check_SCRIPTS += \
test/osd/osd-scrub-repair.sh \
test/osd/osd-scrub-snaps.sh \
test/osd/osd-config.sh \
test/osd/osd-reuse-id.sh \
test/osd/osd-bench.sh \
test/osd/osd-reactivate.sh \
test/osd/osd-copy-from.sh \
Expand Down
51 changes: 51 additions & 0 deletions src/test/osd/osd-reuse-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /bin/bash
#
# Copyright (C) 2015 Red Hat <contact@redhat.com>
#
# Author: Loic Dachary <loic@dachary.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library Public License for more details.
#
source ../qa/workunits/ceph-helpers.sh

function run() {
local dir=$1
shift

export CEPH_MON="127.0.0.1:7123" # git grep '\<7123\>' : there must be only one
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "

local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
for func in $funcs ; do
$func $dir || return 1
done
}

function TEST_reuse_id() {
local dir=$1

setup $dir || return 1
run_mon $dir a --osd_pool_default_size=1 || return 1
run_osd $dir 0 || return 1
run_osd $dir 1 || return 1
wait_for_clean || return 1
destroy_osd $dir 1 || return 1
run_osd $dir 1 || return 1
}

main osd-reuse-id "$@"

# Local Variables:
# compile-command: "cd ../.. ; make -j4 && test/osd/osd-reuse-id.sh"
# End: