StackStorm / StackStorm/st2

Sensor raises Error when using sensor_service.list_values

Open
#5,327 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug regression
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

when the sensor tries to read from the datastore (st2KV) with self.sensor_service.list_values(prefix'something'), it raises this Error:

ERROR [-] Sensor "MySensor" run method raised an exception: no such option in group api: max_page_size.
WARNING [-] Sensor "MySensor" run method raised an exception: no such option in group api: max_page_size.
KeyError: ('api', 'max_page_size')
    limit = limit or cfg.CONF.api.max_page_size
oslo_config.cfg.NoSuchOptError: no such option in group api: max_page_size
ERROR [-] ('api', 'max_page_size')
ERROR [-] limit = limit or cfg.CONF.api.max_page_size
ERROR [-] no such option in group api: max_page_size
STACKSTORM VERSION

v3.5.0

OS, environment, install method

using docker version

Steps to reproduce the problem

  1. create a new pack with sensor class :
from st2reactor.sensor.base import PollingSensor

class MySensor(PollingSensor):
    def __init__(self, sensor_service, config=None):
        super(SyslogAlertsSenderSensor, self).__init__(
            sensor_service=sensor_service,
            config=config,
            poll_interval=60
        )
        ...

    def poll(self):
        payloads = self.sensor_service.list_values(local=False, prefix='something')
        ...
  1. install the pack
  2. enable the sensor and look at the logs of st2sencorcontainer.

Expected Results

 DEBUG [-] Sensor my_pack.MySensor started.

Actual Results

ERROR [-] Sensor "MySensor" run method raised an exception: no such option in group api: max_page_size.

Workaround

add this code to sensor file:

from oslo_config import cfg

try:
    api_group = cfg.OptGroup('api')
    cfg.CONF.register_group(api_group)
    cfg.CONF.register_opts([cfg.IntOpt('max_page_size', default=50)], group=api_group)
except cfg.DuplicateOptError:
    pass

Thanks!

Contributor guide

Open the contributing guide

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 the PollingSensor example and the sensor_service.list_values(local=False, prefix='something') call, then reproduce it by installing and enabling the pack while watching the st2sensor logs. Trace the call to cfg.CONF.api.max_page_size; done means list_values works without sensor-level option registration and the max_page_size error is gone.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.