dmwm / WMCore

Core workflow management components for CMS.
Apache License 2.0
46 stars 107 forks source link

can not send email from wmagent docker container #12159

Open mapellidario opened 3 weeks ago

mapellidario commented 3 weeks ago

Impact of the bug

All of WMAgents

Describe the bug

The script https://github.com/dmwm/WMCore/blob/master/deploy/restartComponent.sh run from a cronjob inside the wmagent docker container fails to send emails.

How to reproduce it

log into a wmagent, change to cmst1 user, then you can use the command mail to send an email with s-nail

cmst1@vocms0262:~ $ # from the host, send an email with "s-nail"
cmst1@vocms0262:~ $ mail -V
s-nail v14.9.22, 2021-02-24 (built for Linux)
cmst1@vocms0262:~ $ echo -e "test email N" | mail -s "${HOSTNAME} : test email N" dmapelli@cern.ch

then start a shell inside a wmagent docker container: the comman mail points to mailutils, but there is not

(WMAgent-2.3.5) [cmst1@vocms0262:current]$ mail -V
mail (GNU Mailutils) 3.10
Copyright (C) 2007-2019 Free Software Foundation, inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(WMAgent-2.3.5) [cmst1@vocms0262:current]$ echo -e "test email N" | mail -s "${HOSTNAME} : test email N" dmapelli@cern.ch
mail: cannot send message: Process exited with a non-zero status
(WMAgent-2.3.5) [cmst1@vocms0262:current]$ echo -e "test email N" | mail --debug-level=mailer.trace9 dmapelli@cern.ch
mail: sendmail binary: /usr/sbin/sendmail
mail: mu_mailer_send_message(): using From: cmst1
mail: exec /usr/sbin/sendmail argv: /usr/sbin/sendmail -oi -f cmst1@vocms0262.cern.ch -t
mail: Sending headers...
mail: Sending body...
mail: /usr/sbin/sendmail exited with: 1
mail: progmailer error: Process exited with a non-zero status
mail: cannot send message: Process exited with a non-zero status
(WMAgent-2.3.5) [cmst1@vocms0262:current]$ sendmail
exim: failed to find uid for user name "Debian-exim"
(WMAgent-2.3.5) [cmst1@vocms0262:current]$

Expected behavior

we should be able to send emails from inside the wmagent docker container

Additional context and error message

Possible solutions

We can properly install a mail client inside the wmagent docker container.

Alternatively, we can get rid of these emails and send the event to AMQ/opensearch and display them in a table in grafana. I would prefer this second option.

amaltaro commented 3 days ago

@khurtado I am afraid I might have missed a possible solution for this. Can you please confirm if this is still being worked on? If it's resolved, then I would suggest to provide the PR in here and close it. Thanks

khurtado commented 1 day ago

@amaltaro I have a working solution that fixes exim4. The solution in short:

I will make a PR soon.

EDIT: @amaltaro This works for me: https://github.com/dmwm/CMSKubernetes/pull/1566