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 2 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
18 changes: 17 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 Down Expand Up @@ -211,6 +210,23 @@ 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')
input_file_types = [
'nfsrootfs',
'rootfs',
'ramdisk',
'initrd',
'ndbroot',
'persistent_nfs'
]
job_actions = job_callback.get_job_definition('actions')
if job_actions and len(job_actions) > 0:
deploy = job_actions[0].get('deploy')
if deploy:
for input_file in input_file_types:
if deploy.get('images') and deploy['images'].get(input_file):
url = deploy['images'][input_file].get('url')
if 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
28 changes: 26 additions & 2 deletions src/send_kcidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,33 @@ def _parse_checkout_node(self, origin, checkout_node):
}
}]

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

def _get_output_files(self, artifacts: dict, exclude_properties=None):
output_files = []
for name, url in artifacts.items():
if exclude_properties and name in exclude_properties:
continue
if "input_" in name:
# Skip input files
continue
# Replace "/" with "_" to match with the allowed pattern
# for "name" property of "output_files" i.e. '^[^/]+$'
name = name.replace("/", "_")
Expand Down Expand Up @@ -312,7 +334,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 +558,14 @@ def _parse_test_node(self, origin, test_node):

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