diff options
Diffstat (limited to 'extras/devel-tools')
6 files changed, 201 insertions, 13 deletions
diff --git a/extras/devel-tools/devel-vagrant/Vagrantfile b/extras/devel-tools/devel-vagrant/Vagrantfile index 43783e441cb..78dc29bdc68 100644 --- a/extras/devel-tools/devel-vagrant/Vagrantfile +++ b/extras/devel-tools/devel-vagrant/Vagrantfile @@ -13,6 +13,8 @@ node_count = 0 disk_count = -1 node_name = "Node" ipbase="192.168.99." +source_path = "/source/glusterfs" +target_path = "/mnt/src" if ARGV[0] == "up" environment = open('vagrant_env.conf', 'w') @@ -40,9 +42,16 @@ if ARGV[0] == "up" end end + print "\e[1;37mEnter GlusterFS source location? Default: \"#{source_path}\" : \e[32m" + tmploc = $stdin.gets.strip.to_s + if tmploc != "" + source_path = "#{tmploc}" + end + environment.puts("# BEWARE: Do NOT modify ANY settings in here or your vagrant environment will be messed up") environment.puts(node_count.to_s) environment.puts(disk_count.to_s) + environment.puts(source_path) print "\e[32m\nOK I will provision #{node_count} VMs for you and each one will have #{disk_count} disks for bricks\e[37m\n\n" system "sleep 1" @@ -52,6 +61,7 @@ else # So that we destroy and can connect to all VMs... environment.readline # Skip the comment on top node_count = environment.readline.to_i disk_count = environment.readline.to_i + source_path = environment.readline.gsub(/\s+/, "") if ARGV[0] != "ssh-config" puts "Detected settings from previous vagrant up:" @@ -85,13 +95,17 @@ def attachDisks(numDisk, provider) $devnamecreated = true end + +$ansivar["src_path"].push "#{source_path}" +$ansivar["trg_path"].push "#{target_path}" + groups = Hash.new{ |hash,key| hash[key] = [] } groups["origin"].push "#{node_name}1" groups["all"].push "#{node_name}1" (2..node_count).each do |num| - groups["group1"].push "#{node_name}#{num}" + $ansivar["peer_nodes"].push "#{node_name}#{num}" groups["all"].push "#{node_name}#{num}" end @@ -100,7 +114,6 @@ hostsFile = "\n" hostsFile += "#{ipbase}#{( 100 + num).to_s} #{node_name}#{num.to_s}\n" end - Vagrant.configure("2") do |config| (1..node_count).each do |num| config.vm.define "#{node_name}#{num}" do |node| @@ -110,7 +123,7 @@ Vagrant.configure("2") do |config| node.vm.box_url = box_url node.vm.hostname = "#{node_name}#{num}" node.ssh.insert_key = false - node.vm.synced_folder "/work/source", "/work/source", type: "nfs" + node.vm.synced_folder "#{source_path}", "#{target_path}", type: "nfs" # Define basic config for VM, memory, cpu, storage pool node.vm.provider "libvirt" do |virt| @@ -124,7 +137,7 @@ Vagrant.configure("2") do |config| node.vm.post_up_message = "\e[37mBuilding of this VM is finished \n" "You can access it now with: \n" "vagrant ssh #{node_name}#{num.to_s}\n\n" - "/work/source directory in VM #{node_name}#{num.to_s}" + "#{target_path} directory in VM #{node_name}#{num.to_s}" "is synced with Host machine. \nSo any changes done in this" "directory will be reflected in the host machine as well\n" "Beware of this when you delete content from this directory\e[32m" diff --git a/extras/devel-tools/devel-vagrant/ansible/roles/cluster/tasks/main.yml b/extras/devel-tools/devel-vagrant/ansible/roles/cluster/tasks/main.yml index 1f1ab6116d6..3306c7a3dc2 100644 --- a/extras/devel-tools/devel-vagrant/ansible/roles/cluster/tasks/main.yml +++ b/extras/devel-tools/devel-vagrant/ansible/roles/cluster/tasks/main.yml @@ -1,6 +1,5 @@ --- -- name: Gluster peer probe +- name: gluster peer probe shell: gluster peer probe {{ item }} - with_items: groups ['group1'] - + with_items: "{{ peer_nodes | default([]) }}" diff --git a/extras/devel-tools/devel-vagrant/ansible/roles/compile-gluster/tasks/main.yml b/extras/devel-tools/devel-vagrant/ansible/roles/compile-gluster/tasks/main.yml index 1807dc05f33..6ee258c7780 100644 --- a/extras/devel-tools/devel-vagrant/ansible/roles/compile-gluster/tasks/main.yml +++ b/extras/devel-tools/devel-vagrant/ansible/roles/compile-gluster/tasks/main.yml @@ -1,9 +1,10 @@ --- - name: autogen.sh - shell: chdir=/work/source/glusterfs ./autogen.sh + shell: chdir={{ item }} ./autogen.sh + with_items: "{{ trg_path }}" - name: configure - shell: chdir=/work/source/glusterfs CFLAGS="-g -O0 -Werror -Wall -Wno-error=cpp -Wno-error=maybe-uninitialized" \ + shell: chdir={{ item }} CFLAGS="-g -O0 -Werror -Wall -Wno-error=cpp -Wno-error=maybe-uninitialized" \ ./configure \ --prefix=/usr \ --exec-prefix=/usr \ @@ -20,7 +21,9 @@ --infodir=/usr/share/info \ --libdir=/usr/lib64 \ --enable-debug + with_items: "{{ trg_path }}" - name: make install - shell: chdir=/work/source/glusterfs make install + shell: chdir={{ item }} make install + with_items: "{{ trg_path }}" diff --git a/extras/devel-tools/devel-vagrant/ansible/setup.yml b/extras/devel-tools/devel-vagrant/ansible/setup.yml index 764078f3669..c26bd7d6051 100644 --- a/extras/devel-tools/devel-vagrant/ansible/setup.yml +++ b/extras/devel-tools/devel-vagrant/ansible/setup.yml @@ -1,6 +1,7 @@ --- - hosts: all - sudo: true + become: yes + become_method: sudo roles: - install-pkgs - prepare-brick @@ -8,13 +9,15 @@ - iptables - hosts: all - sudo: true + become: yes + become_method: sudo serial: 1 roles: - compile-gluster - service - hosts: origin - sudo: true + become: yes + become_method: sudo roles: - cluster diff --git a/extras/devel-tools/print-backtrace.sh b/extras/devel-tools/print-backtrace.sh new file mode 100755 index 00000000000..33fbae288bc --- /dev/null +++ b/extras/devel-tools/print-backtrace.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# sample unresolved backtrace lines picked up from a brick log that should go +# into a backtrace file eg. bt-file.txt: +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3ec81)[0x7fe4bc271c81] +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3eecd)[0x7fe4bc271ecd] +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x404cb)[0x7fe4bc2734cb] +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3d2b6)[0x7fe4bc2702b6] +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3d323)[0x7fe4bc270323] +# +# following is the output of the script for the above backtrace lines: +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3ec81)[0x7fe4bc271c81] __afr_selfheal_data_finalize_source inlined at /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-data.c:684 in __afr_selfheal_data_prepare /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-data.c:603 +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3eecd)[0x7fe4bc271ecd] __afr_selfheal_data /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-data.c:740 +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x404cb)[0x7fe4bc2734cb] afr_selfheal_data /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-data.c:883 +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3d2b6)[0x7fe4bc2702b6] afr_selfheal_do /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-common.c:1968 +# /usr/lib64/glusterfs/3.8.4/xlator/cluster/replicate.so(+0x3d323)[0x7fe4bc270323] afr_selfheal /usr/src/debug/glusterfs-3.8.4/xlators/cluster/afr/src/afr-self-heal-common.c:2015 +# +# Usage with debuginfo RPM: +# print-backtrace.sh $HOME/Downloads/glusterfs-debuginfo-3.8.4-10.el7.x86_64.rpm bt-file.txt +# +# Usage with source install: +# print-packtrace.sh none bt-file.txt + +function version_compare() { test $(echo $1|awk -F '.' '{print $1 $2 $3}') -gt $(echo $2|awk -F '.' '{print $1 $2 $3}'); } + +function Usage() +{ + echo -e "Usage:\n\t$0 { none | <debuginfo-rpm> } <backtrace-file>" + echo "none: implies we don't have a debuginfo rpm but want to resolve" + echo " against a source install which already has the debuginfo" + echo " NOTE: in this case you should have configured the build" + echo " with --enable-debug and the linker options should" + echo " have the option -rdynamic" +} + +debuginfo_rpm=$1 +backtrace_file=$2 + +if [ ! $debuginfo_rpm ] || [ ! $backtrace_file ]; then + Usage + exit 1 +fi + +if [ $debuginfo_rpm != "none" ]; then + if [ ! -f $debuginfo_rpm ]; then + echo "no such rpm file: $debuginfo_rpm" + exit 1 + fi +fi + +if [ ! -f $backtrace_file ]; then + echo "no such backtrace file: $backtrace_file" + exit 1 +fi + +if [ "$debuginfo_rpm" != "none" ]; then + if ! file $debuginfo_rpm | grep RPM >/dev/null 2>&1 ; then + echo "file does not look like an rpm: $debuginfo_rpm" + exit 1 + fi +fi + +cpio_version=$(cpio --version|grep cpio|cut -f 2 -d ')'|sed -e 's/^[[:space:]]*//') +rpm_name="" +debuginfo_path="" +debuginfo_extension="" + +if [ $debuginfo_rpm != "none" ]; then + # extract the gluster debuginfo rpm to resolve the symbols against + rpm_name=$(basename $debuginfo_rpm '.rpm') + if [ -d $rpm_name ]; then + echo "directory already exists: $rpm_name" + echo "please remove/move it and reattempt" + exit 1 + fi + mkdir -p $rpm_name + if version_compare $cpio_version "2.11"; then + rpm2cpio $debuginfo_rpm | cpio --quiet --extract --make-directories --preserve-modification-time --directory=$rpm_name + ret=$? + else + current_dir="$PWD" + cd $rpm_name + rpm2cpio $debuginfo_rpm | cpio --quiet --extract --make-directories --preserve-modification-time + ret=$? + cd $current_dir + fi + if [ $ret -eq 1 ]; then + echo "failed to extract rpm $debuginfo_rpm to $PWD/$rpm_name directory" + rm -rf $rpm_name + exit 1 + fi + debuginfo_path="$PWD/$rpm_name/usr/lib/debug" + debuginfo_extension=".debug" +else + debuginfo_path="" + debuginfo_extension="" +fi + +# NOTE: backtrace file should contain only the lines which need to be resolved +for bt in $(cat $backtrace_file) +do + libname=$(echo $bt | cut -f 1 -d '(') + addr=$(echo $bt | cut -f 2 -d '(' | cut -f 1 -d ')') + libpath=${debuginfo_path}${libname}${debuginfo_extension} + if [ ! -f $libpath ]; then + continue + fi + newbt=( $(eu-addr2line --functions --exe=$libpath $addr) ) + echo "$bt ${newbt[*]}" +done + +# remove the temporary directory +if [ -d $rpm_name ]; then + rm -rf $rpm_name +fi + diff --git a/extras/devel-tools/strace-brick.sh b/extras/devel-tools/strace-brick.sh new file mode 100755 index 00000000000..a140729111c --- /dev/null +++ b/extras/devel-tools/strace-brick.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Usage: +# nice -n -19 strace-brick.sh glusterfsd 50 + +brick_process_name=$1 +min_watch_cpu=$2 +if [ ! $brick_process_name ]; then + brick_process_name=glusterfsd +fi + +if [ ! $min_watch_cpu ]; then + min_watch_cpu=50 +fi + +echo "min_watch_cpu: $min_watch_cpu" + +break=false + +while ! $break; +do + mypids=( $(pgrep $brick_process_name) ) + echo "mypids: ${mypids[*]}" + + pid_args=$(echo ${mypids[*]} | sed -e 's/ / -p /g;s/^/-p /') + echo "pid_args: $pid_args" + + pcpu=( $(ps $pid_args -o pcpu -h ) ) + echo "pcpu: ${pcpu[*]}" + + wait_longer=false + + for i in $( seq 0 $((${#pcpu[*]} - 1)) ) + do + echo "i: $i" + echo "mypids[$i]: ${mypids[$i]}" + + int_pcpu=$(echo ${pcpu[$i]} | cut -f 1 -d '.') + echo "int_pcpu: $int_pcpu" + if [ ! $int_pcpu ] || [ ! $min_watch_cpu ]; then + break=true + echo "breaking" + fi + if [ $int_pcpu -ge $min_watch_cpu ]; then + wait_longer=true + mydirname="${brick_process_name}-${mypids[$i]}-$(date --utc +'%Y%m%d-%H%M%S.%N')" + $(mkdir $mydirname && cd $mydirname && timeout --kill-after=5 --signal=KILL 60 nice -n -19 strace -p ${mypids[$i]} -ff -tt -T -o $brick_process_name) & + fi + done + + if $wait_longer; then + sleep 90 + else + sleep 15 + fi +done |
