Skip to content

Fixes for csfle downloading on some Linux platforms #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ae134d1
Add mlib to the source tree
vector-of-bool Apr 5, 2022
70cbd72
No -Winline
vector-of-bool Apr 6, 2022
bd6501d
Tweak mlib usage in CMake
vector-of-bool Apr 7, 2022
e6363ba
Incorporate changes for csfle in libmongocrypt
vector-of-bool Apr 14, 2022
cddf5c7
Enable C99 as the default language mode for the project
vector-of-bool Apr 15, 2022
33827b6
Tweak macro name
vector-of-bool Apr 7, 2022
44ff2e8
Test case to check linker symbol merging
vector-of-bool Apr 7, 2022
4099263
Missing dist listing
vector-of-bool Apr 15, 2022
cbdc11a
Merge branch 'master' into adopt-csfle
vector-of-bool Apr 18, 2022
21c5581
test-libmongoc might not be created
vector-of-bool Apr 18, 2022
cbfdfca
MinGW lacks WC_ERR_INVALID_CHARS
vector-of-bool Apr 18, 2022
834308f
Document new extraOptions for auto-encryption
vector-of-bool Apr 19, 2022
a334c4e
Remove mlib for now
vector-of-bool Apr 19, 2022
17687a7
Add mongodl, download a csfle library for testing. Use csfle in test …
vector-of-bool Apr 19, 2022
2566d33
Fix: forked child processes must not used exit() nor allocating funct…
vector-of-bool Apr 19, 2022
8328de4
C99 is not required
vector-of-bool Apr 20, 2022
c966020
mlib is not part of the dist any more
vector-of-bool Apr 20, 2022
46fde37
Fix platform detection in mongodl
vector-of-bool Apr 20, 2022
3a20ed6
Tweak filter output for --list
vector-of-bool Apr 20, 2022
6c6b01e
Various spelling
vector-of-bool Apr 20, 2022
3b7bb90
Only download csfle if we are building tests
vector-of-bool Apr 20, 2022
58fc76a
mongodl: Default edition is 'enterprise'
vector-of-bool Apr 20, 2022
864e513
Do not append csfle search paths if we are explicit or bypassing auto…
vector-of-bool Apr 20, 2022
a41f7c9
Make a USE_CSFLE option to control whether we use csfle for testing. Fix
vector-of-bool Apr 21, 2022
53ed65e
Address PR comments. Tweak doc wording.
vector-of-bool Apr 21, 2022
c6a78b1
Fix mongodl for rhel versions and ASCII stdout
vector-of-bool Apr 22, 2022
addb083
Prefer find_program() for finding Python3
vector-of-bool Apr 22, 2022
aac7994
Fix Ubuntu detection. Small formatting
vector-of-bool Apr 22, 2022
40a2612
Missing dist for mongodl
vector-of-bool Apr 22, 2022
ccc2547
Using an $ORIGIN based path for the csfle library
vector-of-bool Apr 22, 2022
c82bdb1
Disable csfle for tests that rely on mongocryptd behaviors
vector-of-bool Apr 22, 2022
57e53b7
Speeling
vector-of-bool Apr 22, 2022
966d303
Indentation fix
vector-of-bool Apr 22, 2022
ec9ec9a
Clearer assertion error message
vector-of-bool Apr 22, 2022
606b1a5
Use POSIX _exit instead of wrapping it
vector-of-bool Apr 22, 2022
37cb34d
Formatting
vector-of-bool Apr 22, 2022
aa5180b
csfle placement is difficult
vector-of-bool Apr 22, 2022
3c8ccfa
Just put it in the top directory for now
vector-of-bool Apr 26, 2022
45a9bf2
Just use 'find'
vector-of-bool Apr 26, 2022
c497d22
Better find, better output path
vector-of-bool Apr 26, 2022
eda94f6
Remove BSON_MEMCHECK. We're getting ODR trouble.
vector-of-bool Apr 27, 2022
7654848
Tell me what you did.
vector-of-bool Apr 27, 2022
5e29834
No csflePath on Windows yet
vector-of-bool Apr 27, 2022
281df33
Remove __csfleDisabled option
vector-of-bool Apr 27, 2022
c7d54b4
Skip failing CSE tests for now
vector-of-bool Apr 27, 2022
a4363a7
Fix mongodl for older Python versions
vector-of-bool Apr 28, 2022
4635971
Older Python3 has limitted pathlib functions
vector-of-bool Apr 28, 2022
760ad4c
Archlinux is a special case. Just use RHEL8 binaries
vector-of-bool Apr 28, 2022
f959f04
Even older Linuxes
vector-of-bool Apr 28, 2022
80dce13
Disable csfle download if there is no version download available for …
vector-of-bool Apr 28, 2022
e7405f2
Merge remote-tracking branch 'upstream/master' into adopt-csfle
vector-of-bool Apr 28, 2022
56c0e3e
Stop _mkdir path creation if we find an existing dir.
vector-of-bool Apr 28, 2022
1b9e4c6
Explain some behavior in mongodl
vector-of-bool Apr 28, 2022
8af720a
Fix Amazon linux detection
vector-of-bool Apr 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .evergreen/compile-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ if [ "darwin" = "$OS" -a "arm64" = "$MARCH" ]; then
CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DCMAKE_OSX_ARCHITECTURES=arm64"
fi

if ! python3 build/mongodl.py --test -C csfle -V 5.3.1 -o . > /dev/null; then
echo "No csfle detected for this platform. Disabling MONGOC_TEST_USE_CSFLE."
CONFIGURE_FLAGS="$CONFIGURE_FLAGS -DMONGOC_TEST_USE_CSFLE=OFF"
fi

CONFIGURE_FLAGS="$CONFIGURE_FLAGS $EXTRA_CONFIGURE_FLAGS"
export MONGOC_TEST_FUTURE_TIMEOUT_MS=30000
export MONGOC_TEST_SKIP_LIVE=on
Expand Down
49 changes: 39 additions & 10 deletions build/mongodl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'opensuse-leap': 'sles',
'opensuse': 'sles',
'redhat': 'rhel',
'rocky': 'rhel',
}

DISTRO_VERSION_MAP = {
Expand All @@ -46,6 +47,7 @@
'20.*': 'ubuntu2004',
'18.*': 'ubuntu1804',
'16.*': 'ubuntu1604',
'14.*': 'ubuntu1404',
},
'debian': {
'9': 'debian92',
Expand All @@ -54,8 +56,11 @@
},
'rhel': {
'6': 'rhel60',
'6.*': 'rhel60',
'7': 'rhel70',
'7.*': 'rhel70',
'8': 'rhel80',
'8.*': 'rhel80',
},
'sles': {
'10.*': 'suse10',
Expand All @@ -65,8 +70,8 @@
'15.*': 'suse15',
},
'amzn': {
'2018': 'amzn64',
'2': 'amzn64',
'2018.*': 'amzn64',
'2': 'amazon2',
},
}

Expand All @@ -84,12 +89,18 @@ def infer_target():


def _infer_target_os_rel():
content = Path('/etc/os-release').read_text()
with Path('/etc/os-release').open('r', encoding='utf-8') as f:
content = f.read()
id_re = re.compile(r'\bID=("?)(.*)\1')
mat = id_re.search(content)
assert mat, 'Unable to detect ID from [/etc/os-release] content:\n{}'.format(
content)
os_id = mat.group(2)
if os_id == 'arch':
# There are no Archlinux-specific MongoDB downloads, so we'll just use
# the build for RHEL8, which is reasonably compatible with other modern
# distributions (including Arch).
return 'rhel80'
ver_id_re = re.compile(r'VERSION_ID=("?)(.*?)\1')
mat = ver_id_re.search(content)
assert mat, 'Unable to detect VERSION_ID from [/etc/os-release] content:\n{}'.format(
Expand Down Expand Up @@ -122,11 +133,11 @@ def caches_root():
if sys.platform == 'win32':
return Path(os.environ['LocalAppData'])
if sys.platform == 'darwin':
return Path('~/Library/Caches').expanduser()
return Path(os.environ['HOME'] + '/Library/Caches')
xdg_cache = os.getenv('XDG_CACHE_HOME')
if xdg_cache:
return Path(xdg_cache)
return Path('~/.cache').expanduser()
return Path(os.environ['HOME'] + '/.cache')


def cache_dir():
Expand Down Expand Up @@ -214,9 +225,27 @@ def _import_json_data(db, json_file):
)


def _mkdir(dirpath):
"""
Ensure a directory at ``dirpath``, and all parent directories thereof.

Cannot using Path.mkdir(parents, exist_ok) on some Python versions that
we need to support.
"""
if dirpath.is_dir():
return
par = dirpath.parent
if par != dirpath:
_mkdir(par)
try:
dirpath.mkdir()
except FileExistsError:
pass


def get_dl_db():
caches = cache_dir()
caches.mkdir(exist_ok=True, parents=True)
_mkdir(caches)
db = sqlite3.connect(str(caches / 'downloads.db'), isolation_level=None)
db.executescript(r'''
CREATE TABLE IF NOT EXISTS meta (
Expand Down Expand Up @@ -271,7 +300,7 @@ def _print_list(db, version, target, arch, edition, component):
' Edition: {}\n\n'
' Info: {}\n\n'.format(comp_key, version, target, arch,
edition, comp_data))
print(f'(Omit filter arguments for a list of available filters)')
print('(Omit filter arguments for a list of available filters)')
return

arches, targets, editions, versions, components = next(
Expand Down Expand Up @@ -344,7 +373,7 @@ def _download_file(db, url):
return DLRes(False, dest)
else:
print('Downloading [{}] ...'.format(url))
dest.parent.mkdir(exist_ok=True, parents=True)
_mkdir(dest.parent)
got_etag = resp.getheader("ETag")
got_modtime = resp.getheader('Last-Modified')
with dest.open('wb') as of:
Expand Down Expand Up @@ -551,10 +580,10 @@ def _maybe_extract_member(out, relpath, pattern, strip, is_dir, opener,
# We are running in test-only mode: Do not do anything
return 1
if is_dir:
dest.mkdir(exist_ok=True, parents=True)
_mkdir(dest)
return 1
with opener() as infile:
dest.parent.mkdir(exist_ok=True, parents=True)
_mkdir(dest.parent)
with dest.open('wb') as outfile:
shutil.copyfileobj(infile, outfile)
os.chmod(str(dest), modebits)
Expand Down