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

Feature/planning 499 different error codes for version check #3118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
754df39
return different error codes for check-version
jsteemann Jul 26, 2017
9feecd4
Merge remote-tracking branch 'origin/devel' into feature/planning-499…
ObiWahn Aug 15, 2017
a283279
Adds data file for exit codes that can be used by ArangoDB applications
ObiWahn Aug 15, 2017
035d6d2
add some exit codes
ObiWahn Aug 15, 2017
ce234bd
better return codes for centos
ObiWahn Aug 15, 2017
0a7c6fd
add codes in arangod
ObiWahn Aug 15, 2017
a80d094
remove test code
ObiWahn Aug 15, 2017
5e075ce
prevent re-downloading of starter and other small improvements
ObiWahn Aug 16, 2017
75513e9
fix some erros
ObiWahn Aug 16, 2017
8301e1e
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
ObiWahn Aug 16, 2017
4835744
finish centos
ObiWahn Aug 16, 2017
7111f2d
update urls
ObiWahn Aug 16, 2017
492f037
add info about systemd detection
ObiWahn Aug 17, 2017
d2a21e9
move further towards a working systemd setup
ObiWahn Aug 17, 2017
5a95b3e
set service type to simple
ObiWahn Aug 17, 2017
d787af6
add arangodb-update-db script
ObiWahn Aug 17, 2017
1b80004
start work on debian packages
ObiWahn Aug 18, 2017
4002a0a
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
ObiWahn Aug 18, 2017
407604c
a db dir that is already in place (former installation) should be reu…
ObiWahn Aug 18, 2017
7b98f66
fix minor bugs
ObiWahn Aug 18, 2017
8009a27
Implement exit code translation in the windows installer.
dothebart Aug 18, 2017
5c090d4
add autogenerated NSIS exit code mapping
dothebart Aug 18, 2017
42951ab
Merge branch 'devel' of https://github.com/arangodb/arangodb into fea…
ObiWahn Aug 24, 2017
5da38f8
Merge branch 'devel' into feature/planning-499-different-error-codes-…
fceller Aug 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ core.*
*.gcno
*.gcda

*.deb
*.rpm

.DS_Store
*.swp
*.diff
Expand Down Expand Up @@ -110,3 +113,6 @@ data-*
cluster-init

datafile-*.db
# by build process
arangodb-linux-amd64
last_compiled_version.sha
45 changes: 43 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,23 @@ get_filename_component(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" REALPATH)

set($ENV{PYTHON_EXECUTABLE} ${PYTHON_EXECUTABLE})

# FIXME the build containers seem to have a
# /usr/bin/ch(mod|own) to prevent the search
# to find those files the NO_DEFAULT_PATH
# argument is passed
if (NOT WINDOWS)
find_program(CHMOD_EXECUTABLE chmod)
find_program(CHOWN_EXECUTABLE chown)
find_program(
CHMOD_EXECUTABLE chmod
PATHS "/bin/" "/usr/bin/"
NO_DEFAULT_PATH
)
message(STATUS "chmod found in ${CHMOD_EXECUTABLE}")
find_program(
CHOWN_EXECUTABLE chown
PATHS "/bin" "/usr/bin"
NO_DEFAULT_PATH
)
message(STATUS "chown found in ${CHOWN_EXECUTABLE}")
endif()

################################################################################
Expand Down Expand Up @@ -894,6 +908,33 @@ if (USE_MAINTAINER_MODE)
endforeach ()

add_custom_target(errorfiles ALL DEPENDS ${ERROR_FILES_GEN})

set(EXIT_CODE_FILES
lib/Basics/exitcodes.h
lib/Basics/exitcodes.cpp
js/common/bootstrap/exitcodes.js
Installation/Windows/Plugins/exitcodes.nsh
)

set(EXIT_CODE_FILES_GEN)
set(EXIT_CODES_DAT lib/Basics/exitcodes.dat)

foreach (m IN LISTS EXIT_CODE_FILES)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${m}
COMMAND ${PYTHON_EXECUTABLE} ./utils/generateExitCodesFiles.py ./${EXIT_CODES_DAT} ./${m}.tmp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ./${m}.tmp ./${m}
COMMAND ${CMAKE_COMMAND} -E remove ./${m}.tmp
DEPENDS ${CMAKE_SOURCE_DIR}/${EXIT_CODES_DAT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building exitcode files ${m}"
VERBATIM
)

list(APPEND EXIT_CODE_FILES_GEN ${CMAKE_SOURCE_DIR}/${m})
endforeach ()

add_custom_target(exitcodefiles ALL DEPENDS ${EXIT_CODE_FILES_GEN})
endif ()

################################################################################
Expand Down
14 changes: 11 additions & 3 deletions Installation/Jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,18 @@ if test "${DOWNLOAD_STARTER}" == 1; then
if test -f "${TN}"; then
rm -f "${TN}"
fi
curl -LO "${STARTER_URL}"
FN=$(echo "${STARTER_URL}" |${SED} "s;.*/;;")
mv "${FN}" "${BUILD_DIR}/${TN}"
chmod a+x "${BUILD_DIR}/${TN}"

echo $FN
if ! test -f "${BUILD_DIR}/${FN}-${STARTER_REV}"; then
curl -LO "${STARTER_URL}"
cp "${FN}" "${BUILD_DIR}/${TN}"
touch "${BUILD_DIR}/${FN}-${STARTER_REV}"
chmod a+x "${BUILD_DIR}/${TN}"
echo "downloaded ${BUILD_DIR}/${FN}-${STARTER_REV} MD5: $(${MD5} < "${BUILD_DIR}/${TN}")"
else
echo "using already downloaded ${BUILD_DIR}/${FN}-${STARTER_REV} MD5: $(${MD5} < "${BUILD_DIR}/${TN}")"
fi
fi
CONFIGURE_OPTIONS+=("-DTHIRDPARTY_BIN=${BUILD_DIR}/${TN}")
fi
Expand Down
75 changes: 75 additions & 0 deletions Installation/Windows/Plugins/exitcodes.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

!include "LogicLib.nsh"
!macro printExitCode exitCode Message
Push "${exitCode}"
Push "${Message}"
Call printExitCode
!macroend
Function printExitCode
pop $1
pop $2
${Switch} $0


${Case} 0 # EXIT_SUCCESS
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nsuccess'
; No error has occurred.
${Break}

${Case} 1 # EXIT_FAILED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nexit with error'
; Will be returned when a general error occurred.
${Break}

${Case} 2 # EXIT_CODE_RESOLVING_FAILED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nexit code resolving failed'
; fill me
${Break}

${Case} 5 # EXIT_BINARY_NOT_FOUND
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nbinary not found'
; fill me
${Break}

${Case} 6 # EXIT_CONFIG_NOT_FOUND
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nconfig not found'
; fill me
${Break}

${Case} 10 # EXIT_UPGRADE_FAILED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nupgrade failed'
; Will be returned when the database upgrade failed
${Break}

${Case} 11 # EXIT_UPGRADE_REQUIRED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\ndb upgrade required'
; Will be returned when a database upgrade is required
${Break}

${Case} 12 # EXIT_DOWNGRADE_REQUIRED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\ndb downgrade required'
; Will be returned when a database upgrade is required
${Break}

${Case} 13 # EXIT_VERSION_CHECK_FAILED
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nversion check failed'
; Will be returned when there is a version mismatch
${Break}

${Case} 20 # EXIT_ALREADY_RUNNING
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nalready running'
; Will be returned when arangod is already running according to PID-file
${Break}

${Case} 21 # EXIT_COULD_NOT_BIND_PORT
MessageBox MB_ICONEXCLAMATION '$1:$\r$\nport blocked'
; Will be returned when endpoint is taken by another process
${Break}

${Case} 22 # EXIT_COULD_NOT_LOCK
MessageBox MB_ICONEXCLAMATION '$1:$\r$\ncould not lock - another process could be running'
; fill me
${Break}

${EndSwitch}
FunctionEnd
13 changes: 10 additions & 3 deletions Installation/Windows/Templates/NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!addincludedir '@CPACK_PLUGIN_PATH@/UAC-plug-in-NSIS'
!addincludedir '@CPACK_PLUGIN_PATH@/'
!include "OpenLink.nsh"
!include "exitcodes.nsh"

;--------------------------------
; Include LogicLib for more readable code
Expand Down Expand Up @@ -718,7 +719,10 @@ Function UpgradeExisting
DetailPrint "Checking whether an existing database needs upgrade: "
ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.foreground-tty false --database.check-version" $0
DetailPrint "done Checking whether an existing database needs upgrade: $0"
${If} $0 == 1
${If} $0 != 0
${AndIf} $0 != 11
!insertmacro printExitCode $0 "failed to detect whether we need to Upgrade"
${ElseIf} $0 == 11
${AndIf} $AUTOMATIC_UPDATE == "1"
DetailPrint "Yes."

Expand All @@ -740,8 +744,8 @@ Function UpgradeExisting
; Now actually do the upgrade
ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.level error --database.auto-upgrade true" $0
DetailPrint "Done running database upgrade: $0"
${If} $0 == 1
MessageBox MB_ICONEXCLAMATION "the Upgrade failed, please do a manual upgrade"
${If} $0 != 0
!insertmacro printExitCode $0 "the Upgrade failed, please do a manual upgrade"
Abort
${EndIf}
${EndIf}
Expand All @@ -757,6 +761,9 @@ Function SetDBPassword
DetailPrint "Done initializing password: $0"
${If} $0 == 0
return
${Else}
!insertmacro printExitCode $0 "Failed to initialize database password.$\r$\nPlease check the windows event log for more details$\r$\n"
Abort
${EndIf}
error:
MessageBox MB_OK "Failed to initialize database password.$\r$\nPlease check the windows event log for details."
Expand Down
146 changes: 146 additions & 0 deletions Installation/arangodb-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#!/bin/sh

# os detection
ar_detect_os(){
local file="/etc/centos-release"
local os="unknown release"
if [ -f "$file" ]; then
os="centos"
if grep -q -s " 6" "$file" &>/dev/null ; then
os+="6"
elif grep -q -s " 7" "$file" &>/dev/null ; then
os+="7"
fi
fi
echo "$os"

#debian
#opensuse
#mac
}
#export detected os
export ARANGO_OS="$(ar_detect_os)"


#print error message
ar_err(){
local msg="$1"
local code="${2-1}"
if ! [ $code -eq 0 ]; then
echo "ERROR: $msg" 1>&2
fi
}

#print fatal error message and exit
ar_ferr(){
local code="${2-1}"
if ! [ $code -eq 0 ]; then
local msg="$1"
echo "FATAL ERROR: $msg" 1>&2
exit "$code"
fi
}

## exit codes and other data

#function for searching .dat files
ar_find_dat_file(){
local name="$1"
local found=false
for p in "/usr/share/arangodb3" "some other path"; do
local full_path="$p/$name"
if [ -f "$full_path" ]; then
found=true
echo "$full_path"
break
fi
done

if ! $found; then
echo "$could not find datafile $name"
fi
}

export ARANGO_ERROR_CODES_DAT="$(ar_find_dat_file exitcodes.dat)"

ar_exitcode_num_to_string(){
in="$1"
local file="$ARANGO_ERROR_CODES_DAT"
local found=false
if [ -f "$file" ]; then
while IFS=',' read code num _ ; do
if [ "$in" == "$num" ]; then
echo $code
found=true
break
fi
done < "$file"
else
echo "EXIT_CODE_RESOLVING_FAILED for code $in"
fi

if ! $found; then
echo "EXIT_CODE_RESOLVING_FAILED for code $in"
fi
}

ar_exitcode_num_to_message(){
local in="$1"
if [[ $in == "0" ]]; then
return
fi
local file="$ARANGO_ERROR_CODES_DAT"
local found=false
if [ -f $file ]; then
while IFS=',' read code num message long_message; do
if [ "$in" == "$num" ]; then
echo "$message"
found=true
break
fi
done < "$file"
else
echo "could not resolve exit code $in"
fi

if ! $found; then
echo "could not resolve exit code $in"
fi
}

ar_exitcode_string_to_num(){
local file="$ARANGO_ERROR_CODES_DAT"
local found=false
if [ -f $file ]; then
in="$1"
while IFS=',' read code num _ ; do
if [ "$in" == "$code" ]; then
echo $num
found=true
break
fi
done < "$file"
else
echo 2
fi

if ! $found; then
echo 2
fi
}

ar_exit_by_num(){
local code="$1"
local str="$(ar_exitcode_num_to_string $code)"
local msg="$(ar_exitcode_num_to_message $code)"
if [ $code -ne 0 ]; then
echo "FATAL ERROR: $str - $msg" 1>&2
exit "$code"
fi
}

ar_exit_by_string(){
local code=$(ar_exitcode_string_to_num "$1")
ar_exit_by_num $code
}

8 changes: 8 additions & 0 deletions Installation/arangodb-update-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

#update db
/usr/sbin/arangod --uid arangodb --gid arangodb --pid-file /var/run/arangodb3/arangod.pid --server.rest-server false --database.auto-upgrade true

rv=$?
. /usr/share/arangodb3/arangodb-helper
ar_exit_by_num $rv