Procházet zdrojové kódy

AMBARI-12635. If the "current" stack version status is OUT_OF_SYNC, no version box is displayed on Admin > Stacks > Version page (dlysnichenko)

Lisnichenko Dmitro před 10 roky
rodič
revize
1a4ad49566

+ 2 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java

@@ -1250,6 +1250,8 @@ public class ClusterImpl implements Cluster {
     }
 
     // Also returns when have a mix of CURRENT and INSTALLING|INSTALLED|UPGRADING|UPGRADED
+    LOG.warn("have a mix of CURRENT and INSTALLING|INSTALLED|UPGRADING|UPGRADED host versions, " +
+            "returning OUT_OF_SYNC as cluster version. Host version states: " + stateToHosts.toString());
     return RepositoryVersionState.OUT_OF_SYNC;
   }
 

+ 1 - 1
ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js

@@ -131,7 +131,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       element.set('text', Em.I18n.t('hosts.host.stackVersions.status.installing'));
       element.set('action', 'showProgressPopup');
     } else if (status === 'INSTALLED' && !this.get('isUpgrading')) {
-      if (stringUtils.compareVersions(this.get('content.repositoryVersion'), currentVersion.repository_version) === 1) {
+      if (stringUtils.compareVersions(this.get('content.repositoryVersion'), Em.get(currentVersion, 'repository_version')) === 1) {
         var isDisabled = !App.isAccessible('ADMIN') || this.get('controller.requestInProgress') || isInstalling;
         element.set('isButtonGroup', true);
         element.set('text', Em.I18n.t('admin.stackVersions.version.performUpgrade'));

+ 1 - 1
ambari-web/app/views/main/admin/stack_upgrade/versions_view.js

@@ -153,7 +153,7 @@ App.MainAdminStackVersionsView = Em.View.extend({
         }
       }, this);
     }
-    if (App.get('supports.displayOlderVersions')) {
+    if (App.get('supports.displayOlderVersions') || Em.isNone(currentVersion)) {
       return versions.toArray();
     } else {
       return versions.filter(function(v) {

+ 171 - 147
ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js

@@ -32,166 +32,190 @@ describe('App.mainAdminStackVersionsView', function () {
 
   describe("#filterBy()", function () {
     var versions = [
-      Em.Object.create({
-        status: "INIT",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "INSTALLING",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "INSTALLED",
-        repositoryVersion: "2.2.0.1"
-      }),
-      Em.Object.create({
-        status: "INSTALLED",
-        repositoryVersion: "2.2.2.1"
-      }),
-      Em.Object.create({
-        status: "INSTALL_FAILED",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "OUT_OF_SYNC",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "UPGRADING",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "UPGRADED",
-        repositoryVersion: "2.2.1.1"
-      }),
-      Em.Object.create({
-        status: "CURRENT",
-        repositoryVersion: "2.2.1.1"
-      })
-    ];
-
-    var testCases = [
-      {
-        filter:  Em.Object.create({
-          value: ''
+        Em.Object.create({
+          status: "INIT",
+          repositoryVersion: "2.2.1.1"
         }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "INIT",
-            repositoryVersion: "2.2.1.1"
-          }),
-          Em.Object.create({
-            status: "INSTALLING",
-            repositoryVersion: "2.2.1.1"
+        Em.Object.create({
+          status: "INSTALLING",
+          repositoryVersion: "2.2.1.1"
+        }),
+        Em.Object.create({
+          status: "INSTALLED",
+          repositoryVersion: "2.2.0.1"
+        }),
+        Em.Object.create({
+          status: "INSTALLED",
+          repositoryVersion: "2.2.2.1"
+        }),
+        Em.Object.create({
+          status: "INSTALL_FAILED",
+          repositoryVersion: "2.2.1.1"
+        }),
+        Em.Object.create({
+          status: "OUT_OF_SYNC",
+          repositoryVersion: "2.2.1.1"
+        }),
+        Em.Object.create({
+          status: "UPGRADING",
+          repositoryVersion: "2.2.1.1"
+        }),
+        Em.Object.create({
+          status: "UPGRADED",
+          repositoryVersion: "2.2.1.1"
+        }),
+        Em.Object.create({
+          status: "CURRENT",
+          repositoryVersion: "2.2.1.1"
+        })
+      ],
+      testCases = [
+        {
+          filter:  Em.Object.create({
+            value: ''
           }),
-          Em.Object.create({
-            status: "INSTALLED",
-            repositoryVersion: "2.2.2.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "INIT",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "INSTALLING",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "INSTALLED",
+              repositoryVersion: "2.2.2.1"
+            }),
+            Em.Object.create({
+              status: "INSTALL_FAILED",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "OUT_OF_SYNC",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "UPGRADING",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "UPGRADED",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "CURRENT",
+              repositoryVersion: "2.2.1.1"
+            })
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'NOT_INSTALLED'
           }),
-          Em.Object.create({
-            status: "INSTALL_FAILED",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "INIT",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "INSTALLING",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "INSTALL_FAILED",
+              repositoryVersion: "2.2.1.1"
+            }),
+            Em.Object.create({
+              status: "OUT_OF_SYNC",
+              repositoryVersion: "2.2.1.1"
+            })
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'INSTALLED'
           }),
-          Em.Object.create({
-            status: "OUT_OF_SYNC",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'UPGRADE_READY'
           }),
-          Em.Object.create({
-            status: "UPGRADING",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "INSTALLED",
+              repositoryVersion: "2.2.2.1"
+            })
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'CURRENT'
           }),
-          Em.Object.create({
-            status: "UPGRADED",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "CURRENT",
+              repositoryVersion: "2.2.1.1"
+            })
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'UPGRADING'
           }),
-          Em.Object.create({
-            status: "CURRENT",
-            repositoryVersion: "2.2.1.1"
-          })
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'NOT_INSTALLED'
-        }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "INIT",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "UPGRADING",
+              repositoryVersion: "2.2.1.1"
+            })
+          ]
+        },
+        {
+          filter:  Em.Object.create({
+            value: 'UPGRADED'
           }),
-          Em.Object.create({
-            status: "INSTALLING",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: [
+            Em.Object.create({
+              status: "UPGRADED",
+              repositoryVersion: "2.2.1.1"
+            })
+          ]
+        },
+        {
+          noCurrentVersion: true,
+          filter:  Em.Object.create({
+            value: ''
           }),
-          Em.Object.create({
-            status: "INSTALL_FAILED",
-            repositoryVersion: "2.2.1.1"
+          filteredVersions: versions,
+          message: 'no current version'
+        },
+        {
+          displayOlderVersions: true,
+          filter:  Em.Object.create({
+            value: ''
           }),
-          Em.Object.create({
-            status: "OUT_OF_SYNC",
-            repositoryVersion: "2.2.1.1"
-          })
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'INSTALLED'
-        }),
-        filteredVersions: [
+          filteredVersions: versions,
+          message: 'display older versions'
+        }
+      ];
 
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'UPGRADE_READY'
-        }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "INSTALLED",
-            repositoryVersion: "2.2.2.1"
-          })
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'CURRENT'
-        }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "CURRENT",
-            repositoryVersion: "2.2.1.1"
-          })
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'UPGRADING'
-        }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "UPGRADING",
-            repositoryVersion: "2.2.1.1"
-          })
-        ]
-      },
-      {
-        filter:  Em.Object.create({
-          value: 'UPGRADED'
-        }),
-        filteredVersions: [
-          Em.Object.create({
-            status: "UPGRADED",
-            repositoryVersion: "2.2.1.1"
-          })
-        ]
-      }
-    ].forEach(function(t) {
-        var msg = t.filter.get('value') ? t.filter.get('value') : "All";
-        it("filter By " + msg, function () {
-          view.set('controller.currentVersion', {repository_version: '2.2.1.1'});
-          expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
+    afterEach(function () {
+      App.get.restore();
+    });
+
+    testCases.forEach(function(t) {
+      var msg = t.filter.get('value') ? t.filter.get('value') : "All";
+      it(t.message || "filter By " + msg, function () {
+        sinon.stub(App, 'get', function (key) {
+          return key == 'supports.displayOlderVersions' ? Boolean(t.displayOlderVersions) : Em.get(App, key);
         });
+        view.set('controller.currentVersion', t.noCurrentVersion ? null : {repository_version: '2.2.1.1'});
+        expect(view.filterBy(versions, t.filter)).to.eql(t.filteredVersions);
       });
+    });
   });
 
   describe("#didInsertElement()", function() {