You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/01/29 17:22:47 UTC

ambari git commit: AMBARI-9375. Safety meassures: autoremove only packages that have repo version at their name (dlysnichenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 78d0af1b8 -> aa2709676


AMBARI-9375. Safety meassures: autoremove only packages that have repo version at their name (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/aa270967
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/aa270967
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/aa270967

Branch: refs/heads/trunk
Commit: aa27096762ddab99f16b150ecb67e9c86bac74d1
Parents: 78d0af1
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Jan 29 17:50:15 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Jan 29 18:22:37 2015 +0200

----------------------------------------------------------------------
 .../custom_actions/scripts/install_packages.py        |  9 ++++++++-
 .../test/python/custom_actions/TestInstallPackages.py | 14 ++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aa270967/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
index 79ad99a..e401986 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
@@ -106,8 +106,15 @@ class InstallPackages(Script):
           packages_installed_after = [package[0] for package in packages_installed_after]
           packages_installed_before = set(packages_installed_before)
           new_packages_installed = [package for package in packages_installed_after if package not in packages_installed_before]
+
+          if OSCheck.is_ubuntu_family():
+            package_version_string = repository_version.replace('.', '-')
+          else:
+            package_version_string = repository_version.replace('-', '_')
+            package_version_string = package_version_string.replace('.', '_')
           for package in new_packages_installed:
-            Package(package, action="remove")
+            if package_version_string and (package_version_string in package):
+              Package(package, action="remove")
 
     # Build structured output
     structured_output = {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa270967/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 17ea63f..ad164e7 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -139,11 +139,14 @@ class TestInstallPackages(RMFTestCase):
 
   @staticmethod
   def _add_packages_with_fail(arg):
-    arg.append(["pkg1", "1.0", "repo"])
-    arg.append(["pkg2", "2.0", "repo2"])
+    arg.append(["pkg1_2_2_0_1_885_pack", "1.0", "repo"])
+    arg.append(["pkg2_2_2_0_1_885_pack2", "2.0", "repo2"])
     if TestInstallPackages._install_failed:
-      arg.append(["hadoop_2_2_fake_pkg", "1.0", "repo"])
-      arg.append(["snappy_fake_pkg", "3.0", "repo2"])
+      arg.append(["should_not_be_removed_pkg1", "1.0", "repo"])
+      arg.append(["hadoop_2_2_0_1_885fake_pkg", "1.0", "repo"])
+      arg.append(["snappy__2_2_0_1_885_fake_pkg", "3.0", "repo2"])
+      arg.append(["ubuntu-like-2-2-0-1-885-fake-pkg", "3.0", "repo2"])
+      arg.append(["should_not_be_removed_pkg2", "3.0", "repo2"])
 
   @staticmethod
   def _new_with_exception(cls, name, env=None, provider=None, **kwargs):
@@ -164,6 +167,7 @@ class TestInstallPackages(RMFTestCase):
     is_redhat_family_mock.return_value = True
     list_ambari_managed_repos_mock.return_value = []
     def side_effect(retcode):
+      TestInstallPackages._install_failed = True
       raise Exception()
     Package__mock.side_effect = side_effect
     self.assertRaises(Fail, self.executeScript, "scripts/install_packages.py",
@@ -196,6 +200,8 @@ class TestInstallPackages(RMFTestCase):
                               )
     self.assertNoMoreResources()
 
+    TestInstallPackages._install_failed = False
+
 
   @patch("ambari_commons.os_check.OSCheck.is_suse_family")
   @patch("resource_management.core.resources.packaging.Package")