chronos
chronos copied to clipboard
Starting task right after creating it sometimes causes an error
There is a concurrency bug in Chronos. Running script like this sometimes results in error:
#!/usr/bin/env bash
cd "$(dirname "$0")"
set -euf pipefail
for number in {1..30}
do
echo "Creating job ${number}"
curl -H "Content-Type: application/json" -X POST -d \
"{ \"name\": \"abc${number}\", \"epsilon\":\"PT15M\",\"async\":false,\"scheduleTimeZone\":\"UTC\",\"command\":\"node index.js\",\"container\":{\"type\":\"DOCKER\",\"network\":\"USER\",\"networkName\":\"compose_default\",\"image\":\"some\"}}" http://localhost:4400/v1/scheduler/iso8601
echo "Starting job ${number}"
curl -H "Content-Type: application/json" -X PUT http://localhost:4400/v1/scheduler/job/abc${number}
done
Adding sleep 0.1 beetween creation of job and running it solves the problem.
I am running dockerized chronos 3.0.2 on mac os x.