Merge "Drop support for liberasurecode<1.4.0"

This commit is contained in:
Zuul
2024-04-20 00:36:39 +00:00
committed by Gerrit Code Review
5 changed files with 18 additions and 91 deletions

View File

@@ -10,6 +10,8 @@
- openstack-tox-py35:
vars:
tox_envlist: py35-compilelibs
tox_environment:
LIBERASURECODE_REF: '1.4.0'
- openstack-tox-py36
- openstack-tox-py37
- openstack-tox-py38
@@ -29,6 +31,8 @@
- openstack-tox-py35:
vars:
tox_envlist: py35-compilelibs
tox_environment:
LIBERASURECODE_REF: '1.4.0'
- openstack-tox-py36
- openstack-tox-py37
- openstack-tox-py38

View File

@@ -24,7 +24,7 @@ Installation
Install pre-requisites:
* Python 2.6, 2.7 or 3.x (including development packages), argparse, setuptools
* liberasurecode v1.3.1 or greater [3]
* liberasurecode v1.4.0 or greater [3]
* Erasure code backend libraries, gf-complete and Jerasure [1],[2], ISA-L [4], etc
Install dependencies:
@@ -44,7 +44,6 @@ If you want to confirm all dependency packages installed successfully, try::
$ sudo bindep -f bindep.txt
*Note*: Currently, for Ubuntu, liberasurecode-dev in package repo is older than v1.2.0.
For CentOS, make sure to install the latest Openstack Cloud SIG repo
to be able to install the latest available version of liberasurecode-devel.

View File

@@ -30,39 +30,17 @@ from pyeclib_c import get_liberasurecode_version
import warnings
import logging
from logging.handlers import SysLogHandler
logger = logging.getLogger('pyeclib')
syslog_handler = SysLogHandler()
logger.addHandler(syslog_handler)
def check_backend_available(backend_name):
try:
from pyeclib_c import check_backend_available
from pyeclib_c import check_backend_available
if backend_name.startswith('flat_xor_hd'):
int_type = PyECLib_EC_Types.get_by_name('flat_xor_hd')
else:
int_type = PyECLib_EC_Types.get_by_name(backend_name)
if not int_type:
return False
return check_backend_available(int_type.value)
except ImportError:
# check_backend_available has been supported since
# liberasurecode>=1.2.0 so we need to define the func for older
# liberasurecode version
# select available k, m values
if backend_name.startswith('flat_xor_hd'):
k, m = (10, 5)
else:
k, m = (10, 4)
try:
ECDriver(ec_type=backend_name, k=k, m=m)
except ECDriverError:
return False
return True
if backend_name.startswith('flat_xor_hd'):
int_type = PyECLib_EC_Types.get_by_name('flat_xor_hd')
else:
int_type = PyECLib_EC_Types.get_by_name(backend_name)
if not int_type:
return False
return check_backend_available(int_type.value)
def PyECLibVersion(z, y, x):
@@ -566,25 +544,10 @@ VALID_EC_TYPES = _PyECLibValidECTypes()
def _liberasurecode_version():
version_int = get_liberasurecode_version()
version_hex_str = hex(version_int)
version_hex_str = version_hex_str.lstrip('0x')
major = str(int(version_hex_str[-6:-4]))
minor = str(int(version_hex_str[-4:-2]))
rev = str(int(version_hex_str[-2:]))
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
major = (version_int >> 16) & 0xff
minor = (version_int >> 8) & 0xff
rev = (version_int >> 0) & 0xff
return '%d.%d.%d' % (major, minor, rev)
LIBERASURECODE_VERSION = _liberasurecode_version()

View File

@@ -34,10 +34,6 @@
#include <bytesobject.h>
#include <liberasurecode/erasurecode.h>
#if ( LIBERASURECODE_VERSION < _VERSION(1,1,0) )
#include <liberasurecode/erasurecode_helpers.h>
#endif
/* Compat layer for python <= 2.6 */
#include "capsulethunk.h"
@@ -1189,32 +1185,7 @@ pyeclib_c_check_backend_available(PyObject *self, PyObject *args)
static PyObject*
pyeclib_c_liberasurecode_version(PyObject *self, PyObject *args) {
void *hLib;
char *err;
uint32_t (*hGetVersion)(void);
dlerror();
hLib = dlopen("liberasurecode.so", RTLD_LAZY);
/* It's important that we clear the last error before calling dysym */
err = dlerror();
if (err) {
/* This should never actually get hit; since we're using various
symbols already, liberasurecode.so should *already* be loaded. */
return PyInt_FromLong(LIBERASURECODE_VERSION);
}
hGetVersion = dlsym(hLib, "liberasurecode_get_version");
err = dlerror();
if (err) {
/* This is the important bit. Old version, doesn't have get_version
support; fall back to old behavior. */
dlclose(hLib);
return PyInt_FromLong(LIBERASURECODE_VERSION);
}
uint32_t version = (*hGetVersion)();
dlclose(hLib);
return Py_BuildValue("k", version);
return Py_BuildValue("k", liberasurecode_get_version());
}
static PyMethodDef PyECLibMethods[] = {
@@ -1227,9 +1198,7 @@ static PyMethodDef PyECLibMethods[] = {
{"get_metadata", pyeclib_c_get_metadata, METH_VARARGS, "Get the integrity checking metadata for a fragment"},
{"check_metadata", pyeclib_c_check_metadata, METH_VARARGS, "Check the integrity checking metadata for a set of fragments"},
{"get_liberasurecode_version", pyeclib_c_liberasurecode_version, METH_NOARGS, "Get libersaurecode version in use"},
#if ( LIBERASURECODE_VERSION >= _VERSION(1,2,0) )
{"check_backend_available", pyeclib_c_check_backend_available, METH_VARARGS, "Check if a backend is available"},
#endif
{NULL, NULL, 0, NULL} /* Sentinel */
};

View File

@@ -29,7 +29,6 @@ import sys
import tempfile
import unittest
from distutils.version import StrictVersion
from itertools import combinations
import six
@@ -46,8 +45,6 @@ from pyeclib.ec_iface import PyECLib_EC_Types
from pyeclib.ec_iface import ALL_EC_TYPES
from pyeclib.ec_iface import VALID_EC_TYPES
from pyeclib.ec_iface import LIBERASURECODE_VERSION
if sys.version < '3':
def b2i(b):
@@ -691,11 +688,6 @@ class TestPyECLibDriver(unittest.TestCase):
(first_fragment_to_corrupt + i) % len(fragments)
for i in range(num_to_corrupt)]
if StrictVersion(LIBERASURECODE_VERSION) < \
StrictVersion('1.2.0'):
# if liberasurecode is older than the version supports
# fragment integrity check, skip following test
continue
i = 0
for fragment in fragments:
if i in fragments_to_corrupt: