After some testing for the final project’s presentation, it was discovered that even the workaround reproduces the error if it is executed very quickly (i.e., if it is executed as a single command separated by semicolons). Adding a sleep command for 2-5 seconds seems to fix this new error in the workaround.
Therefore, it seems this issue might be caused by race conditions. Perhaps the Ansible task tries to update Grafana's configuration while its container is not in an ideal state. Adding a sleep task in between the role, to give enough time for the container to prepare, might prove to fix this issue.
The single-line workaround with the sleep command is the following one:
cd grafana/; docker compose down -v; sudo rm -f initialConfig/grafana.db; docker compose up -d; sleep 5; sudo bash /home/vagrant/utils/grafanaUtils/restoreConfig.sh /home/vagrant/grafana/initialConfig/ <grafana_config_pwd>
Development task
[ ] Add the new task to wait for the container to be fully raised
Issue description
Originally posted by @martin059 in https://github.com/martin059/virtualization-level-2-vagrant-setup/issues/54#issuecomment-2199731764
After some testing for the final project’s presentation, it was discovered that even the workaround reproduces the error if it is executed very quickly (i.e., if it is executed as a single command separated by semicolons). Adding a
sleep
command for 2-5 seconds seems to fix this new error in the workaround.Therefore, it seems this issue might be caused by race conditions. Perhaps the Ansible task tries to update Grafana's configuration while its container is not in an ideal state. Adding a
sleep
task in between the role, to give enough time for the container to prepare, might prove to fix this issue.The single-line workaround with the
sleep
command is the following one:cd grafana/; docker compose down -v; sudo rm -f initialConfig/grafana.db; docker compose up -d; sleep 5; sudo bash /home/vagrant/utils/grafanaUtils/restoreConfig.sh /home/vagrant/grafana/initialConfig/ <grafana_config_pwd>
Development task