Skip to content

Commit

Permalink
Avoid triggering spurious HTTP request of all jenkins jobs.
Browse files Browse the repository at this point in the history
There's a malinteraction with the jenkinsapi library and Python
convention which has been causing extremely large HTTP requests whenever
the truthiness of an instance of the Jenkins class is tested.

Jenkins defines a `__len__` method which is used to determine
truthiness. But this method triggers a fetch of every job on our Jenkins
host which can take 2 - 5 minutes to return due to the sheer volume of
jobs.

By avoiding this in favor of an explicit check whether jenkins is an
instance of the JenkinsProxy class we can save taking a really big
runtime hit and cut down on spurious failures due to timeouts.
  • Loading branch information
nuclearsandwich committed Apr 27, 2024
1 parent b15a01f commit 60131b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ros_buildfarm/ci_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ros_buildfarm.config import get_ci_build_files
from ros_buildfarm.config import get_index as get_config_index
from ros_buildfarm.git import get_repository
from ros_buildfarm.jenkins import JenkinsProxy
from ros_buildfarm.templates import expand_template
from rosdistro import get_index

Expand Down Expand Up @@ -80,7 +81,7 @@ def _configure_ci_jobs(
ci_view_name: configure_ci_view(
jenkins, ci_view_name, dry_run=dry_run)
}
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
view_configs.update(views)
groovy_data = {
'dry_run': dry_run,
Expand Down
3 changes: 2 additions & 1 deletion ros_buildfarm/devel_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ros_buildfarm.config import get_index as get_config_index
from ros_buildfarm.config import get_source_build_files
from ros_buildfarm.git import get_repository
from ros_buildfarm.jenkins import JenkinsProxy
from ros_buildfarm.templates import expand_template
from rosdistro import get_distribution_cache
from rosdistro import get_index
Expand Down Expand Up @@ -90,7 +91,7 @@ def configure_devel_jobs(
if build_file.test_pull_requests_force is not False:
views[pull_request_view_name] = configure_devel_view(
jenkins, pull_request_view_name, dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins,JenkinsProxy):
view_configs.update(views)
groovy_data = {
'dry_run': dry_run,
Expand Down
3 changes: 2 additions & 1 deletion ros_buildfarm/doc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ros_buildfarm.config import get_global_doc_build_files
from ros_buildfarm.config import get_index as get_config_index
from ros_buildfarm.git import get_repository
from ros_buildfarm.jenkins import JenkinsProxy
from ros_buildfarm.templates import expand_template
from rosdistro import get_distribution_cache
from rosdistro import get_index
Expand Down Expand Up @@ -83,7 +84,7 @@ def configure_doc_jobs(
views = {}
views[doc_view_name] = configure_doc_view(
jenkins, doc_view_name, dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
view_configs.update(views)
groovy_data = {
'dry_run': dry_run,
Expand Down
2 changes: 1 addition & 1 deletion ros_buildfarm/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def configure_view(
view_config = get_view_config(
template_name, view_name, include_regex=include_regex,
filter_queue=filter_queue)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
_cached_views[key] = view_config
return view_config
view_type = _get_view_type(view_config)
Expand Down
9 changes: 5 additions & 4 deletions ros_buildfarm/release_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from ros_buildfarm.config import get_distribution_file
from ros_buildfarm.config import get_index as get_config_index
from ros_buildfarm.config import get_release_build_files
from ros_buildfarm.jenkins import JenkinsProxy
from ros_buildfarm.git import get_repository
from ros_buildfarm.package_repo import get_package_repo_data
from ros_buildfarm.templates import expand_template
Expand Down Expand Up @@ -144,14 +145,14 @@ def configure_release_jobs(
job_name, job_config = configure_import_package_job(
config_url, rosdistro_name, release_build_name,
config=config, build_file=build_file, jenkins=jenkins, dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
all_job_configs[job_name] = job_config
break

job_name, job_config = configure_sync_packages_to_main_job(
config_url, rosdistro_name, release_build_name,
config=config, build_file=build_file, jenkins=jenkins, dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
all_job_configs[job_name] = job_config

for os_name, os_code_name in platforms:
Expand All @@ -161,7 +162,7 @@ def configure_release_jobs(
os_name, os_code_name, arch,
config=config, build_file=build_file, jenkins=jenkins,
dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
all_job_configs[job_name] = job_config

targets = []
Expand All @@ -172,7 +173,7 @@ def configure_release_jobs(
views = configure_release_views(
jenkins, rosdistro_name, release_build_name, targets,
dry_run=dry_run)
if not jenkins:
if not isinstance(jenkins, JenkinsProxy):
all_view_configs.update(views)
groovy_data = {
'dry_run': dry_run,
Expand Down

0 comments on commit 60131b7

Please sign in to comment.