Skip to content

Feat: send input files ref to kcidb, add input files to maestro "artifacts" field #1140

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

Open
wants to merge 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
strategy:
matrix:
python-version:
- '3.7'
- '3.10'
- '3.13'

Expand Down
29 changes: 28 additions & 1 deletion src/lava_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

from base import validate_url


SETTINGS = toml.load(os.getenv('KCI_SETTINGS', 'config/kernelci.toml'))
CONFIGS = kernelci.config.load(
SETTINGS.get('DEFAULT', {}).get('yaml_config', 'config')
Expand All @@ -40,6 +39,24 @@
app = FastAPI()
executor = ThreadPoolExecutor(max_workers=16)

# Most common images used in LAVA deploy actions
# https://docs.lavasoftware.org/lava/actions-deploy.html#deploy-action-reference
input_file_types = [
'nfsrootfs',
'rootfs',
'ramdisk',
'initrd',
'initramfs',
'ndbroot',
'persistent_nfs',
'nfsrootfs',
'boot',
'boot_part',
'recovery_image',
'system',
'partition',
]


class ManualCheckout(BaseModel):
commit: str
Expand Down Expand Up @@ -211,6 +228,16 @@ def async_job_submit(api_helper, node_id, job_callback):
job_result = job_callback.get_job_status()
device_id = job_callback.get_device_id()
storage_config_name = job_callback.get_meta('storage_config_name')

if job_actions := job_callback.get_job_definition('actions'):
if deploy_images := job_actions[0].get('deploy', {}):
# Some LAVA deploy actions have images key, others directly
# have the input file types in the deploy dict
if "images" in deploy_images:
deploy_images = deploy_images.get('images')
for input_file in input_file_types:
if url := deploy_images.get(input_file, {}).get('url'):
job_node['artifacts']["input_"+input_file] = url
storage = _get_storage(storage_config_name)
log_txt_url = _upload_log(log_parser, job_node, storage)
if log_txt_url:
Expand Down
25 changes: 15 additions & 10 deletions src/send_kcidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,24 @@ def _parse_checkout_node(self, origin, checkout_node):
}
}]

def _get_output_files(self, artifacts: dict, exclude_properties=None):
output_files = []
def _filter_artifacts(self, artifacts: dict, exclude_properties=None,
include_properties=None):
filtered_artifacts = []
for name, url in artifacts.items():
if exclude_properties and name in exclude_properties:
if exclude_properties and any(prop in name for prop in exclude_properties):
continue
if include_properties and not any(prop in name for prop in include_properties):
continue
# Replace "/" with "_" to match with the allowed pattern
# for "name" property of "output_files" i.e. '^[^/]+$'
# for "name" property of "input_files" i.e. '^[^/]+$'
name = name.replace("/", "_")
output_files.append(
filtered_artifacts.append(
{
'name': name,
'url': url
}
)
return output_files
return filtered_artifacts

def _get_log_excerpt(self, log_url):
"""Parse compressed(gzip) or text log file and return last 16*1024 characters as it's
Expand Down Expand Up @@ -312,7 +315,6 @@ def _parse_build_node(self, origin, node):
artifacts=artifacts,
exclude_properties=('build_log', '_config')
)
parsed_build_node['input_files'] = None
parsed_build_node['config_url'] = artifacts.get('_config')
parsed_build_node['log_url'] = artifacts.get('build_log')
log_url = parsed_build_node['log_url']
Expand Down Expand Up @@ -537,11 +539,14 @@ def _parse_test_node(self, origin, test_node):

artifacts = self._get_artifacts(test_node)
if artifacts:
parsed_test_node['output_files'] = self._get_output_files(
parsed_test_node['input_files'] = self._filter_artifacts(
artifacts=artifacts,
include_properties=('input_')

Choose a reason for hiding this comment

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

Suggested change
include_properties=('input_')
include_properties=('input_',)

)
parsed_test_node['output_files'] = self._filter_artifacts(
artifacts=artifacts,
exclude_properties=('lava_log', 'test_log')
exclude_properties=('lava_log', 'test_log', 'input_')
)
parsed_test_node['input_files'] = None
if artifacts.get('lava_log'):
parsed_test_node['log_url'] = artifacts.get('lava_log')
else:
Expand Down