You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/04/23 17:04:54 UTC
[2/5] ambari git commit: AMBARI-10696. Prevent the "Make Current"
operation on a historical config with an incompatible stack (alexantonenko)
AMBARI-10696. Prevent the "Make Current" operation on a historical config with an incompatible stack (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5ab5f3f7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5ab5f3f7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5ab5f3f7
Branch: refs/heads/trunk
Commit: 5ab5f3f779620865bbf245f7a69b41b7d790c425
Parents: f333a78
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Apr 23 15:41:17 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Apr 23 18:04:49 2015 +0300
----------------------------------------------------------------------
.../data/configurations/service_versions.json | 52 +++++++++++---------
.../mappers/service_config_version_mapper.js | 3 +-
.../models/configs/service_config_version.js | 4 ++
ambari-web/app/styles/config_history_flow.less | 14 ++----
.../common/configs/config_history_flow.hbs | 8 +--
.../common/configs/service_version_box.hbs | 2 +-
ambari-web/app/utils/ajax/ajax.js | 2 +-
.../configs/service_config_version_test.js | 35 +++++++++++++
8 files changed, 80 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/assets/data/configurations/service_versions.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/configurations/service_versions.json b/ambari-web/app/assets/data/configurations/service_versions.json
index 5b30903..c5eb46c 100644
--- a/ambari-web/app/assets/data/configurations/service_versions.json
+++ b/ambari-web/app/assets/data/configurations/service_versions.json
@@ -8,7 +8,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "ganglia-env",
"tag" : "version1414410959005",
@@ -36,7 +36,8 @@
"service_config_version_note" : "Initial configurations for Ganglia",
"service_name" : "GANGLIA",
"user" : "admin",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6",
+ "is_cluster_compatible": true
},
{
"href" : "http://192.168.56.101:8080/api/v1/clusters/tdk/configurations/service_config_versions?service_name=HDFS&service_config_version=2",
@@ -45,7 +46,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "core-site",
"tag" : "version1",
@@ -75,7 +76,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hadoop-policy",
"tag" : "version1",
@@ -97,7 +98,8 @@
},
{
"Config" : {
- "cluster_name" : "tdk"
+ "cluster_name" : "tdk",
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hdfs-log4j",
"tag" : "version1",
@@ -110,7 +112,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hdfs-site",
"tag" : "version1",
@@ -173,7 +175,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hadoop-env",
"tag" : "version1414314983497",
@@ -206,7 +208,8 @@
"service_config_version_note" : "",
"service_name" : "HDFS",
"user" : "admin",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5",
+ "is_cluster_compatible": false
},
{
"href" : "http://192.168.56.101:8080/api/v1/clusters/tdk/configurations/service_config_versions?service_name=HDFS&service_config_version=1",
@@ -215,7 +218,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hadoop-env",
"tag" : "version1",
@@ -241,7 +244,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hdfs-log4j",
"tag" : "version1",
@@ -254,7 +257,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hdfs-site",
"tag" : "version1",
@@ -317,7 +320,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "hadoop-policy",
"tag" : "version1",
@@ -340,7 +343,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5"
},
"type" : "core-site",
"tag" : "version1",
@@ -377,7 +380,8 @@
"service_config_version_note" : "Initial configurations for HDFS",
"service_name" : "HDFS",
"user" : "admin",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.5",
+ "is_cluster_compatible": false
},
{
"href" : "http://192.168.56.101:8080/api/v1/clusters/tdk/configurations/service_config_versions?service_name=HDFS&service_config_version=3",
@@ -386,7 +390,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "hadoop-env",
"tag" : "version1414314983497",
@@ -412,7 +416,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "hadoop-policy",
"tag" : "version1",
@@ -435,7 +439,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "hdfs-log4j",
"tag" : "version1",
@@ -448,7 +452,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "hdfs-site",
"tag" : "version1",
@@ -511,7 +515,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "core-site",
"tag" : "version1414410959005",
@@ -548,7 +552,8 @@
"service_config_version_note" : null,
"service_name" : "HDFS",
"user" : "admin",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6",
+ "is_cluster_compatible": true
},
{
"href" : "http://192.168.56.101:8080/api/v1/clusters/tdk/configurations/service_config_versions?service_name=ZOOKEEPER&service_config_version=1",
@@ -557,7 +562,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "zookeeper-env",
"tag" : "version1",
@@ -578,7 +583,7 @@
{
"Config" : {
"cluster_name" : "tdk",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6"
},
"type" : "zookeeper-log4j",
"tag" : "version1",
@@ -598,7 +603,8 @@
"service_config_version_note" : "Initial configurations for ZooKeeper",
"service_name" : "ZOOKEEPER",
"user" : "admin",
- "stack_id": "HDP-2.0.6"
+ "stack_id" : "HDP-2.0.6",
+ "is_cluster_compatible": true
}
]
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/mappers/service_config_version_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_config_version_mapper.js b/ambari-web/app/mappers/service_config_version_mapper.js
index fbec4dc..2935cfa 100644
--- a/ambari-web/app/mappers/service_config_version_mapper.js
+++ b/ambari-web/app/mappers/service_config_version_mapper.js
@@ -32,7 +32,8 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({
notes: 'service_config_version_note',
is_current: 'is_current',
index: 'index',
- stack_version: 'stack_id'
+ stack_version: 'stack_id',
+ is_compatible: 'is_cluster_compatible'
},
map: function (json) {
var result = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/models/configs/service_config_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/service_config_version.js b/ambari-web/app/models/configs/service_config_version.js
index 7c864dd..fcaa45c 100644
--- a/ambari-web/app/models/configs/service_config_version.js
+++ b/ambari-web/app/models/configs/service_config_version.js
@@ -38,6 +38,10 @@ App.ServiceConfigVersion = DS.Model.extend({
isCurrent: DS.attr('boolean'),
isDisplayed: DS.attr('boolean'),
stackVersion: DS.attr('string'),
+ isCompatible: DS.attr('boolean'),
+ canBeMadeCurrent: function () {
+ return this.get('isCompatible') && !this.get('isCurrent');
+ }.property('isCurrent', 'isCompatible'),
isDefault: function() {
return this.get('groupName') === 'default';
}.property('groupName'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/styles/config_history_flow.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/config_history_flow.less b/ambari-web/app/styles/config_history_flow.less
index ad34696..f62e995 100644
--- a/ambari-web/app/styles/config_history_flow.less
+++ b/ambari-web/app/styles/config_history_flow.less
@@ -120,11 +120,8 @@
white-space: nowrap;
}
}
- .version-operations-buttons {
- text-align: center;
- .btn {
- font-size: 13px;
- }
+ .version-operations-buttons .btn {
+ font-size: 13px;
}
}
.version-box:hover{
@@ -286,11 +283,8 @@
white-space: pre-wrap;
}
}
- .version-operations-buttons {
- text-align: center;
- .btn {
- font-size: 13px;
- }
+ .version-operations-buttons .btn {
+ font-size: 13px;
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/templates/common/configs/config_history_flow.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/config_history_flow.hbs b/ambari-web/app/templates/common/configs/config_history_flow.hbs
index 866ee11..d6fae10 100644
--- a/ambari-web/app/templates/common/configs/config_history_flow.hbs
+++ b/ambari-web/app/templates/common/configs/config_history_flow.hbs
@@ -48,7 +48,7 @@
<strong>{{view.compareServiceVersion.createdDate}}</strong>
</div>
<div class="pull-right operations-button">
- <button class="btn btn-success" {{action doAction view.serviceVersionsReferences.compare view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.compareServiceVersion.isCurrent:hidden"}}>{{view.compareServiceVersion.makeCurrentButtonText}}</button>
+ <button class="btn btn-success" {{action doAction view.serviceVersionsReferences.compare view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.compareServiceVersion.canBeMadeCurrent::hidden"}}>{{view.compareServiceVersion.makeCurrentButtonText}}</button>
</div>
</div>
</div>
@@ -80,8 +80,8 @@
<div class="version-operations-buttons">
<button {{bindAttr disabled="serviceVersion.disabledActionAttr.view" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.view"}} {{action doAction serviceVersion view.actionTypes.SWITCH target="view"}}><i class="icon-search"></i> {{t common.view}}</button>
{{#isAccessible MANAGER}}
- <button {{bindAttr disabled="serviceVersion.disabledActionAttr.compare" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.compare"}} {{action doAction serviceVersion view.actionTypes.COMPARE target="view"}}><i class="icon-copy"></i> {{t common.compare}}</button>
- <button {{bindAttr disabled="serviceVersion.disabledActionAttr.revert" class=":btn serviceVersion.isCurrent:not-allowed-cursor" title="serviceVersion.disabledActionMessages.revert"}} {{action doAction serviceVersion view.actionTypes.REVERT target="view"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
+ <button {{bindAttr disabled="serviceVersion.disabledActionAttr.compare" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.compare"}} {{action doAction serviceVersion view.actionTypes.COMPARE target="view"}}><i class="icon-copy"></i> {{t common.compare}}</button>
+ <button {{bindAttr disabled="serviceVersion.disabledActionAttr.revert" class=":btn serviceVersion.isCurrent:not-allowed-cursor serviceVersion.isCompatible::hidden" title="serviceVersion.disabledActionMessages.revert"}} {{action doAction serviceVersion view.actionTypes.REVERT target="view"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
{{/isAccessible}}
</div>
</ul>
@@ -114,7 +114,7 @@
<button class="btn" {{action doCancel target="controller"}} {{bindAttr disabled="view.isDiscardDisabled"}}>{{t common.discard}}</button>
<button class="btn btn-success" {{action save target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t common.save}}</button>
</div>
- <button class="btn btn-success" {{action doAction view.serviceVersionsReferences.displayed view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.displayedServiceVersion.isCurrent:hidden"}}>{{view.displayedServiceVersion.makeCurrentButtonText}}</button>
+ <button class="btn btn-success" {{action doAction view.serviceVersionsReferences.displayed view.actionTypes.REVERT target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.displayedServiceVersion.canBeMadeCurrent::hidden"}}>{{view.displayedServiceVersion.makeCurrentButtonText}}</button>
</div>
{{/isAccessible}}
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/templates/common/configs/service_version_box.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/service_version_box.hbs b/ambari-web/app/templates/common/configs/service_version_box.hbs
index 132a8ab..72127ef 100644
--- a/ambari-web/app/templates/common/configs/service_version_box.hbs
+++ b/ambari-web/app/templates/common/configs/service_version_box.hbs
@@ -47,7 +47,7 @@
<button {{bindAttr disabled="serviceVersion.disabledActionAttr.view" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.view"}} {{action doAction serviceVersion view.actionTypes.SWITCH target="view.parentView"}}><i class="icon-search"></i> {{t common.view}}</button>
{{#isAccessible MANAGER}}
<button {{bindAttr disabled="serviceVersion.disabledActionAttr.compare" class=":btn serviceVersion.isDisplayed:not-allowed-cursor" title="serviceVersion.disabledActionMessages.compare"}} {{action doAction serviceVersion view.actionTypes.COMPARE target="view.parentView"}}><i class="icon-copy"></i> {{t common.compare}}</button>
- <button {{bindAttr disabled="serviceVersion.disabledActionAttr.revert" class=":btn serviceVersion.isCurrent:not-allowed-cursor" title="serviceVersion.disabledActionMessages.revert"}} {{action doAction serviceVersion view.actionTypes.REVERT target="view.parentView"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
+ <button {{bindAttr disabled="serviceVersion.disabledActionAttr.revert" class=":btn serviceVersion.isCurrent:not-allowed-cursor serviceVersion.isCompatible::hidden" title="serviceVersion.disabledActionMessages.revert"}} {{action doAction serviceVersion view.actionTypes.REVERT target="view.parentView"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
{{/isAccessible}}
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 21dc116..18beeb1 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2302,7 +2302,7 @@ var urls = {
}
},
'service.serviceConfigVersions.get': {
- real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&fields=service_config_version,user,hosts,group_id,group_name,is_current,createtime,service_name,service_config_version_note,stack_id&minimal_response=true',
+ real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&fields=service_config_version,user,hosts,group_id,group_name,is_current,createtime,service_name,service_config_version_note,stack_id,is_cluster_compatible&minimal_response=true',
mock: '/data/configurations/service_versions.json'
},
'service.serviceConfigVersions.get.current': {
http://git-wip-us.apache.org/repos/asf/ambari/blob/5ab5f3f7/ambari-web/test/models/configs/service_config_version_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/service_config_version_test.js b/ambari-web/test/models/configs/service_config_version_test.js
index fbddcb8..e721890 100644
--- a/ambari-web/test/models/configs/service_config_version_test.js
+++ b/ambari-web/test/models/configs/service_config_version_test.js
@@ -51,4 +51,39 @@ describe('App.ServiceConfigVersion', function () {
});
+ describe('#canBeMadeCurrent', function () {
+
+ var cases = [
+ {
+ isCompatible: true,
+ isCurrent: true,
+ canBeMadeCurrent: false,
+ title: 'current version'
+ },
+ {
+ isCompatible: true,
+ isCurrent: false,
+ canBeMadeCurrent: true,
+ title: 'compatible version'
+ },
+ {
+ isCompatible: false,
+ isCurrent: false,
+ canBeMadeCurrent: false,
+ title: 'not compatible version'
+ }
+ ];
+
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ model.setProperties({
+ isCompatible: item.isCompatible,
+ isCurrent: item.isCurrent
+ });
+ expect(model.get('canBeMadeCurrent')).to.equal(item.canBeMadeCurrent);
+ });
+ });
+
+ });
+
});