Commit e9f637cb authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Merge branch 'devel-2.1'



* devel-2.1:
  ganeti-cleaner: Write log file with removed files
  RAPI client: Handle urllib2.HTTPError and raise GanetiApiError
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parents dfb34028 f6781abf
...@@ -20,20 +20,43 @@ ...@@ -20,20 +20,43 @@
set -e set -e
cleanup_master() {
# Return if machine is not part of a cluster
[[ -e $DATA_DIR/ssconf_master_node ]] || return 0
# Return if queue archive directory doesn't exist
[[ -d $QUEUE_ARCHIVE_DIR ]] || return 0
# Remove old jobs
find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \
xargs -r0 rm -vf
}
DATA_DIR=@LOCALSTATEDIR@/lib/ganeti DATA_DIR=@LOCALSTATEDIR@/lib/ganeti
CLEANER_LOG_DIR=@LOCALSTATEDIR@/log/ganeti/cleaner
QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive
# Define how many days archived jobs should be left alone # Define how many days archived jobs should be left alone
REMOVE_AFTER=21 REMOVE_AFTER=21
# Exit if machine is not part of a cluster # Define how many log files to keep around (usually one per day)
[[ -e $DATA_DIR/ssconf_master_node ]] || exit 0 KEEP_LOGS=50
# Log file for this run
LOG_FILE=$CLEANER_LOG_DIR/cleaner-$(date +'%Y-%m-%dT%H_%M').$$.log
# Create log directory
mkdir -p $CLEANER_LOG_DIR
# Redirect all output to log file
exec >>$LOG_FILE 2>&1
echo "Cleaner started at $(date)"
# Exit if queue archive directory doesn't exist # Remove old cleaner log files
[[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0 find $CLEANER_LOG_DIR -maxdepth 1 -type f | sort | head -n -$KEEP_LOGS | \
xargs -r rm -vf
# Remove old jobs cleanup_master
find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \
xargs -r0 rm -f
exit 0 exit 0
...@@ -419,6 +419,8 @@ class GanetiRapiClient(object): ...@@ -419,6 +419,8 @@ class GanetiRapiClient(object):
encoded_response_content = resp.read() encoded_response_content = resp.read()
except (OpenSSL.SSL.Error, OpenSSL.crypto.Error), err: except (OpenSSL.SSL.Error, OpenSSL.crypto.Error), err:
raise CertificateError("SSL issue: %s (%r)" % (err, err)) raise CertificateError("SSL issue: %s (%r)" % (err, err))
except urllib2.HTTPError, err:
raise GanetiApiError(str(err), code=err.code)
if encoded_response_content: if encoded_response_content:
response_content = simplejson.loads(encoded_response_content) response_content = simplejson.loads(encoded_response_content)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment