Revert "SERVER-75033 Capture core dumps from test failures on macOS"

This reverts commit d6072dc2c6.

GitOrigin-RevId: 46a18f2bf208191c2e48357043a879de3f2435b6
This commit is contained in:
Trevor Guidry 2023-12-14 20:07:42 +00:00 committed by MongoDB Bot
parent 5d6ea60c37
commit 2734f82d7d
5 changed files with 63 additions and 95 deletions

View File

@ -2939,7 +2939,15 @@ tasks:
archive-dist-test archive-dist-test
task_compile_flags: >- task_compile_flags: >-
PREFIX=dist-test PREFIX=dist-test
sign_macos_archive: true - command: subprocess.exec
params:
binary: bash
add_expansions_to_env: true
args:
- "src/evergreen/run_python_script.sh"
- "evergreen/macos_notary.py"
- "mongodb-binaries.${ext|tgz}"
- command: s3.put - command: s3.put
params: params:
optional: true optional: true
@ -8157,7 +8165,14 @@ tasks:
${additional_package_targets|} ${additional_package_targets|}
task_compile_flags: >- task_compile_flags: >-
--legacy-tarball --legacy-tarball
sign_macos_archive: true - command: subprocess.exec
params:
binary: bash
add_expansions_to_env: true
args:
- "src/evergreen/run_python_script.sh"
- "evergreen/macos_notary.py"
- "mongodb-dist.${ext|tgz}"
- func: "f_expansions_write" - func: "f_expansions_write"
- command: subprocess.exec - command: subprocess.exec
params: params:

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/>
<!--The get-task-allow entitlement is insecure and must only be used in dev environments-->
<key>com.apple.security.get-task-allow</key><true/>
</dict>
</plist>

View File

@ -1,4 +1,3 @@
import argparse
import os import os
import platform import platform
import shutil import shutil
@ -7,13 +6,15 @@ import subprocess
import zipfile import zipfile
import stat import stat
import sys import sys
import yaml
if platform.system().lower() != 'darwin': if platform.system().lower() != 'darwin':
print("Not a macos system, skipping macos signing.") print("Not a macos system, skipping macos signing.")
sys.exit(0) sys.exit(0)
if len(sys.argv) < 2:
print("Must provide at least 1 archive to sign.")
sys.exit(1)
supported_archs = { supported_archs = {
'arm64': 'arm64', 'arm64': 'arm64',
'x86_64': 'amd64' 'x86_64': 'amd64'
@ -24,21 +25,13 @@ if arch not in supported_archs:
print(f"Unsupported platform uname arch: {arch}, must be {supported_archs.keys()}") print(f"Unsupported platform uname arch: {arch}, must be {supported_archs.keys()}")
sys.exit(1) sys.exit(1)
expansions_file = "../expansions.yml"
if not os.path.exists(expansions_file):
print("Evergreen expansions file not found. Skipping macos_notary.")
sys.exit(0)
with open(expansions_file) as file:
expansions = yaml.safe_load(file)
should_sign = expansions.get("sign_macos_archive", None)
if not should_sign:
print("sign_macos_archive expansion not found not found or false. Skipping macos_notary.")
sys.exit(0)
macnotary_name = f'darwin_{supported_archs[arch]}' macnotary_name = f'darwin_{supported_archs[arch]}'
if os.environ['project'] == "mongodb-mongo-master-nightly":
signing_type = 'notarizeAndSign'
else:
signing_type = 'sign'
macnotary_url = f'https://macos-notary-1628249594.s3.amazonaws.com/releases/client/latest/{macnotary_name}.zip' macnotary_url = f'https://macos-notary-1628249594.s3.amazonaws.com/releases/client/latest/{macnotary_name}.zip'
print(f'Fetching macnotary tool from: {macnotary_url}') print(f'Fetching macnotary tool from: {macnotary_url}')
local_filename, headers = urllib.request.urlretrieve(macnotary_url, f'{macnotary_name}.zip') local_filename, headers = urllib.request.urlretrieve(macnotary_url, f'{macnotary_name}.zip')
@ -49,51 +42,43 @@ st = os.stat(f'{macnotary_name}/macnotary')
os.chmod(f'{macnotary_name}/macnotary', st.st_mode | stat.S_IEXEC) os.chmod(f'{macnotary_name}/macnotary', st.st_mode | stat.S_IEXEC)
failed = False failed = False
parser = argparse.ArgumentParser( archives = sys.argv[1:]
prog="MacOS Notary",
description="Sign and/or notarize a tarball containing unsigned binaries.",
)
parser.add_argument("--archive-name", "-a", action="store", required=True)
parser.add_argument("--entitlements-file", "-e", action="store", required=True)
parser.add_argument("--signing-type", "-s", action="store", required=True)
args = parser.parse_args()
archive_name = args.archive_name
entitlements_file = args.entitlements_file
signing_type = args.signing_type
archive_base, archive_ext = os.path.splitext(archive_name) for archive in archives:
unsigned_archive = f'{archive_base}_unsigned{archive_ext}' archive_base, archive_ext = os.path.splitext(archive)
shutil.move(archive_name, unsigned_archive) unsigned_archive = f'{archive_base}_unsigned{archive_ext}'
shutil.move(archive, unsigned_archive)
signing_cmd = [ signing_cmd = [
f'./{macnotary_name}/macnotary', f'./{macnotary_name}/macnotary',
'-f', f'{unsigned_archive}', '-f', f'{unsigned_archive}',
'-m', f'{signing_type}', '-m', f'{signing_type}',
'-u', 'https://dev.macos-notary.build.10gen.cc/api', '-u', 'https://dev.macos-notary.build.10gen.cc/api',
'-k', 'server', '-k', 'server',
'--entitlements', entitlements_file, '--entitlements', 'etc/macos_entitlements.xml',
'--verify', '--verify',
'-b', 'server.mongodb.com', '-b', 'server.mongodb.com',
'-i', f'{expansions["task_id"]}', '-i', f'{os.environ["task_id"]}',
'-c', f'{expansions["project"]}', '-c', f'{os.environ["project"]}',
'-o', f'{archive_name}' '-o', f'{archive}'
] ]
signing_env = os.environ.copy() signing_env = os.environ.copy()
signing_env['MACOS_NOTARY_SECRET'] = expansions.get("macos_notarization_secret", "") signing_env['MACOS_NOTARY_SECRET'] = os.environ["macos_notarization_secret"]
print(' '.join(signing_cmd)) print(' '.join(signing_cmd))
p = subprocess.Popen(signing_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=signing_env) p = subprocess.Popen(signing_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=signing_env)
print(f"Signing tool completed with exitcode: {p.returncode}") print(f"Signing tool completed with exitcode: {p.returncode}")
for line in iter(p.stdout.readline, b''): for line in iter(p.stdout.readline, b''):
print(f'macnotary: {line.decode("utf-8").strip()}') print(f'macnotary: {line.decode("utf-8").strip()}')
p.wait() p.wait()
if p.returncode != 0: if p.returncode != 0:
failed = True failed = True
shutil.move(unsigned_archive, archive_name) shutil.move(unsigned_archive, archive)
else: else:
os.unlink(unsigned_archive) os.unlink(unsigned_archive)
if failed: if failed:
exit(1) exit(1)

View File

@ -290,25 +290,6 @@ def archive_builder(source, target, env, for_signature):
return cmd return cmd
def macos_archive_sign_builder(source, target, env, for_signature):
if env['PLATFORM'] != 'darwin' or env.GetOption("ninja") != 'disabled':
return ""
if env.GetOption("release") is not None:
print("MacOS release build found, signing with release entitlements.")
entitlements_file = 'etc/macos_release_entitlements.xml'
signing_type = 'notarizeAndSign'
else:
print("MacOS dev build found, signing with insecure development entitlements.")
entitlements_file = 'etc/macos_dev_entitlements.xml'
signing_type = 'sign'
archive_name = env.File(target[0])
macos_notory_cmd = f"{sys.executable} evergreen/macos_notary.py --archive-name={archive_name} --entitlements-file={entitlements_file} --signing-type={signing_type}"
return macos_notory_cmd
def exists(env): def exists(env):
return True return True
@ -318,14 +299,11 @@ def generate(env):
env.Tool("auto_install_binaries") env.Tool("auto_install_binaries")
bld = SCons.Builder.Builder( bld = SCons.Builder.Builder(
action=SCons.Action.ListAction([ action=SCons.Action.CommandGeneratorAction(
SCons.Action.CommandGeneratorAction( archive_builder,
archive_builder, {"cmdstr": "Building package ${TARGETS[0]} from ${SOURCES[1:]}"}
{"cmdstr": "Building package ${TARGETS[0]} from ${SOURCES[1:]}"} if not env.Verbose() else {"cmdstr": ""},
if not env.Verbose() else {"cmdstr": ""}, ))
),
SCons.Action.CommandGeneratorAction(macos_archive_sign_builder, {})
]))
env.Append(BUILDERS={"AutoArchive": bld}) env.Append(BUILDERS={"AutoArchive": bld})
env["AUTO_ARCHIVE_TARBALL_SUFFIX"] = env.get( env["AUTO_ARCHIVE_TARBALL_SUFFIX"] = env.get(
"AUTO_ARCHIVE_TARBALL_SUFFIX", "AUTO_ARCHIVE_TARBALL_SUFFIX",