Skip to content
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

teuthology/suite/run.py: Improve ScheduleFail exception #1924

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docker-compose/start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -e -x
export TEUTHOLOGY_BRANCH=${TEUTHOLOGY_BRANCH:-$(git branch --show-current)}
export TEUTH_BRANCH=${TEUTHOLOGY_BRANCH}
if [ -n "$ANSIBLE_INVENTORY_REPO" ]; then
Expand Down
2 changes: 1 addition & 1 deletion docs/docker-compose/teuthology/teuthology.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -e
if [ -n "$SSH_PRIVKEY_FILE" ]; then
echo "$SSH_PRIVKEY" > $HOME/.ssh/$SSH_PRIVKEY_FILE
fi
source /teuthology/virtualenv/bin/activate
set -x
source /teuthology/virtualenv/bin/activate
if [ -n "$TESTNODES" ]; then
for node in $(echo $TESTNODES | tr , ' '); do
teuthology-update-inventory -m $MACHINE_TYPE $node
Expand Down
12 changes: 8 additions & 4 deletions teuthology/repo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ def ls_remote(url, ref):
"""
sha1 = None
cmd = "git ls-remote {} {}".format(url, ref)
result = subprocess.check_output(
cmd, shell=True).split()
if result:
sha1 = result[0].decode()
try:
result = subprocess.check_output(
cmd, stderr=subprocess.STDOUT,
shell=True).split()
if result:
sha1 = result[0].decode()
except subprocess.CalledProcessError as e:
raise GitError(e.output) from None
log.debug("{} -> {}".format(cmd, sha1))
return sha1

Expand Down
67 changes: 39 additions & 28 deletions teuthology/suite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from teuthology.suite.run import Run
from teuthology.suite.util import schedule_fail
from teuthology.exceptions import ScheduleFailError

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -51,33 +52,42 @@ def process_args(args):
key = key.lstrip('--').replace('-', '_')
# Rename the key if necessary
key = rename_args.get(key) or key
if key == 'suite_branch':
value = value or override_arg_defaults('--suite-branch', None)
if key == 'suite' and value is not None:
value = normalize_suite_name(value)
if key == 'suite_relpath' and value is None:
value = ''
elif key in ('limit', 'priority', 'num', 'newest', 'seed', 'job_threshold'):
value = int(value)
elif key == 'subset' and value is not None:
# take input string '2/3' and turn into (2, 3)
value = tuple(map(int, value.split('/')))
elif key in ('filter_all', 'filter_in', 'filter_out', 'rerun_statuses'):
if not value:
value = []
else:
value = [x.strip() for x in value.split(',')]
elif key == 'ceph_repo':
value = expand_short_repo_name(
value,
config.get_ceph_git_url())
elif key == 'suite_repo':
value = expand_short_repo_name(
value,
config.get_ceph_qa_suite_git_url())
elif key in ('validate_sha1', 'filter_fragments', 'kdb'):
value = strtobool(value)
conf[key] = value
try:
if key == 'suite_branch':
value = value or override_arg_defaults('--suite-branch', None)
if key == 'suite' and value is not None:
value = normalize_suite_name(value)
if key == 'suite_relpath' and value is None:
value = ''
elif key in ('limit', 'priority', 'num', 'newest', 'seed', 'job_threshold'):
value = int(value)
if key != 'seed' and value < 0:
log.error("{} value cannot be < 0".format(key))
raise ScheduleFailError("{} value cannot be < 0".format(key),'')
elif key == 'subset' and value is not None:
# take input string '2/3' and turn into (2, 3)
value = tuple(map(int, value.split('/')))
if len(value) != 2:
raise ValueError
elif key in ('filter_all', 'filter_in', 'filter_out', 'rerun_statuses'):
if not value:
value = []
else:
value = [x.strip() for x in value.split(',')]
elif key == 'ceph_repo':
value = expand_short_repo_name(
value,
config.get_ceph_git_url())
elif key == 'suite_repo':
value = expand_short_repo_name(
value,
config.get_ceph_qa_suite_git_url())
elif key in ('validate_sha1', 'filter_fragments'):
value = strtobool(value)
conf[key] = value
except ValueError:
log.error(" --{} value has incorrect type/format".format(key))
raise ScheduleFailError("--{} value has incorrect type/format".format(key),'')
return conf


Expand Down Expand Up @@ -142,10 +152,11 @@ def main(args):

run = Run(conf)
name = run.name
run.prepare_and_schedule()
job_count = run.prepare_and_schedule()
if not conf.dry_run and conf.wait:
return wait(name, config.max_job_time,
conf.archive_upload_url)
return job_count


def get_rerun_filters(name, statuses):
Expand Down
36 changes: 28 additions & 8 deletions teuthology/suite/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from teuthology.config import config, JobConfig
from teuthology.exceptions import (
BranchMismatchError, BranchNotFoundError, CommitNotFoundError,
ScheduleFailError, GitError
)
from teuthology.misc import deep_merge, get_results_url
from teuthology.orchestra.opsys import OS
Expand Down Expand Up @@ -103,8 +104,14 @@ def create_initial_config(self):


if self.args.distro_version:
self.args.distro_version, _ = \
OS.version_codename(self.args.distro, self.args.distro_version)
try:
self.args.distro_version, _ = \
OS.version_codename(self.args.distro, self.args.distro_version)
except KeyError:
raise ScheduleFailError(
" ditro: {} or distro_version: {} doesn't exists".format(
self.args.distro, self.args.distro_version),''
)
self.config_input = dict(
suite=self.args.suite,
suite_branch=suite_branch,
Expand All @@ -129,8 +136,11 @@ def choose_os(self):
os_type = self.args.distro
os_version = self.args.distro_version
if not (os_type and os_version):
os_ = util.get_distro_defaults(
self.args.distro, self.args.machine_type)[2]
try:
os_ = util.get_distro_defaults(
self.args.distro, self.args.machine_type)[2]
except KeyError:
raise ScheduleFailError(f"distro {self.args.distro} doesn't exist")
else:
os_ = OS(os_type, os_version)
return os_
Expand Down Expand Up @@ -190,8 +200,11 @@ def choose_ceph_hash(self):
log.info("ceph sha1 explicitly supplied")

elif self.args.ceph_branch:
ceph_hash = util.git_ls_remote(
self.args.ceph_repo, self.args.ceph_branch)
try:
ceph_hash = util.git_ls_remote(
self.args.ceph_repo, self.args.ceph_branch)
except GitError as e:
raise util.schedule_fail(message=str(e), name=self.name, dry_run=self.args.dry_run) from None
if not ceph_hash:
exc = BranchNotFoundError(
self.args.ceph_branch,
Expand Down Expand Up @@ -440,6 +453,8 @@ def prepare_and_schedule(self):
if num_jobs:
self.write_result()

return num_jobs

def collect_jobs(self, arch, configs, newest=False, limit=0):
jobs_to_schedule = []
jobs_missing_packages = []
Expand Down Expand Up @@ -579,8 +594,11 @@ def schedule_suite(self):
self.suite_repo_path,
self.args.suite_relpath,
'suites',
self.base_config.suite.replace(':', '/'),
suite_name.replace(':', '/'),
))
if not os.path.exists(suite_path):
log.error("Suite path doesn't exists")
raise ScheduleFailError("Suite path doesn't exists", suite_name)
log.debug('Suite %s in %s' % (suite_name, suite_path))
log.debug(f"subset = {self.args.subset}")
log.debug(f"no_nested_subset = {self.args.no_nested_subset}")
Expand Down Expand Up @@ -656,7 +674,9 @@ def schedule_suite(self):
if not sha1s:
sha1s = util.find_git_parents('ceph', str(self.base_config.sha1), self.args.newest)
if not sha1s:
util.schedule_fail('Backtrack for --newest failed', name, dry_run=self.args.dry_run)
util.schedule_fail('Backtrack for --newest failed, could not find a git parent with the packages,' \
' (optionally) use --sha1 to directly point to' \
' your build.', name, dry_run=self.args.dry_run)
self.config_input['ceph_hash'] = sha1s.pop(0)
self.base_config = self.build_base_config()
backtrack += 1
Expand Down
2 changes: 1 addition & 1 deletion teuthology/suite/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def get_sha1s(project, committish, count):
if len(sha1s) != count:
log.debug('got response: %s', resp.json())
log.error('can''t find %d parents of %s in %s: %s',
int(count), sha1, project, resp.json()['error'])
int(count), sha1, project, resp.json())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return sha1s

# index 0 will be the commit whose parents we want to find.
Expand Down