From 03b831736af3913c068cc2dd9bbecf70d7e73d8c Mon Sep 17 00:00:00 2001 From: vimniky Date: Sat, 31 Mar 2018 18:49:38 +0800 Subject: [PATCH] Add Embedded ES resource quota configuration UI --- .../components/logging/new-edit/component.js | 14 ----- .../logging/target-embedded/component.js | 22 +++++++- .../logging/target-embedded/template.hbs | 56 +++++++++++++++++-- lib/logging/addon/logging/route.js | 1 - lib/logging/addon/mixins/logging-model.js | 11 ++-- lib/logging/translations/en-us.yaml | 14 +++++ 6 files changed, 92 insertions(+), 26 deletions(-) diff --git a/lib/logging/addon/components/logging/new-edit/component.js b/lib/logging/addon/components/logging/new-edit/component.js index 07fe16fcd..c5b0f2c34 100644 --- a/lib/logging/addon/components/logging/new-edit/component.js +++ b/lib/logging/addon/components/logging/new-edit/component.js @@ -129,19 +129,6 @@ export default Ember.Component.extend(NewOrEdit, { && get(this, 'targetType') === 'none'; }.property('originalModel.{id,targetType}', 'targetType'), - - validate() { - const targetType = get(this, 'targetType'); - const config = get(this, `primaryResource.${targetType}Config`); - const errors = config.validationErrors(); - if (errors.get('length')) { - set(this, 'errors', errors); - return false; - } - set(this, 'errors', null); - return true; - }, - actions: { save(cb) { const targetType = get(this, 'targetType'); @@ -198,7 +185,6 @@ export default Ember.Component.extend(NewOrEdit, { set(model, 'outputFlushInterval', get(model, `${targetType}.outputFlushInterval`)); set(model, 'outputTags', get(model, `${targetType}.outputTags`)); set(model, `${targetType}Config`, get(model, `${targetType}.config`)); - this._super(cb); }, }, diff --git a/lib/logging/addon/components/logging/target-embedded/component.js b/lib/logging/addon/components/logging/target-embedded/component.js index 52ae6ca8b..e51d6dad0 100644 --- a/lib/logging/addon/components/logging/target-embedded/component.js +++ b/lib/logging/addon/components/logging/target-embedded/component.js @@ -1,4 +1,24 @@ import Component from '@ember/component'; import es from 'logging/mixins/target-elasticsearch'; +import { get, set } from '@ember/object'; -export default Component.extend(es, {}); +export default Component.extend(es, { + + init() { + this._super(...arguments); + const requestsCpu = get(this, 'config.requestsCpu') || 1000; + const limitsCpu = get(this, 'config.limitsCpu'); + set(this, 'requestsCpu', requestsCpu / 1000); + set(this, 'limitsCpu', limitsCpu / 1000); + }, + + limitsCpuChanged: function() { + const requestsCpu = get(this, 'requestsCpu'); + set(this, 'config.requestsCpu', requestsCpu * 1000); + }.observes('requestsCpu'), + + limitsCpuChanged: function() { + const limitsCpu = get(this, 'limitsCpu'); + set(this, 'config.limitsCpu', limitsCpu * 1000); + }.observes('limitsCpu'), +}); diff --git a/lib/logging/addon/components/logging/target-embedded/template.hbs b/lib/logging/addon/components/logging/target-embedded/template.hbs index 1c37009fe..f280324f7 100644 --- a/lib/logging/addon/components/logging/target-embedded/template.hbs +++ b/lib/logging/addon/components/logging/target-embedded/template.hbs @@ -1,10 +1,58 @@

{{t 'loggingPage.embedded.header'}}


-
-

{{t 'loggingPage.embedded.indexPatterns.header'}}

-

{{t 'loggingPage.embedded.indexPatterns.helpText'}}

+
+

{{t 'loggingPage.embedded.resouceRequestsAndLimits'}}

+
+
+ + {{input-number + min=1 + type="number" + value=requestsCpu + className="form-control" + placeholder=(t 'loggingPage.embedded.cpuRequests.placeholder') + }} +
+
+ + {{input-number + min=1 + type="number" + value=limitsCpu + className="form-control" + placeholder=(t 'loggingPage.embedded.cpuLimits.placeholder') + }} +
+
+ +
+
+ + {{input-number + min=500 + type="number" + value=config.requestsMemory + className="form-control" + placeholder=(t 'loggingPage.embedded.memRequests.placeholder') + }} +
+ +
+ + {{input-number + min=1000 + type="number" + value=config.limitsMemory + className="form-control" + placeholder=(t 'loggingPage.embedded.memLimits.placeholder') + }} +
+
+ +

{{t 'loggingPage.embedded.indexPatterns.header'}}

+

{{t 'loggingPage.embedded.indexPatterns.helpText'}}

{{input @@ -21,7 +69,6 @@ -
{{t 'loggingPage.embedded.generatedIndex' esIndex=esIndex @@ -29,5 +76,4 @@ }}
-
{{logging/form-log-format logPreview=logPreview model=model}} \ No newline at end of file diff --git a/lib/logging/addon/logging/route.js b/lib/logging/addon/logging/route.js index 23ff6c8b1..f61a6e1a4 100644 --- a/lib/logging/addon/logging/route.js +++ b/lib/logging/addon/logging/route.js @@ -16,7 +16,6 @@ export default Route.extend({ const gs = get(this, 'globalStore'); const newLogging = gs.createRecord({ type: loggingType, - outputFlushInterval: 3, outputTags: {}, }); return newLogging; diff --git a/lib/logging/addon/mixins/logging-model.js b/lib/logging/addon/mixins/logging-model.js index 3ae117ad0..5d84475f1 100644 --- a/lib/logging/addon/mixins/logging-model.js +++ b/lib/logging/addon/mixins/logging-model.js @@ -1,4 +1,5 @@ import { get, set } from '@ember/object' +import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const DEFAULT_TARGET_TYPE = 'none'; @@ -14,6 +15,8 @@ export default Mixin.create({ type: this.get('type'), }); + const map = EmberObject.create({}); + const loggingTagets = [ 'embedded', 'kafka', @@ -22,14 +25,12 @@ export default Mixin.create({ 'syslog', ]; - const map = {}; loggingTagets.forEach(key => { const config = store.createRecord({ - type: `${key}Config` + type: `${key}Config`, }); - const clone = nue.clone(); - clone.set('config', config); - map[key] = clone; + nue.set('config', config); + set(map, key, nue.clone()); }); this.setProperties(map); diff --git a/lib/logging/translations/en-us.yaml b/lib/logging/translations/en-us.yaml index 45f533aac..f741af6ac 100644 --- a/lib/logging/translations/en-us.yaml +++ b/lib/logging/translations/en-us.yaml @@ -53,6 +53,20 @@ loggingPage: requirements: The embedded deployment includes Elasticsearch and Kibana. Elasticsearch requests at least 1 CPU and 500M MEM available on the node it is deployed. esEndpoint: 'Elascticsearch Endpoint: http://47.88.57.141:30022' kibanaEndpoint: 'Kibana Endpoint: http://47.88.57.141:30024' + cpuRequests: + label: CPU Requests (Core) + placeholder: e.g. 1 + cpuLimits: + label: CPU Limits (Core) + placeholder: e.g. 4 + memRequests: + label: Memory Requests (M) + placeholder: e.g. 500 + memLimits: + label: Memory Limits (M) + placeholder: e.g. 2000 + resouceRequestsAndLimits: CPU and Memory + indexPatterns: header: Index Patterns helpText: Index patterns are used to generate Elacticsearch index