Browse Source

AMBARI-12594. RU- 2.3 - 2.3 + - NFS jars are not upgraded and refer to old version after the upgrade (dlysnichenko)

Lisnichenko Dmitro 9 years ago
parent
commit
5cfe6d60d0

+ 9 - 2
ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/nfsgateway.py

@@ -24,6 +24,9 @@ from resource_management.libraries.functions.security_commons import build_expec
   FILE_TYPE_XML
 from hdfs_nfsgateway import nfsgateway
 from hdfs import hdfs
+from resource_management.libraries.functions import conf_select
+from resource_management.libraries.functions import hdp_select
+from resource_management.libraries.functions.version import compare_versions, format_hdp_stack_version
 
 
 class NFSGateway(Script):
@@ -39,8 +42,12 @@ class NFSGateway(Script):
     self.install_packages(env, params.exclude_packages)
 
   def pre_rolling_restart(self, env):
-    # it does not need any Rolling Restart logic.
-    pass
+    import params
+    env.set_params(params)
+
+    if Script.is_hdp_stack_greater_or_equal('2.3.0.0'):
+      conf_select.select(params.stack_name, "hadoop", params.version)
+      hdp_select.select("hadoop-hdfs-nfs3", params.version)
 
   def start(self, env, rolling_restart=False):
     import params

+ 7 - 0
ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml

@@ -137,6 +137,7 @@
       <service-check>false</service-check>
       <service name="HDFS">
         <component>DATANODE</component>
+        <component>NFS_GATEWAY</component>
       </service>
       
       <service name="HBASE">
@@ -396,6 +397,12 @@
         </upgrade>
       </component>
 
+      <component name="NFS_GATEWAY">
+        <upgrade>
+          <task xsi:type="restart" />
+        </upgrade>
+      </component>
+
       <component name="HDFS_CLIENT">
         <upgrade>
           <task xsi:type="restart" />

+ 23 - 0
ambari-server/src/test/python/stacks/2.0.6/HDFS/test_nfsgateway.py

@@ -18,6 +18,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 import os
+import json
 from stacks.utils.RMFTestCase import *
 from mock.mock import MagicMock, patch
 
@@ -380,3 +381,25 @@ class TestNFSGateway(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
     put_structured_out_mock.assert_called_with({"securityState": "UNSECURED"})
+    self.assertNoMoreResources()
+
+  @patch("resource_management.core.shell.call")
+  def test_pre_rolling_restart(self, call_mock):
+    call_mock.side_effects = [(0, None), (0, None)]
+    config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    with open(config_file, "r") as f:
+      json_content = json.load(f)
+    version = '2.3.1.0-3242'
+    json_content['commandParams']['version'] = version
+    stack_version = '2.3'
+    json_content['hostLevelParams']['stack_version'] = stack_version
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nfsgateway.py",
+                       classname = "NFSGateway",
+                       command = "pre_rolling_restart",
+                       config_dict = json_content,
+                       hdp_stack_version = self.STACK_VERSION,
+                       target = RMFTestCase.TARGET_COMMON_SERVICES,
+                       call_mocks = [(0, None), (0, None), (0, None), (0, None)])
+    self.assertResourceCalled('Execute',
+                              ('hdp-select', 'set', 'hadoop-hdfs-nfs3', version), sudo=True,)
+    self.assertNoMoreResources()