StackStorm / StackStorm/st2-packages

'st2ctl reload' bundled in packaging fails on first st2 install

Open
#453 31 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Shell
Stars
28
Forks
63
PR merge metrics
No merged PRs in 30d

Description

In curl | bash script we configure mongo with specific username/password and permissions.

During the apt/yum install we automatically trigger st2ctl reload --register-runners --register-fail-on-failure via packaging postinst.

That fails, because when installing StackStorm for the first time, st2.conf is shipped with default values and so mongo user doesn't have needed permissions:

  Installing : st2-2.2.1-3.x86_64                                                                                                                                                 15/15 
Registering content...[flags = --register-runners --register-fail-on-failure]
2017-03-23 17:28:52,705 INFO [-] Connecting to database "st2" @ "0.0.0.0:27017" as user "None".
Traceback (most recent call last):
  File "/usr/bin/st2-register-content", line 22, in <module>
    sys.exit(content_loader.main(sys.argv[1:]))
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/content/bootstrap.py", line 384, in main
    setup(argv)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/content/bootstrap.py", line 376, in setup
    common_setup(config=config, setup_db=True, register_mq_exchanges=True)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/script_setup.py", line 86, in setup
    db_setup()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/database_setup.py", line 43, in db_setup
    ssl_match_hostname=cfg.CONF.database.ssl_match_hostname)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/persistence/db_init.py", line 65, in db_setup_with_retry
    ssl_match_hostname=ssl_match_hostname)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/retrying.py", line 206, in call
    return attempt.get(self._wrap_exception)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/models/db/__init__.py", line 94, in db_setup
    db_ensure_indexes()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/models/db/__init__.py", line 131, in db_ensure_indexes
    raise e
pymongo.errors.OperationFailure: not authorized on st2 to execute command { createIndexes: "user_d_b", indexes: [ { unique: true, background: false, sparse: false, key: { name: 1 }, name: "name_1" } ] }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with scripts/st2bootstrap-deb.sh at the Mongo configuration lines 228-250 and packages/st2/rpm/postinst_script.spec, then reproduce the first apt/yum installation and its st2ctl reload. Trace how the shipped st2.conf reaches the registration command and verify that a first install completes registration without the MongoDB authorization failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, shell
Domain
build-system, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.