-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
cmd_converge_to: hook-converge-to | ||
cmd_check_finished: hook-probability "agent already finished the task" 5 | ||
cmd_prepare: hook-take | ||
cmd_try_release: hook-probability "agent can be removed early" 25 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
Check warning Code scanning / vcs-diff-lint Missing module docstring Warning
Missing module docstring
|
||
|
||
from resalloc.helpers import load_config_file | ||
|
||
def _redis_key_to_ticket_id(key): | ||
return int(key.split(":")[1]) | ||
|
||
def _redis_key_prefixed(ticket): | ||
return f"agent:{ticket}" | ||
|
||
def _rel_path(file): | ||
return os.path.join(os.path.dirname(__file__), file) | ||
|
||
def get_config(): | ||
Check warning Code scanning / vcs-diff-lint get_config: Missing function or method docstring Warning
get_config: Missing function or method docstring
|
||
config_file = _rel_path("config.yaml") | ||
return load_config_file(config_file) | ||
|
||
class CmdCallerMixin: | ||
Check warning Code scanning / vcs-diff-lint CmdCallerMixin: Missing class docstring Warning
CmdCallerMixin: Missing class docstring
|
||
# def hook_file(self, config_name): | ||
# return _rel_path(self.opts[config_name]) | ||
|
||
def command(self, config_name): | ||
Check warning Code scanning / vcs-diff-lint CmdCallerMixin.command: Missing function or method docstring Warning
CmdCallerMixin.command: Missing function or method docstring
|
||
return self.opts[config_name] | ||
|
||
def subproces_kwargs(self, data): | ||
Check warning Code scanning / vcs-diff-lint CmdCallerMixin.subproces_kwargs: Missing function or method docstring Warning
CmdCallerMixin.subproces_kwargs: Missing function or method docstring
|
||
return { | ||
"env": { | ||
"AGENT_SPAWNER_RESOURCE_DATA": str(data), | ||
"PATH": os.environ["PATH"] + ":" + _rel_path("."), | ||
}, | ||
"shell": True, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#! /bin/bash | ||
|
||
id=$(echo "$AGENT_SPAWNER_RESOURCE_DATA" | grep RESALLOC_ID=) | ||
echo -n "Checking if '$1' ($id) (probability of success $2%) => " | ||
|
||
if test 1 -eq $(( RANDOM % 100 < $2 )); then | ||
echo "Success!" | ||
exit 0 | ||
fi | ||
echo No. | ||
exit 1 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
#! /bin/bash | ||
|
||
eval 'set -- $1' # strip | ||
echo "Releasing with resalloc ticket data: $1" | ||
echo -n "Checking if agent (resource) $1 can be removed: " | ||
|
||
# ~33% chance of closing this one | ||
test $(( RANDOM % 3 )) -eq 0 && exit 0 | ||
test $(( RANDOM % 3 )) -eq 0 && { | ||
echo "YES!" | ||
exit 0 | ||
} | ||
|
||
echo "no, not removing." | ||
exit 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#! /bin/sh | ||
#! /bin/sh -x | ||
|
||
cd .. | ||
rm /tmp/server-sql | ||
cd "$(dirname "$(readlink -f "$0")")/.." || exit 1 | ||
redis-cli flushall || exit 1 | ||
rm -f /tmp/server-sql | ||
mkdir -p /tmp/logdir | ||
./test-tooling/resalloc-server |