Skip to content

st2sensor default create a token with ttl = 1 day #3314

@jiang-wei

Description

@jiang-wei

when update the ttl of the token in st2.conf to 600 seconds, the sensor container complains failed to create token with expiry of 86400 for the sensor.

[2017-03-28 16:57:38,855 58587408 ERROR sensor_watcher [-] Handling failed. Message body: SensorTypeDB(artifact_uri="file:///opt/stackstorm/packs/chatops/sensors/HubotWatchdog2.py", description="watch the log of st2chatops. send the timestamp of the last log line", enabled=True, entry_point="sensors.HubotWatchdog2.HubotWatchdog", id=58d0dadc921627282206cf04, name="HubotWatchdog", pack="chatops", poll_interval=10, trigger_types=[u'chatops.last_hubot_log_timestamp_delta'], uid="sensor_type:chatops:HubotWatchdog"). Exception: TTL specified 86400 is greater than max allowed 600.
Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/services/sensor_watcher.py", line 82, in process_task
    handler(body)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2reactor/container/manager.py", line 141, in _handle_update_sensor
    self._sensor_container.add_sensor(sensor=sensor_obj)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2reactor/container/process_container.py", line 215, in add_sensor
    self._spawn_sensor_process(sensor=sensor)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2reactor/container/process_container.py", line 294, in _spawn_sensor_process
    temporary_token = create_token(username='sensors_container', ttl=ttl)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/services/access.py", line 58, in create_token
    raise TTLTooLargeException(msg)](url)

I check the code and found at /opt/stackstorm/st2/lib/python2.7/site-packages/st2reactor/container/process_container.py + 449

        # Include full api URL and API token specific to that sensor
        ttl = (24 * 60 * 60)
        temporary_token = create_token(username='sensors_container', ttl=ttl)

create_token is about to create a token with ttl=86400 but failed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions