Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
francois
slapos
Commits
95748c74
Commit
95748c74
authored
Dec 17, 2014
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Webunner: Make import script report in a file if import / afterimport was ok
+ make promise checking this
parent
e9da64e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
software/slaprunner/instance-runner-import.cfg.in
software/slaprunner/instance-runner-import.cfg.in
+19
-0
software/slaprunner/template/runner-import.sh.jinja2
software/slaprunner/template/runner-import.sh.jinja2
+16
-9
No files found.
software/slaprunner/instance-runner-import.cfg.in
View file @
95748c74
...
@@ -26,6 +26,7 @@ parts +=
...
@@ -26,6 +26,7 @@ parts +=
instance-software-type
instance-software-type
bash-profile
bash-profile
supervisord-wrapper
supervisord-wrapper
importer-consistency-promise
# have to repeat the next one, as it's not inherited from pbsready-import
# have to repeat the next one, as it's not inherited from pbsready-import
import-on-notification
import-on-notification
## Monitoring part
## Monitoring part
...
@@ -59,12 +60,30 @@ rendered = $${directory:bin}/$${slap-parameter:namebase}-importer
...
@@ -59,12 +60,30 @@ rendered = $${directory:bin}/$${slap-parameter:namebase}-importer
# backward compatibility for resilient stack
# backward compatibility for resilient stack
wrapper = $${:rendered}
wrapper = $${:rendered}
mode = 700
mode = 700
restore-exit-code-file=$${directory:srv}/importer-exit-code-file
context =
context =
key backend_url slaprunner:access-url
key backend_url slaprunner:access-url
section directory directory
section directory directory
raw shell_binary ${dash:location}/bin/dash
raw shell_binary ${dash:location}/bin/dash
raw rsync_binary ${rsync:location}/bin/rsync
raw rsync_binary ${rsync:location}/bin/rsync
raw curl_binary ${curl:location}/bin/curl
raw curl_binary ${curl:location}/bin/curl
raw restore_exit_code_file $${:restore-exit-code-file}
[importer-consistency-promise]
# Test that the importer script and "after-import" subscripts:
# 1/ Have been run in the last 24 hours
# 2/ Have succeeded
recipe = collective.recipe.template
input = inline: #!/bin/sh
EXIT_CODE_FILE=$(find "$${importer:restore-exit-code-file}" -mtime -1)
if [ -z "$EXIT_CODE_FILE" ]; then
echo "Consistency check is too old."
exit 1
fi
EXIT_CODE=$(cat $EXIT_CODE_FILE)
exit $EXIT_CODE
output = $${directory:promises}/importer-consistency-promise
mode = 755
[slap-parameter]
[slap-parameter]
auto-deploy-instance = false
auto-deploy-instance = false
...
...
software/slaprunner/template/runner-import.sh.jinja2
View file @
95748c74
...
@@ -35,22 +35,23 @@ cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }};
...
@@ -35,22 +35,23 @@ cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }};
# Invoke arbitrary script to perform specific restoration
# Invoke arbitrary script to perform specific restoration
# procedure.
# procedure.
RESTORE_EXIT_CODE=0
runner_import_restore=$srv_directory/runner-import-restore
runner_import_restore=$srv_directory/runner-import-restore
if [ ! -e "$runner_import_restore" ]; then
if [ ! -e "$runner_import_restore" ]; then
touch $runner_import_restore
touch $runner_import_restore
chmod +x $runner_import_restore
chmod +x $runner_import_restore
fi
fi
echo "Running $runner_import_restore script..."
echo "Running $runner_import_restore script..."
# XXX create exit code file if this failed (same below), and remove this in tidstorage/mariadb
$srv_directory/runner-import-restore || RESTORE_EXIT_CODE=$?
$srv_directory/runner-import-restore || true
HOME={{ directory['home'] }}
echo "Updating slapproxy database, software release and instances..."
HOME="{{ directory['home'] }}"
SLAPOS="{{ directory['bin'] }}/slapos"
# XXX hardcoded
# XXX hardcoded
SQLITE3="$HOME/software_release/parts/sqlite3/bin/sqlite3"
SQLITE3="$HOME/software_release/parts/sqlite3/bin/sqlite3"
DATABASE="$HOME/srv/runner/proxy.db"
DATABASE="$HOME/srv/runner/proxy.db"
# Change slapproxy database to point instances to new software release
# Change slapproxy database to point instances to new software release
# XXX ha
ckish and ha
rdcoded
# XXX hardcoded
PARTITION=$(basename $HOME)
PARTITION=$(basename $HOME)
OLD_SOFTWARE_RELEASE=$($SQLITE3 $DATABASE "select software_release from partition11 where reference='slappart0';")
OLD_SOFTWARE_RELEASE=$($SQLITE3 $DATABASE "select software_release from partition11 where reference='slappart0';")
SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's/slappart[0-9][0-9]/'"$PARTITION"'/')
SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's/slappart[0-9][0-9]/'"$PARTITION"'/')
...
@@ -58,21 +59,27 @@ $SQLITE3 $DATABASE "update partition11 set software_release='$SOFTWARE_RELEASE'
...
@@ -58,21 +59,27 @@ $SQLITE3 $DATABASE "update partition11 set software_release='$SOFTWARE_RELEASE'
# Change slapproxy database to have all instances stopped
# Change slapproxy database to have all instances stopped
$SQLITE3 $DATABASE "update partition11 set slap_state='stopped';"
$SQLITE3 $DATABASE "update partition11 set slap_state='stopped';"
# Build newest software
# Build newest software
{{ directory['bin'] }}/slapos node software --cfg ~/etc/slapos.cfg --pidfile ~/var/run/slaponode-instance.pid --all
|| true
$SLAPOS node software --cfg ~/etc/slapos.cfg --pidfile ~/var/run/slapos-node-software.pid --all >/dev/null 2>&1
|| true
# Remove defined scripts to force buildout to recreate them to have updated paths
# Remove defined scripts to force buildout to recreate them to have updated paths
# XXX hack
rm $srv_directory/runner/instance/slappart*/srv/runner-import-restore
rm $srv_directory/runner/instance/slappart*/srv/runner-import-restore
# Run slapos node instance
# Run slapos node instance
# XXX hardcoded
# XXX hardcoded
{{ directory['bin'] }}/slapos node instance --cfg ~/etc/slapos.cfg --pidfile ~/var/run/slaponode-instance.pid || true
$SLAPOS node instance --cfg ~/etc/slapos.cfg --pidfile ~/var/run/slapos-node-instance.pid >/dev/null 2>&1 || true
# Invoke defined scripts for each partition inside of slaprunner
# Invoke defined scripts for each partition inside of slaprunner
for partition in $srv_directory/runner/instance/slappart*/
for partition in $srv_directory/runner/instance/slappart*/
do
do
script=$partition/srv/runner-import-restore
script=$partition/srv/runner-import-restore
if [ -e "$script" ]; then
if [ -e "$script" ]; then
echo "Running $script script..."
echo "Running $script script..."
$script ||
true
$script ||
RESTORE_EXIT_CODE=$?
fi
fi
done
done
# Change back slapproxy database to have all instances started
# Change back slapproxy database to have all instances started
$SQLITE3 $DATABASE "update partition11 set slap_state='started';"
$SQLITE3 $DATABASE "update partition11 set slap_state='started';"
# Write exit code to an arbitrary file that will be checked by promise/monitor
RESTORE_EXIT_CODE_FILE="{{ restore_exit_code_file }}"
echo $RESTORE_EXIT_CODE > $RESTORE_EXIT_CODE_FILE
exit $RESTORE_EXIT_CODE
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment