-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up Gitlab testing for Kubernetes runners (#2903)
* Make the Gitlab config explain how to start and stop Docker, in case entrypoints aren't respected * Actually import boto.exception.S3ResponseError Looks like we never tested this code path because we never had an error here in the tests. * Consider cgroup v1 limits when determining available CPUs * Fail the Docker build if Quay login fails * Use new CPU counting function in Parasol test support * Use Gitlab secrets instead of the AWS secrets manager This is so we don't rely on CI runners having any built-in AWS accessi. * Instrument Quay login * Don't open the name of an environment variable as a file * Make sure to pre-pull base Docker images to avoid disconnects failing the actual build * Make sure Docker is actually up before each pull * Just do more pull attempts since it seems like pull is a bit flaky today * Set timouts on the deferred function tests and verbosify them. * Make all the pytest tests verbose so we can see the names of what runs if it gets stuck * Dump flaky test output * Report on core counts in case they weirdly all became 1 * Send enough format arguments * Adopt a non-kubernetes-dependent cgroup sizing method * Stop instrumenting the flaky test so carefully
- Loading branch information
Showing
15 changed files
with
139 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
import subprocess | ||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
stderr = 'Login was not attempted' | ||
|
||
p = subprocess.Popen('aws secretsmanager --region us-west-2 get-secret-value --secret-id /toil/gitlab/quay', | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
stdout, stderr = p.communicate() | ||
env_var = 'GITLAB_SECRET_FILE_QUAY_CREDENTIALS' | ||
|
||
try: | ||
keys = json.loads(json.loads(stdout)['SecretString']) | ||
if env_var not in os.environ: | ||
print('Error: could not find environment variable ' + env_var) | ||
sys.exit(1) | ||
|
||
filename = os.environ[env_var] | ||
|
||
if not os.path.exists(filename): | ||
print('Error: could not find file referenced by ' + env_var) | ||
sys.exit(1) | ||
|
||
print('Opening key file...') | ||
with open(filename, 'r') as cred_json_file: | ||
print('Reading keys...') | ||
keys = json.loads(cred_json_file.read()) | ||
print('Read and decoded keys') | ||
|
||
print('Starting login process...') | ||
process = subprocess.Popen('docker login quay.io -u "{user}" --password-stdin'.format(user=keys['user']), | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, | ||
shell=True) | ||
print('Logging in...') | ||
stdout, stderr = process.communicate(input=keys['password']) | ||
if 'Login Succeeded' in stdout: | ||
print('Login Succeeded') | ||
else: | ||
raise RuntimeError | ||
except: | ||
print('While attempting to log into quay.io:\n' + str(stderr)) | ||
print('Error while attempting to log into quay.io:\n' + str(stderr)) | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import subprocess | ||
import json | ||
import os | ||
|
||
p = subprocess.Popen('aws secretsmanager --region us-west-2 get-secret-value --secret-id /toil/gitlab/ssh_key', | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
stdout, stderr = p.communicate() | ||
import subprocess | ||
import sys | ||
|
||
good_spot = os.path.expanduser('~/.ssh') | ||
os.mkdir(good_spot) | ||
|
||
try: | ||
keys = json.loads(json.loads(stdout)['SecretString']) | ||
with open(os.environ['GITLAB_SECRET_FILE_SSH_KEYS'], 'r') as keys_json_file: | ||
keys = json.loads(keys_json_file.read()) | ||
with open(os.path.join(good_spot, 'id_rsa.pub'), 'w') as f: | ||
f.write(keys['public']) | ||
with open(os.path.join(good_spot, 'id_rsa'), 'w') as f: | ||
f.write(keys['private']) | ||
except: | ||
print('While attempting to set up the ssh key:\n' + str(stderr)) | ||
print('While attempting to set up the ssh keys.') | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.