Commit da3690fa authored by Rafael Monnerat's avatar Rafael Monnerat

slaprunner: Support resilience on computers with more them 100 partitions

  This block could be generalized a bit more but it will be unlikely to have computers with more them 1000 partitions.
parent 46124557
......@@ -23,7 +23,7 @@ md5sum = 8f49df215a1596efcec94e2cca009711
[template-runner-import-script]
filename = template/runner-import.sh.jinja2
md5sum = 3be3ff484a5aaa202f2ea72489a73285
md5sum = 130193114cbbcd014af9704851410605
[instance-runner-import]
filename = instance-runner-import.cfg.in
......
......@@ -136,7 +136,7 @@ DATABASE="$HOME/srv/runner/proxy.db"
# XXX hardcoded
PARTITION=$(basename $HOME)
OLD_SOFTWARE_RELEASE=$("$SQLITE3" "$DATABASE" "select software_release from partition11 where reference='slappart0';")
SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's/\(.*\)\(slappart\|test0-\)[0-9][0-9]\?/\1'"$PARTITION"'/')
SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's/\(.*\)\(slappart\|test0-\)[0-9][0-9][0-9]\?/\1'"$PARTITION"'/')
"$SQLITE3" "$DATABASE" "update partition11 set software_release='$SOFTWARE_RELEASE' where software_release NOT NULL;"
"$SQLITE3" "$DATABASE" "update software11 set url='$SOFTWARE_RELEASE' where url='$OLD_SOFTWARE_RELEASE';" || "$SQLITE3" "$DATABASE" "delete from software11 where url='$OLD_SOFTWARE_RELEASE';"
# Change slapproxy database to have all instances stopped
......
  • I think this breaks for the first 10 partitions, where you have a single digit. I'd rather write:

    SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's/\(.*\)\(slappart\|test0-\)[0-9]\+/\1'"$PARTITION"'/')

    And now, it also works for more than 1000 partitions.

    Slighly more reliable:

    SOFTWARE_RELEASE=$(echo $OLD_SOFTWARE_RELEASE | sed -e 's,\(.*/\)\(slappart\|test0-\)[0-9]\+/,\1'"$PARTITION"/,)

    By using sed -r, we could get rid of all those \ but I don't know about portability.

  • In case it does not appear clearly, the idea of my second suggestion is to make sure that slappart123 is immediately preceded and followed by a /. And when maching / chars, it's easier to use a different sed separator ... that must not appear in PARTITION.

  • mentioned in commit b8be3950

    Toggle commit list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment