Add soft warning log line when using liberasurecode <1.3.1

To apply the fix for a liberasurecode issue [1], we need hard depencency
of liberasurecode requires >=1.3.1. However current binary dependency
maintainance tool "bindep" works only for packagers' repository. (i.e. it
refers the version of apt/yum/etc...) And nothing is cared for the binary
built from source.

This patch provides a way to detect incompatible liberasurecode and
makes a warning log line to syslog which suggest "you're using older
liberasurecode which will be deprecated, please upgrade it".

NOTE:
- This dependency managemnet depends on erasurecode_version.h header
  file in liberasurecode. i.e. it cannot care of overwritten .so library
  after PyECLib built once.

Partial-Bug: #1639691

1: Icee788a0931fe692fe0de31fabc4ba450e338a87

Change-Id: Ice5e96f0a59096cc9067823f0d62d6c7065ed62f
This commit is contained in:
Kota Tsuyuzaki 2016-11-16 20:42:27 -08:00
parent ab26abf78c
commit d163972bb0
1 changed files with 18 additions and 0 deletions

View File

@ -28,6 +28,12 @@ from .utils import create_instance
from .utils import positive_int_value from .utils import positive_int_value
from pyeclib_c import get_liberasurecode_version from pyeclib_c import get_liberasurecode_version
import logging
from logging.handlers import SysLogHandler
logger = logging.getLogger('pyeclib')
syslog_handler = SysLogHandler()
logger.addHandler(syslog_handler)
def check_backend_available(backend_name): def check_backend_available(backend_name):
try: try:
@ -527,6 +533,18 @@ def _liberasurecode_version():
minor = str(int(version_hex_str[-4:-2])) minor = str(int(version_hex_str[-4:-2]))
rev = str(int(version_hex_str[-2:])) rev = str(int(version_hex_str[-2:]))
version_str = '.'.join([major, minor, rev]) version_str = '.'.join([major, minor, rev])
# liberasurecode < 1.3.1 should be incompatible but
# just warn until packagers build the required version
# See https://bugs.launchpad.net/swift/+bug/1639691 in detail
required_version = ((1 << 16) + (3 << 8) + 1)
if version_int < required_version:
logger.warning(
'DEPRECATED WARNING: your liberasurecode '
'%s will be deprecated in the near future because of the issue '
'https://bugs.launchpad.net/swift/+bug/1639691; '
'Please upgrade to >=1.3.1 and rebuild pyeclib to suppress '
'this message' % version_str)
return version_str return version_str
LIBERASURECODE_VERSION = _liberasurecode_version() LIBERASURECODE_VERSION = _liberasurecode_version()