|
|
1f1d7d |
commit 1fb713cdabf46694e76df4092615607fa09016fe
|
|
|
1f1d7d |
Author: Zdenek Pavlas <zpavlas@redhat.com>
|
|
|
1f1d7d |
Date: Thu Dec 19 10:43:07 2013 +0100
|
|
|
1f1d7d |
|
|
|
1f1d7d |
yum-cron: initialize both debuglevel and errorlevel
|
|
|
1f1d7d |
|
|
|
1f1d7d |
When warnings or errors are disabled in verbose
|
|
|
1f1d7d |
logger, disable them in error logger too.
|
|
|
1f1d7d |
|
|
|
1f1d7d |
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
index a1fd10b..19436e5 100755
|
|
|
1f1d7d |
--- a/yum-cron/yum-cron.py
|
|
|
1f1d7d |
+++ b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
@@ -380,16 +380,16 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
self.preconf.fn = self.opts.yum_config_file
|
|
|
1f1d7d |
|
|
|
1f1d7d |
# This needs to be set early, errors are handled later.
|
|
|
1f1d7d |
- try: self.preconf.debuglevel = int(self._confparser.get('base', 'debuglevel'))
|
|
|
1f1d7d |
- except: pass
|
|
|
1f1d7d |
+ try: level = int(self._confparser.get('base', 'debuglevel'))
|
|
|
1f1d7d |
+ except: level = -2
|
|
|
1f1d7d |
+ self.preconf.debuglevel = level
|
|
|
1f1d7d |
+ if -4 <= level <= -2:
|
|
|
1f1d7d |
+ self.preconf.errorlevel = level + 4
|
|
|
1f1d7d |
|
|
|
1f1d7d |
# if we are not root do the special subdir thing
|
|
|
1f1d7d |
if os.geteuid() != 0:
|
|
|
1f1d7d |
self.setCacheDir()
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- # Create the configuration
|
|
|
1f1d7d |
- self.conf
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
# override base yum options
|
|
|
1f1d7d |
self.conf.populate(self._confparser, 'base')
|
|
|
1f1d7d |
del self._confparser
|
|
|
1f1d7d |
commit d0441397dc5a5e4f4d3ccc3a99c4cda57b228009
|
|
|
1f1d7d |
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
|
|
|
1f1d7d |
Date: Mon Jan 6 14:12:46 2014 +0100
|
|
|
1f1d7d |
|
|
|
1f1d7d |
Remove emitCheckFailed(), change it to logger.warn(). BZ 1048391
|
|
|
1f1d7d |
|
|
|
1f1d7d |
Make acquireLock() respect debuglevel.
|
|
|
1f1d7d |
|
|
|
1f1d7d |
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
index b96dd13..386a7a0 100755
|
|
|
1f1d7d |
--- a/yum-cron/yum-cron.py
|
|
|
1f1d7d |
+++ b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
@@ -86,17 +86,6 @@ class UpdateEmitter(object):
|
|
|
1f1d7d |
% errmsg)
|
|
|
1f1d7d |
self.sendMessages()
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- def lockFailed(self, errmsg):
|
|
|
1f1d7d |
- """Append a message to the output list stating that the
|
|
|
1f1d7d |
- program failed to acquire the yum lock, then call sendMessages
|
|
|
1f1d7d |
- to emit the output.
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
- :param errmsg: a string that contains the error message
|
|
|
1f1d7d |
- """
|
|
|
1f1d7d |
- self.output.append("Failed to acquire the yum lock with the following error message: \n%s"
|
|
|
1f1d7d |
- % errmsg)
|
|
|
1f1d7d |
- self.sendMessages()
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
def checkFailed(self, errmsg):
|
|
|
1f1d7d |
"""Append a message to the output stating that checking for
|
|
|
1f1d7d |
updates failed, then call sendMessages to emit the output.
|
|
|
1f1d7d |
@@ -196,16 +185,6 @@ class EmailEmitter(UpdateEmitter):
|
|
|
1f1d7d |
self.subject = "Yum: Failed to perform setup on %s" % self.opts.system_name
|
|
|
1f1d7d |
super(EmailEmitter, self).setupFailed(errmsg)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- def lockFailed(self, errmsg):
|
|
|
1f1d7d |
- """Append a message to the output list stating that the
|
|
|
1f1d7d |
- program failed to acquire the yum lock, then call sendMessages
|
|
|
1f1d7d |
- to emit the output, and set an appropriate subject line.
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
- :param errmsg: a string that contains the error message
|
|
|
1f1d7d |
- """
|
|
|
1f1d7d |
- self.subject = "Yum: Failed to acquire the yum lock on %s" % self.opts.system_name
|
|
|
1f1d7d |
- super(EmailEmitter, self).lockFailed(errmsg)
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
def checkFailed(self, errmsg):
|
|
|
1f1d7d |
"""Append a message to the output stating that checking for
|
|
|
1f1d7d |
updates failed, then call sendMessages to emit the output, and
|
|
|
1f1d7d |
@@ -406,7 +385,7 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
try:
|
|
|
1f1d7d |
self.doLock()
|
|
|
1f1d7d |
except yum.Errors.LockError, e:
|
|
|
1f1d7d |
- self.emitLockFailed("%s" % e)
|
|
|
1f1d7d |
+ self.logger.warn("Failed to acquire the yum lock: %s", e)
|
|
|
1f1d7d |
sys.exit(1)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
def populateUpdateMetadata(self):
|
|
|
1f1d7d |
@@ -675,10 +654,6 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
"""Emit a notice stating that checking for updates failed."""
|
|
|
1f1d7d |
map(lambda x: x.setupFailed(error), self.emitters)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- def emitLockFailed(self, errmsg):
|
|
|
1f1d7d |
- """Emit a notice that we failed to acquire the yum lock."""
|
|
|
1f1d7d |
- map(lambda x: x.lockFailed(errmsg), self.emitters)
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
def emitCheckFailed(self, error):
|
|
|
1f1d7d |
"""Emit a notice stating that checking for updates failed."""
|
|
|
1f1d7d |
map(lambda x: x.checkFailed(error), self.emitters)
|
|
|
1f1d7d |
commit 13f69f68876fade7611bcbab6f612937e1c02bff
|
|
|
1f1d7d |
Author: Zdenek Pavlas <zpavlas@redhat.com>
|
|
|
1f1d7d |
Date: Wed Jan 15 09:11:30 2014 +0100
|
|
|
1f1d7d |
|
|
|
1f1d7d |
yum-cron: emitUpdateFailed() expects str, not an array.
|
|
|
1f1d7d |
|
|
|
1f1d7d |
Avoid Python noise in the report. Also, use implicit conversion
|
|
|
1f1d7d |
instead of str() for unicode interoperability.
|
|
|
1f1d7d |
|
|
|
1f1d7d |
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
index 87b3e69..6cbed94 100755
|
|
|
1f1d7d |
--- a/yum-cron/yum-cron.py
|
|
|
1f1d7d |
+++ b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
@@ -545,7 +545,7 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
try:
|
|
|
1f1d7d |
self.getKeyForPackage(po)
|
|
|
1f1d7d |
except yum.Errors.YumBaseError, errmsg:
|
|
|
1f1d7d |
- self.emitUpdateFailed([str(errmsg)])
|
|
|
1f1d7d |
+ self.emitUpdateFailed(errmsg)
|
|
|
1f1d7d |
return False
|
|
|
1f1d7d |
else:
|
|
|
1f1d7d |
self.emitUpdateFailed(err)
|
|
|
1f1d7d |
@@ -563,8 +563,7 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
try:
|
|
|
1f1d7d |
self.runTransaction(cb=cb)
|
|
|
1f1d7d |
except yum.Errors.YumBaseError, err:
|
|
|
1f1d7d |
-
|
|
|
1f1d7d |
- self.emitUpdateFailed([str(err)])
|
|
|
1f1d7d |
+ self.emitUpdateFailed(err)
|
|
|
1f1d7d |
sys.exit(1)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
if emit :
|
|
|
1f1d7d |
@@ -675,9 +674,9 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
"""Emit a notice stating that downloading the updates failed."""
|
|
|
1f1d7d |
map(lambda x: x.downloadFailed(error), self.emitters)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- def emitUpdateFailed(self, errmsgs):
|
|
|
1f1d7d |
+ def emitUpdateFailed(self, errmsg):
|
|
|
1f1d7d |
"""Emit a notice stating that automatic updates failed."""
|
|
|
1f1d7d |
- map(lambda x: x.updatesFailed(errmsgs), self.emitters)
|
|
|
1f1d7d |
+ map(lambda x: x.updatesFailed(errmsg), self.emitters)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
def emitMessages(self):
|
|
|
1f1d7d |
"""Emit the messages from the emitters."""
|
|
|
1f1d7d |
commit 048af21d6704d40e93e09c65f5c1b547a68e431e
|
|
|
1f1d7d |
Author: Zdenek Pavlas <zpavlas@redhat.com>
|
|
|
1f1d7d |
Date: Mon Jan 20 10:59:58 2014 +0100
|
|
|
1f1d7d |
|
|
|
1f1d7d |
yum-cron: EmailEmitter failure should not be fatal. BZ 1055042
|
|
|
1f1d7d |
|
|
|
1f1d7d |
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
index 6cbed94..bfa580e 100755
|
|
|
1f1d7d |
--- a/yum-cron/yum-cron.py
|
|
|
1f1d7d |
+++ b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
@@ -146,8 +146,9 @@ class UpdateEmitter(object):
|
|
|
1f1d7d |
class EmailEmitter(UpdateEmitter):
|
|
|
1f1d7d |
"""Emitter class to send messages via email."""
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- def __init__(self, opts):
|
|
|
1f1d7d |
+ def __init__(self, opts, logger):
|
|
|
1f1d7d |
super(EmailEmitter, self).__init__(opts)
|
|
|
1f1d7d |
+ self.logger = logger
|
|
|
1f1d7d |
self.subject = ""
|
|
|
1f1d7d |
|
|
|
1f1d7d |
def updatesAvailable(self, summary):
|
|
|
1f1d7d |
@@ -229,10 +230,13 @@ class EmailEmitter(UpdateEmitter):
|
|
|
1f1d7d |
msg['To'] = ",".join(self.opts.email_to)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
# Send the email
|
|
|
1f1d7d |
- s = smtplib.SMTP()
|
|
|
1f1d7d |
- s.connect(self.opts.email_host)
|
|
|
1f1d7d |
- s.sendmail(self.opts.email_from, self.opts.email_to, msg.as_string())
|
|
|
1f1d7d |
- s.close()
|
|
|
1f1d7d |
+ try:
|
|
|
1f1d7d |
+ s = smtplib.SMTP()
|
|
|
1f1d7d |
+ s.connect(self.opts.email_host)
|
|
|
1f1d7d |
+ s.sendmail(self.opts.email_from, self.opts.email_to, msg.as_string())
|
|
|
1f1d7d |
+ s.close()
|
|
|
1f1d7d |
+ except Exception, e:
|
|
|
1f1d7d |
+ self.logger.error("Failed to send an email to %s: %s" % (self.opts.email_host, e))
|
|
|
1f1d7d |
|
|
|
1f1d7d |
|
|
|
1f1d7d |
class StdIOEmitter(UpdateEmitter):
|
|
|
1f1d7d |
@@ -293,7 +297,7 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
# Create the emitters, and add them to the list
|
|
|
1f1d7d |
self.emitters = []
|
|
|
1f1d7d |
if 'email' in self.opts.emit_via:
|
|
|
1f1d7d |
- self.emitters.append(EmailEmitter(self.opts))
|
|
|
1f1d7d |
+ self.emitters.append(EmailEmitter(self.opts, self.logger))
|
|
|
1f1d7d |
if 'stdio' in self.opts.emit_via:
|
|
|
1f1d7d |
self.emitters.append(StdIOEmitter(self.opts))
|
|
|
1f1d7d |
|
|
|
1f1d7d |
commit 8d21de54f5b267af8710c1358fd3a0475aed6bbb
|
|
|
1f1d7d |
Author: Zdenek Pavlas <zpavlas@redhat.com>
|
|
|
1f1d7d |
Date: Mon Jan 20 11:41:15 2014 +0100
|
|
|
1f1d7d |
|
|
|
1f1d7d |
yum-cron: Add a retry loop around doLock().
|
|
|
1f1d7d |
|
|
|
1f1d7d |
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
index bfa580e..e1028be 100755
|
|
|
1f1d7d |
--- a/yum-cron/yum-cron.py
|
|
|
1f1d7d |
+++ b/yum-cron/yum-cron.py
|
|
|
1f1d7d |
@@ -262,6 +262,8 @@ class YumCronConfig(BaseConfig):
|
|
|
1f1d7d |
system_name = Option(gethostname())
|
|
|
1f1d7d |
output_width = IntOption(80)
|
|
|
1f1d7d |
random_sleep = IntOption(0)
|
|
|
1f1d7d |
+ lock_retries = IntOption(5)
|
|
|
1f1d7d |
+ lock_sleep = IntOption(60)
|
|
|
1f1d7d |
emit_via = ListOption(['email','stdio'])
|
|
|
1f1d7d |
email_to = ListOption(["root"])
|
|
|
1f1d7d |
email_from = Option("root")
|
|
|
1f1d7d |
@@ -386,9 +388,14 @@ class YumCronBase(yum.YumBase, YumOutput):
|
|
|
1f1d7d |
def acquireLock(self):
|
|
|
1f1d7d |
""" Wrapper method around doLock to emit errors correctly."""
|
|
|
1f1d7d |
|
|
|
1f1d7d |
- try:
|
|
|
1f1d7d |
- self.doLock()
|
|
|
1f1d7d |
- except yum.Errors.LockError, e:
|
|
|
1f1d7d |
+ i = 0
|
|
|
1f1d7d |
+ while True:
|
|
|
1f1d7d |
+ try: self.doLock(); break
|
|
|
1f1d7d |
+ except yum.Errors.LockError, e:
|
|
|
1f1d7d |
+ i += 1
|
|
|
1f1d7d |
+ if i < self.opts.lock_retries:
|
|
|
1f1d7d |
+ sleep(self.opts.lock_sleep)
|
|
|
1f1d7d |
+ continue
|
|
|
1f1d7d |
self.logger.warn("Failed to acquire the yum lock: %s", e)
|
|
|
1f1d7d |
sys.exit(1)
|
|
|
1f1d7d |
|