-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'st2ctl register' fails to register rules on a fresh DB #445
Comments
Regression from the https://github.com/StackStorm/st2-packages/pull/435/files#diff-0cc9e53cba1b060958ebffa16eb85cb5L332 Revert when #445 is investigated and fixed
Regression from the https://github.com/StackStorm/st2-packages/pull/435/files#diff-0cc9e53cba1b060958ebffa16eb85cb5L332 Revert when StackStorm#445 is investigated and fixed (cherry picked from commit 7170e38)
After further debugging, here is the script to easily reproduce an error on #!/bin/bash
set -o xtrace
# disable mongo auth to run dropDatabase() from cli
if grep -q 'authorization: enabled' /etc/mongod.conf; then
sudo sed -i 's/authorization: enabled/authorization: disabled/' /etc/mongod.conf
sudo service mongod restart
fi
# emulate fresh & clean start
sudo st2ctl stop
mongo st2 --eval 'db.dropDatabase();'
sudo st2ctl start
# Failed to register rules: Failed to register rule "/opt/stackstorm/packs/chatops/rules/notify_hubot.yaml"
st2ctl reload --register-all Seems at early point st2 is busy bootstrapping DB schema in mongo (?) and for some reason can't register a rule (some db resource is not yet available ?) when saving it for the first time. So from the packaging point of view, I can't do anything here. @Kami @lakshmi-kannan @m4dcoder Can you help with debugging this case in StackStorm itself? |
I have the same issue with newly installed vagrant ubuntu 16.06. |
I looked into this a bit tonight, and haven't figured out why this is happening, but it does seem to be a delay in what's being written to MongoDB, and the availability of that resource to be read, since I have been able to fix this by simply inserting a 5 second sleep before the query. Still looking. |
Yeah, it seems related to MongoDB configuration and read after write (or perhaps mongoengine, but less likely). One option might be to experiment with write concern for trigger writes on rule register (https://docs.mongodb.com/manual/reference/write-concern/#standalone). In the worst case, we might need to add some sleep in the code for now as a work-around. |
So as we figured out, the re-appeared regression mentioned in previous 2 messages was caused by the updated But as said before, ideally is to find the root cause/investigate the proper fix for this issue and remove st2-packages/scripts/st2bootstrap-deb.sh Lines 331 to 336 in ffe4f7b
curl|bash installer or CI we just swipe the dirt under the rug.
The bug still remains the bug while users installing st2 manually via packages or via configuration management tools. |
+1 Happens for me too. My environment is a Ubuntu 16.04 virtual machine, upgraded from 14.04 recently. 2 GB RAM, 1 virtual CPU, ~ 10 GB disk available. The result is a system left in an inconsistent state. If I try and re-do the install I get:
If I am able to somehow get back to a "clean" state to continue the installation, where should a pause in the install routine be placed? |
I dug in a little and it looks like the issue is most likely related to register content running before st2api or other services fully start. On st2api and some other services startup internal trigger types are registered so if this internal registration doesn't happen before register content is ran, the script will fail with that error. Having said that, at the moment I still can't tie this issue to the mongoengine change yet. This behavior was always like that, but it's possible there is something else going on, still. On a related note, afaik, if st2ctl start would correctly wait on st2api and other services to start before returning / existing this shouldn't happen. |
@Kami I could further isolate it. #!/bin/bash
set -o xtrace
# disable mongo auth to run dropDatabase() from cli
if grep -q 'authorization: enabled' /etc/mongod.conf; then
sudo sed -i 's/authorization: enabled/authorization: disabled/' /etc/mongod.conf
sudo service mongod restart
fi
# emulate fresh & clean start
sudo st2ctl stop
mongo st2 --eval 'db.dropDatabase();'
# Failed to register rules: Failed to register rule "/opt/stackstorm/packs/chatops/rules/notify_hubot.yaml"
st2ctl reload --register-all So we don't even start st2, just emulate register-content script on a fresh DB. |
This race is fixed in st2 core via StackStorm/st2#3542 a long time ago. |
Previous PR #429 removed all
sleep
occurencies from the installer and fixed some deep issues with the st2 services startup, handling betterst2api
,st2auth
,st2stream
to report correct status only when respective service is listening on the network port.But not all bugs were caught. Under Ubuntu Xenial after initial
st2
install runningfails to register the rules.
Reproduce
Run xenial installer (with removed
sleep
):curl -sSL https://raw.githubusercontent.com/StackStorm/st2-packages/27ec5a09d87c3bc2bcfd0e01adf3ff4daa294551/scripts/st2bootstrap-deb.sh | bash -s -- --user=st2admin --password=st2admin --unstable --staging
Happens only during the first boot.
Error
This time the problem could be related to st2 core itself. Needs more investigation and proper fix.
The text was updated successfully, but these errors were encountered: