Skip to content

Commit

Permalink
Add detailed log for source containers with missing components situat…
Browse files Browse the repository at this point in the history
…ion. (#86)

use join print missing component log
  • Loading branch information
RichardXuan authored Dec 12, 2022
1 parent e95dd24 commit eda3c2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
17 changes: 14 additions & 3 deletions openlcs/libs/sc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,14 @@ def get_remote_source_path(self, component, extra_src_dir):
# check PELC-4511, CLOUDBLD-3809, and OLCS-292.
source_path = self.get_special_component_path(
component, extra_src_dir)
return source_path
return source_path, search_patterns

def get_container_remote_source(self, components):
"""
Get remote source in source container.
"""
missing_components = []
missing_components_error = []
extra_src_dir = os.path.join(self.dest_dir, 'extra_src_dir')

if os.path.exists(extra_src_dir):
Expand All @@ -405,10 +406,16 @@ def get_container_remote_source(self, components):
# Get source for each component.
for _ in range(len(components)):
component = components.pop(0)
comp_path = self.get_remote_source_path(
comp_path, search_patterns = self.get_remote_source_path(
component, extra_src_dir)
if not comp_path:
missing_components.append(component)
err_msg = (f"Failed to get remote source for component."
f"Error info:can not find source tarball path,"
f" search path:{extra_src_dir}, search patterns"
f":{search_patterns}.Component info:"
f"{component}")
missing_components_error.append(err_msg)
continue

# Create a directory to store remote source tarball.
Expand Down Expand Up @@ -451,6 +458,10 @@ def get_container_remote_source(self, components):
misc_dir = os.path.join(self.dest_dir, 'metadata')
shutil.move(extra_src_dir, misc_dir)
else:
err_msg = (f"Failed to get remote source for components."
f"Error info: extra_src_dir:{extra_src_dir} not exist."
f"Components info:{components}")
missing_components_error.append(err_msg)
missing_components = components

return missing_components
return missing_components, missing_components_error
8 changes: 3 additions & 5 deletions openlcsd/flow/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,10 @@ def get_container_remote_source(context, engine):
type_components = components.get(comp_type)
if type_components:
rs_components.extend(type_components)
missing_components = sc_handler.get_container_remote_source(
rs_components)
missing_components, missing_components_errors = \
sc_handler.get_container_remote_source(rs_components)
if missing_components:
engine.logger.error('Failed to get remote source for components:')
for missing_component in missing_components:
engine.logger.error(missing_component)
engine.logger.error("\n".join(missing_components_errors))
context['missing_components'] = missing_components

# Redefine the 'rs_dir' after collate remote source.
Expand Down

0 comments on commit eda3c2d

Please sign in to comment.