Skip to content

Commit

Permalink
Continues processing index upon failure processing entries
Browse files Browse the repository at this point in the history
  Updates the seed-job behavior to continue processing the index
  if it encounters exception while processing index.
  Earlier seed-job would stop processing index if exception occurred
  in between.
  • Loading branch information
navidshaikh committed Sep 7, 2018
1 parent 3ae99f0 commit 0507b94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ccp/index_reader.py
Expand Up @@ -131,8 +131,9 @@ def load_project_entry(self, entry):
self.pre_build_script = self.process_pre_build_script(
entry.get("prebuild-script", None))
except Exception as e:
print ("Error processing container index entry.")
raise(e)
print("Error processing container index entry {}. "
"Moving on".format(entry))
print("Error: {}".format(str(e)))

def get_pipeline_name(self):
"""
Expand Down Expand Up @@ -202,7 +203,12 @@ def read_projects(self):
app = self.read_yaml(yamlfile)
for entry in app['Projects']:
# create a project object here with all properties
project = Project(entry, self.namespace)
try:
project = Project(entry, self.namespace)
except Exception as e:
print("Error processing index entry {}. Moving on.".format(
entry))
print("Error: {}".format(e))
# append to the list of projects
projects.append(project)

Expand Down Expand Up @@ -444,7 +450,12 @@ def run(self):

# oc process and oc apply to all fresh and existing jobs
for project in index_projects:
self.bc_manager.apply_buildconfigs(project)
try:
self.bc_manager.apply_buildconfigs(project)
except Exception as e:
print("Error applying/creating build config for {}. "
"Moving on.".format(project.pipeline_name))
print("Error: {}".format(str(e)))


if __name__ == "__main__":
Expand Down
8 changes: 8 additions & 0 deletions tests/test_00_unit/test_00_index_reader/__init__.py
Expand Up @@ -144,6 +144,14 @@ def test_get_pipeline_name_3(self):
with self.assertRaises(index_reader.InvalidPipelineName):
index_reader.Project(self.entry, self.namespace)

def test_load_project_entry_failure_case(self):
"""
IndexReader: Tests exception while loading invalid index entry
"""
self.entry.pop("target-file")
with self.assertRaises(Exception):
index_reader.Project(self.entry, self.namespace)


if __name__ == "__main__":
unittest.main()

0 comments on commit 0507b94

Please sign in to comment.