Skip to content
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

id is a required argument for st2-track-result command #4115

Merged
merged 7 commits into from
May 10, 2018

Conversation

Kami
Copy link
Member

@Kami Kami commented May 7, 2018

We didn't declare id argument as required so script exited with a confusing error if id wasn't provided.

Before:

$ st2-track-result
2018-05-07 14:38:58,249 INFO [-] Connecting to database "st2" @ "127.0.0.1:27017" as user "None".
2018-05-07 14:38:58,336 INFO [-] Retrieving action execution record...
Traceback (most recent call last):
  File "/usr/bin/st2-track-result", line 113, in <module>
    add_result_tracker(cfg.CONF.id)
  File "/usr/bin/st2-track-result", line 48, in add_result_tracker
    exec_db = ActionExecution.get_by_id(exec_id)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/persistence/base.py", line 87, in get_by_id
    return cls._get_impl().get_by_id(value)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/models/db/__init__.py", line 295, in get_by_id
    return self.get(id=value, raise_exception=True)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/models/db/__init__.py", line 325, in get
    instance = instances[0] if instances else None
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 215, in __nonzero__
    return self._has_data()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 211, in _has_data
    return False if queryset.first() is None else True
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 300, in first
    result = queryset[0]
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 198, in __getitem__
    queryset._cursor[key],
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1547, in _cursor
    self._cursor_obj = self._collection.find(self._query,
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1590, in _query
    self._mongo_query = self._query_obj.to_query(self._document)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/visitor.py", line 89, in to_query
    query = query.accept(QueryCompilerVisitor(document))
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/visitor.py", line 155, in accept
    return visitor.visit_query(self)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/visitor.py", line 78, in visit_query
    return transform.query(self.document, **query.query)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/queryset/transform.py", line 98, in query
    value = field.prepare_query_value(op, value)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/base/fields.py", line 465, in prepare_query_value
    return self.to_mongo(value)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/base/fields.py", line 461, in to_mongo
    self.error(six.text_type(e))
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/mongoengine/base/fields.py", line 159, in error
    raise ValidationError(message, errors=errors, field_name=field_name)
mongoengine.errors.ValidationError: u'None' is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string

After:

$ st2-track-result
Traceback (most recent call last):
  File "st2common/bin/st2-track-result", line 111, in <module>
    setup()
  File "st2common/bin/st2-track-result", line 44, in setup
    script_setup.setup(config, register_mq_exchanges=False)
  File "/data/stanley/st2common/st2common/script_setup.py", line 73, in setup
    config.parse_args()
  File "/data/stanley/st2common/st2common/config.py", line 398, in parse_args
    default_config_files=[DEFAULT_CONFIG_FILE_PATH])
  File "/data/stanley/virtualenv/local/lib/python2.7/site-packages/oslo_config/cfg.py", line 1884, in __call__
    self._check_required_opts()
  File "/data/stanley/virtualenv/local/lib/python2.7/site-packages/oslo_config/cfg.py", line 2433, in _check_required_opts
    raise RequiredOptError(opt.name, group)
oslo_config.cfg.RequiredOptError: value required for option: id

@Kami Kami added this to the 2.8.0 milestone May 7, 2018
@Kami Kami modified the milestones: 2.8.0, 2.7.2 May 8, 2018
@Kami Kami merged commit 6c10c2c into master May 10, 2018
@Kami Kami deleted the fix_track_result_id_is_required branch May 10, 2018 17:25
@Kami Kami mentioned this pull request May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants