Skip to content

Sensor raises Error when using sensor_service.list_values #5327

Open
@Moradf90

Description

@Moradf90

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions