#316 Handle clone_distgit_repo exception.
Merged 6 months ago by jkaluza. Opened 6 months ago by jkaluza.
jkaluza/freshmaker git-os-error  into  master

file modified
+6 -2

@@ -361,8 +361,12 @@ 

  

          prefix = "freshmaker-%s-%s-%s" % (namespace, name, commit)

          with temp_dir(prefix=prefix) as repodir:

-             clone_distgit_repo(namespace, name, repodir, commit=commit,

-                                ssh=False, logger=log)

+             try:

+                 clone_distgit_repo(namespace, name, repodir, commit=commit,

+                                    ssh=False, logger=log)

+             except OSError as e:

+                 self.log_error("Error while cloning dist-git repo: %s" % e)

+                 return data

  

              content_sets_path = os.path.join(repodir, "content_sets.yml")

              if not os.path.exists(content_sets_path):

file modified
+20

@@ -171,6 +171,26 @@ 

              helpers.AnyStringWith('freshmaker-rpms-foo-docker'),

              commit='commit', logger=log, ssh=False)

  

+     def test_generate_os_error(self):

+         self.clone_distgit_repo.side_effect = OSError(

+             "Got an error (128) from git: fatal: reference is not a tree: "

+             "4d42e2009cec70d871c65de821396cd750d523f1")

+ 

+         image = ContainerImage.create({"brew": {"build": "nvr"}})

+         ret = image._get_additional_data_from_distgit(

+             "rpms/foo-docker", "branch", "commit")

+         self.assertEqual(ret["generate_pulp_repos"], False)

+ 

+         self.assertEqual(

+             image["error"],

+             "Error while cloning dist-git repo: Got an error (128) from git: "

+             "fatal: reference is not a tree: 4d42e2009cec70d871c65de821396cd750d523f1")

+ 

+         self.clone_distgit_repo.assert_called_once_with(

+             'rpms', 'foo-docker',

+             helpers.AnyStringWith('freshmaker-rpms-foo-docker'),

+             commit='commit', logger=log, ssh=False)

+ 

      def test_generate_no_namespace(self):

          self.path_exists.return_value = True

          self.patched_open.side_effect = [

This exception can be handled in case the dist-git commit from which the container
image has been built does not exist in dist-git anymore. This is probably an issue
in the workflow or dist-git itself, but Freshmaker should handle that.

Before this commit, Freshmaker marked whole Event as failed.

After this commit, it will only mark particular container image build as failed, but
it will still rebuild the other images.

Pull-Request has been merged by jkaluza

6 months ago