Bug 1292060 - Emails sent from broker have "corrupted" headers
Emails sent from broker have "corrupted" headers
Status: CLOSED CURRENTRELEASE
Product: ovirt-hosted-engine-ha
Classification: oVirt
Component: Broker (Show other bugs)
1.3.3.3
All All
medium Severity low (vote)
: ovirt-3.6.1
: 1.3.3.4
Assigned To: Martin Sivák
Nikolai Sednev
: Triaged
Depends On: 1301681
Blocks: ovirt-hosted-engine-ha-1.3.4.3
  Show dependency treegraph
 
Reported: 2015-12-16 06:18 EST by HWSD
Modified: 2016-03-06 12:37 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-17 02:19:42 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: SLA
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: ovirt‑3.6.z+
mgoldboi: planning_ack+
msivak: devel_ack+
gklein: testing_ack+


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 50587 master MERGED Fix notification email header corruption 2015-12-17 08:32 EST
oVirt gerrit 50671 ovirt-hosted-engine-ha-1.3 MERGED Fix notification email header corruption 2015-12-17 08:47 EST

  None (edit)
Description HWSD 2015-12-16 06:18:15 EST
Description of problem:

After upgrading ovirt from 3.5 to 3.6 emails sent from broker have "corrupted" headers.

At the ent of message we can see:

-----
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Date: Mon, 09 Nov 2015 11:33:37 +0100
Message-Id: <20151109103337.D9C7D1260001@my.server.lan>
From: mysender@server.lan
To: undisclosed-recipients:;

From: mysender@server.lan
To: myreceiver@server.lan
Subject: ovirt-hosted-engine state transition
EngineUp-GlobalMaintenance

The state machine changed state.
-----

From and To are repeated twice. This cause that email client show
correctly the sender butan empty recipient and an empty subject.

On message body I see everything after "To: undisclosed-recipients:;"

Version-Release number of selected component (if applicable):

ovirt-hosted-engine-ha-1.3.3.3-1.el7.centos.noarch

How reproducible:

Always

Steps to Reproduce:

Put hosted engine in global maintenance mode to make broker send an email

Actual results:

From and To headers are repeated twice.

Expected results:

Only one From and To header with filled correctly

Additional info:

This pach from Martin Sivak <msivak@redhat.com> solve the problem:

diff --git a/ovirt_hosted_engine_ha/broker/notifications.py b/ovirt_hosted_engin
index 425822d..00e7e60 100644
--- a/ovirt_hosted_engine_ha/broker/notifications.py
+++ b/ovirt_hosted_engine_ha/broker/notifications.py
@@ -1,4 +1,4 @@
-from email.mime.text import MIMEText
+from email.parser import Parser
 from email.utils import formatdate
 import socket

@@ -24,7 +24,7 @@ def send_email(cfg, email_body):
         server = smtplib.SMTP(cfg["smtp-server"], port=cfg["smtp-port"])
         server.set_debuglevel(1)
         to_addresses = EMAIL_SPLIT_RE.split(cfg["destination-emails"].strip())
-        message = MIMEText(email_body)
+        message = Parser().parsestr(email_body)
         message["Date"] = formatdate(localtime=True)
         server.sendmail(cfg["source-email"],
                         to_addresses,
Comment 1 Gil Klein 2016-02-17 02:19:42 EST
This bug was fixed and is slated to be in the upcoming version. As we
are focusing our testing at this phase on severe bugs, this bug was
closed without going through its verification step. If you think this
bug should be verified by QE, please set its severity to high and move
it back to ON_QA
Comment 2 Nikolai Sednev 2016-03-06 12:37:09 EST
Works for me on these components:
Host:
qemu-kvm-rhev-2.3.0-31.el7_2.8.x86_64
libvirt-client-1.2.17-13.el7_2.3.x86_64
sanlock-3.2.4-2.el7_2.x86_64
mom-0.5.2-1.el7ev.noarch
vdsm-4.17.23-0.el7ev.noarch
ovirt-host-deploy-1.4.1-1.el7ev.noarch
ovirt-hosted-engine-ha-1.3.4.3-1.el7ev.noarch
ovirt-vmconsole-1.0.0-1.el7ev.noarch
ovirt-vmconsole-host-1.0.0-1.el7ev.noarch
ovirt-hosted-engine-setup-1.3.3.4-1.el7ev.noarch
ovirt-setup-lib-1.0.1-1.el7ev.noarch
Linux version 3.10.0-327.13.1.el7.x86_64 (mockbuild@x86-019.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) ) #1 SMP Mon Feb 29 13:22:02 EST 2016


Engine:
rhevm-3.6.3.4-0.1.el6.noarch
ovirt-vmconsole-proxy-1.0.0-1.el6ev.noarch
ovirt-engine-extension-aaa-ldap-1.1.2-1.el6ev.noarch
ovirt-host-deploy-1.4.1-1.el6ev.noarch
ovirt-host-deploy-java-1.4.1-1.el6ev.noarch
ovirt-setup-lib-1.0.1-1.el6ev.noarch
ovirt-vmconsole-1.0.0-1.el6ev.noarch
ovirt-engine-extension-aaa-jdbc-1.0.6-1.el6ev.noarch

Linux version 2.6.32-573.18.1.el6.x86_64 (mockbuild@x86-010.build.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP Wed Jan 6 11:20:49 EST 2016


Emails were received normally, without any errors:

From: host1@organization.com
To: receiver@mail.company.com
Subject: ovirt-hosted-engine state transition LocalMaintenance-ReinitializeFSM
Date: Sun, 06 Mar 2016 19:12:58 +0200
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24

The state machine changed state.

Note You need to log in before you can comment on or make changes to this bug.