Cannot use Email Imap plugin on Kubernetes

Hi there, I’m using email plugin on Kubernetes using stackstorm-ha HELM Chart.
I’m using 3.2.0 version and tried to build it with st2packs-dockerfiles, also using FROM stackstorm/st2:3.2.0. I also tried the last 3.3dev version.

However IMAP doesn’t work and I see this error on my st2sensorcontainer logs:

2020-08-05 09:58:53,705 ERROR [-] File “/opt/stackstorm/packs/email/sensors/imap_sensor.py”, line 133, in _process_message
2020-08-05 09:58:53,705 ERROR [-]
2020-08-05 09:58:53,705 ERROR [-] message = mailbox.mail(uid, include_raw=True)
2020-08-05 09:58:53,705 ERROR [-]
2020-08-05 09:58:53,705 ERROR [-] File “/opt/stackstorm/virtualenvs/email/lib/python3.6/site-packages/easyimap/easyimap.py”, line 198, in mail
2020-08-05 09:58:53,706 ERROR [-]
2020-08-05 09:58:53,706 ERROR [-] typ, content = self._mailer.uid(‘fetch’, uid, self._fetch_message_parts)
2020-08-05 09:58:53,706 ERROR [-]
2020-08-05 09:58:53,706 ERROR [-] File “/usr/lib/python3.6/imaplib.py”, line 879, in uid
2020-08-05 09:58:53,706 ERROR [-]
2020-08-05 09:58:53,706 ERROR [-] typ, dat = self._simple_command(name, command, *args)
2020-08-05 09:58:53,707 ERROR [-]
2020-08-05 09:58:53,707 ERROR [-] File “/usr/lib/python3.6/imaplib.py”, line 1196, in _simple_command
2020-08-05 09:58:53,707 ERROR [-]
2020-08-05 09:58:53,707 ERROR [-] return self._command_complete(name, self._command(name, *args))
2020-08-05 09:58:53,707 ERROR [-]
2020-08-05 09:58:53,708 ERROR [-] File “/usr/lib/python3.6/imaplib.py”, line 961, in _command
2020-08-05 09:58:53,708 ERROR [-]
2020-08-05 09:58:53,708 ERROR [-] data = data + b’ ’ + arg
2020-08-05 09:58:53,708 ERROR [-]
2020-08-05 09:58:53,708 ERROR [-] TypeError
2020-08-05 09:58:53,708 ERROR [-] :
2020-08-05 09:58:53,708 ERROR [-] can’t concat int to bytes
2020-08-05 09:58:53,709 ERROR [-]
2020-08-05 09:58:53,709 ERROR [-]
During handling of the above exception, another exception occurred:
2020-08-05 09:58:53,709 ERROR [-] Traceback (most recent call last):
2020-08-05 09:58:53,709 ERROR [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 361, in
2020-08-05 09:58:53,709 ERROR [-]
2020-08-05 09:58:53,709 ERROR [-] obj.run()
2020-08-05 09:58:53,709 ERROR [-]
2020-08-05 09:58:53,710 ERROR [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 235, in run
2020-08-05 09:58:53,710 ERROR [-]
2020-08-05 09:58:53,710 ERROR [-] raise Exception(msg)
2020-08-05 09:58:53,710 ERROR [-]
2020-08-05 09:58:53,710 ERROR [-] Exception
2020-08-05 09:58:53,710 ERROR [-] :
2020-08-05 09:58:53,710 ERROR [-] Sensor “IMAPSensor” run method raised an exception: can’t concat int to bytes.
2020-08-05 09:58:53,710 ERROR [-]
2020-08-05 09:58:53,711 INFO [-] Stopping trigger watcher
2020-08-05 09:58:53,711 INFO [-] Invoking cleanup on sensor
2020-08-05 09:58:54,483 INFO [-] Process for sensor email.IMAPSensor has exited with code 1
2020-08-05 09:58:59,123 WARNING [-] Symbol ‘mailbox_or_url_list’ is unreachable

Any hint what could be wrong?

Regards

What have you tried for troubleshooting?

Hi,

I have tested with 3.2.0 and 3.3dev, doesn’t work on both.

I also discovered that it works on a vm centos and the code seems to be exactly the same, except that the vm uses python2 and the container is based on Ubuntu18 uses python3.

Thanks

A Dom, 9 de ago de 2020, 05:07, punkrokk via StackStorm Support <stackstorm@discoursemail.com> escreveu:

It’s sounds like maybe a PR is needed again that pack to support python3? Does it work on Ubuntu 18 with the one line installer?

Hi,

sorry for the late answer, I was on hollidays.

It doesn’t work on ubuntu18 running in a vm also:

20-08-24 10:09:59,075 140457947180528 ERROR (unknown file) [-] Traceback (most recent call last):

2020-08-24 10:09:59,075 140457947180528 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 361, in

2020-08-24 10:09:59,075 140457947180528 ERROR (unknown file) [-]
2020-08-24 10:09:59,075 140457947180528 ERROR (unknown file) [-] obj.run()
2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 218, in run

2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-]
2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-] self._sensor_instance.setup()
2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 37, in setup

2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-]
2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-] trigger=self._trigger)
2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,076 140457947180528 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 58, in init

2020-08-24 10:09:59,077 140457947180528 ERROR (unknown file) [-]
2020-08-24 10:09:59,077 140457947180528 ERROR (unknown file) [-] smtpd.SMTPServer.init(self, localaddr, remoteaddr) # pylint: disable=no-member
2020-08-24 10:09:59,077 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,077 140457947180528 ERROR (unknown file) [-] File “/usr/lib/python3.6/smtpd.py”, line 646, in init

2020-08-24 10:09:59,077 140457947180528 ERROR (unknown file) [-]
2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-] type=socket.SOCK_STREAM)
2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-] TypeError
2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-] :
2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-] getaddrinfo() got an unexpected keyword argument ‘type’
2020-08-24 10:09:59,078 140457947180528 ERROR (unknown file) [-]

2020-08-24 10:09:59,078 140457947180528 INFO (unknown file) [-] Stopping trigger watcher
2020-08-24 10:09:59,079 140457947180528 INFO (unknown file) [-] Invoking cleanup on sensor
2020-08-24 10:10:01,434 140173923993752 INFO (unknown file) [-] Process for sensor email.SMTPSensor has exited with code 1
2020-08-24 10:10:03,945 140173923994816 WARNING (unknown file) [-] “auth.api_url” configuration option is not configured
2020-08-24 10:10:04,930 140222680661488 INFO (unknown file) [-] Found config for sensor “SMTPSensor”
2020-08-24 10:10:04,930 140222680661488 INFO (unknown file) [-] Watcher started
2020-08-24 10:10:04,930 140222680661488 INFO (unknown file) [-] Running sensor initialization code
2020-08-24 10:10:04,930 140222680661488 ERROR (unknown file) [-] Traceback (most recent call last):

2020-08-24 10:10:04,930 140222680661488 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 361, in

2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-]
2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-] obj.run()
2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 218, in run

2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-]
2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-] self._sensor_instance.setup()
2020-08-24 10:10:04,931 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 37, in setup

2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-]
2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-] trigger=self._trigger)
2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 58, in init

2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-]
2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-] smtpd.SMTPServer.init(self, localaddr, remoteaddr) # pylint: disable=no-member
2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,932 140222680661488 ERROR (unknown file) [-] File “/usr/lib/python3.6/smtpd.py”, line 646, in init

2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-]
2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-] type=socket.SOCK_STREAM)
2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-] TypeError
2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-] :
2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-] getaddrinfo() got an unexpected keyword argument ‘type’
2020-08-24 10:10:04,933 140222680661488 ERROR (unknown file) [-]

2020-08-24 10:10:04,933 140222680661488 INFO (unknown file) [-] Stopping trigger watcher
2020-08-24 10:10:04,934 140222680661488 INFO (unknown file) [-] Invoking cleanup on sensor
2020-08-24 10:10:06,438 140173923993752 INFO (unknown file) [-] Process for sensor email.SMTPSensor has exited with code 1
2020-08-24 10:10:11,448 140173923994664 WARNING (unknown file) [-] “auth.api_url” configuration option is not configured
2020-08-24 10:10:12,465 139974111616496 INFO (unknown file) [-] Found config for sensor “SMTPSensor”
2020-08-24 10:10:12,466 139974111616496 INFO (unknown file) [-] Watcher started
2020-08-24 10:10:12,466 139974111616496 INFO (unknown file) [-] Running sensor initialization code
2020-08-24 10:10:12,466 139974111616496 ERROR (unknown file) [-] Traceback (most recent call last):

2020-08-24 10:10:12,467 139974111616496 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 361, in

2020-08-24 10:10:12,467 139974111616496 ERROR (unknown file) [-]
2020-08-24 10:10:12,467 139974111616496 ERROR (unknown file) [-] obj.run()
2020-08-24 10:10:12,467 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,468 139974111616496 ERROR (unknown file) [-] File “/opt/stackstorm/st2/lib/python3.6/site-packages/st2reactor/container/sensor_wrapper.py”, line 218, in run

2020-08-24 10:10:12,468 139974111616496 ERROR (unknown file) [-]
2020-08-24 10:10:12,468 139974111616496 ERROR (unknown file) [-] self._sensor_instance.setup()
2020-08-24 10:10:12,468 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,469 139974111616496 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 37, in setup

2020-08-24 10:10:12,469 139974111616496 ERROR (unknown file) [-]
2020-08-24 10:10:12,469 139974111616496 ERROR (unknown file) [-] trigger=self._trigger)
2020-08-24 10:10:12,469 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,469 139974111616496 ERROR (unknown file) [-] File “/opt/stackstorm/packs/email/sensors/smtp_sensor.py”, line 58, in init

2020-08-24 10:10:12,470 139974111616496 ERROR (unknown file) [-]
2020-08-24 10:10:12,470 139974111616496 ERROR (unknown file) [-] smtpd.SMTPServer.init(self, localaddr, remoteaddr) # pylint: disable=no-member
2020-08-24 10:10:12,470 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,470 139974111616496 ERROR (unknown file) [-] File “/usr/lib/python3.6/smtpd.py”, line 646, in init

2020-08-24 10:10:12,471 139974111616496 ERROR (unknown file) [-]
2020-08-24 10:10:12,471 139974111616496 ERROR (unknown file) [-] type=socket.SOCK_STREAM)
2020-08-24 10:10:12,471 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,471 139974111616496 ERROR (unknown file) [-] TypeError
2020-08-24 10:10:12,471 139974111616496 ERROR (unknown file) [-] :
2020-08-24 10:10:12,472 139974111616496 ERROR (unknown file) [-] getaddrinfo() got an unexpected keyword argument ‘type’
2020-08-24 10:10:12,472 139974111616496 ERROR (unknown file) [-]

2020-08-24 10:10:12,472 139974111616496 INFO (unknown file) [-] Stopping trigger watcher
2020-08-24 10:10:12,473 139974111616496 INFO (unknown file) [-] Invoking cleanup on sensor
2020-08-24 10:10:16,444 140173923993752 INFO (unknown file) [-] Process for sensor email.SMTPSensor has exited with code 1

@pgsousa Please report a bug in email pack: GitHub - StackStorm-Exchange/stackstorm-email: E-Mail Actions/Sensors for StackStorm

Would be also nice if you give it a try in Ubuntu 16.04 VM, which uses python 2. That might unblock you and give us an idea if it’s py2 vs py3 compatibility issue in pack or not.

Hi,

I confirm that the plugin works on Ubuntu 16.04 with python2.

ubuntu@ubuntu1604:/var/log/st2$ st2 --version
st2 3.2.0, on Python 2.7.12

1 Like

Thanks for reporting a bug report in email pack: IMAPSensor doesn't work on python3 · Issue #36 · StackStorm-Exchange/stackstorm-email · GitHub

Hi,

is it possible to use a docker image with ubuntu 16 with python2 to run on kubernetes?

Thanks

We had python 2 Ubuntu 16.04 LTS images before but migrated to py3 with Ubuntu 18.04 LTS as we’re transitioning away from python 2: Python 2 Deprecation · Issue #40 · StackStorm/discussions · GitHub

Hi Eugen,

thank you for your reply. I tried to use 3.2.0 image with 16.04 version, however I see the error below. Is there a way to build the plugin without python3?

2020-08-24 16:29:55,878 ERROR [-] Handling failed. Message body: SensorTypeDB(artifact_uri=“file:///opt/stackstorm/packs/email/sensors/smtp_sensor.py”, description=“Sensor that emits triggers when e-mail message is received via SMTP”, enabled=True, entry_point=“sensors.smtp_sensor.SMTPSensor”, id=5f2bbf7d52277c70df67ee08, metadata_file=“sensors/smtp_sensor.yaml”, name=“SMTPSensor”, pack=“email”, poll_interval=None, ref=“email.SMTPSensor”, trigger_types=[u’email.smtp.message’], uid=“sensor_type:email:SMTPSensor”). Exception:
Virtual environment (/opt/stackstorm/virtualenvs/email) for pack “email” is using Python 3.
Using Python 3 virtual environments in mixed deployments is only supported for Python runner
actions and not sensors. If you want to run this sensor, please re-recreate the
virtual environment with python2 binary:
“st2 run packs.setup_virtualenv packs=email python3=false”
Traceback (most recent call last):
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/services/sensor_watcher.py”, line 83, in process_task
handler(body)
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/container/manager.py”, line 159, in _handle_update_sensor
self._sensor_container.add_sensor(sensor=sensor_obj)
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/container/process_container.py”, line 242, in add_sensor
self._spawn_sensor_process(sensor=sensor)
File “/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/container/process_container.py”, line 305, in _spawn_sensor_process
raise Exception(msg)
Exception:
Virtual environment (/opt/stackstorm/virtualenvs/email) for pack “email” is using Python 3.
Using Python 3 virtual environments in mixed deployments is only supported for Python runner
actions and not sensors. If you want to run this sensor, please re-recreate the
virtual environment with python2 binary:
"st2 run packs.setup_virtualenv packs=email python3=false"