Bug 1292060

Summary: Emails sent from broker have "corrupted" headers
Product: [oVirt] ovirt-hosted-engine-ha Reporter: HWSD <s.danzi>
Component: BrokerAssignee: Martin Sivák <msivak>
Status: CLOSED CURRENTRELEASE QA Contact: Nikolai Sednev <nsednev>
Severity: low Docs Contact:
Priority: medium    
Version: 1.3.3.3CC: bugs, dfediuck, gklein, mgoldboi, sbonazzo
Target Milestone: ovirt-3.6.1Keywords: Triaged
Target Release: 1.3.3.4Flags: rule-engine: ovirt-3.6.z+
mgoldboi: planning_ack+
msivak: devel_ack+
gklein: testing_ack+
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-17 07:19:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: SLA RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1301681    
Bug Blocks: 1284954    

Description HWSD 2015-12-16 11:18:15 UTC
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.lan>
From: mysender
To: undisclosed-recipients:;

From: mysender
To: myreceiver
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> 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 07:19:42 UTC
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 17:37:09 UTC
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.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.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
To: receiver.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.