pr feedback

fix hpa metric si values
fix harvester vol si unit
This commit is contained in:
Nancy Butler 2021-11-16 12:50:26 -07:00
parent 44886057b1
commit 6349d78113
4 changed files with 15 additions and 37 deletions

View File

@ -3,6 +3,7 @@ import isEmpty from 'lodash/isEmpty';
import UnitInput from '@/components/form/UnitInput';
import { CONTAINER_DEFAULT_RESOURCE_LIMIT } from '@/config/labels-annotations';
import { cleanUp } from '@/utils/object';
import { _VIEW } from '@/config/query-params';
export default {
components: { UnitInput },
@ -42,7 +43,7 @@ export default {
} = this.value;
return {
limitsCpu, limitsMemory, requestsCpu, requestsMemory
limitsCpu, limitsMemory, requestsCpu, requestsMemory, viewMode: _VIEW
};
},

View File

@ -56,7 +56,7 @@ export default {
default: null,
},
// LabeledInput props vv
// LabeledInput props
mode: {
type: String,
default: _EDIT

View File

@ -40,7 +40,6 @@ export default {
value: 'AverageValue',
specKey: 'averageValue',
validTypes: ['resource', 'pod', 'object', 'external'],
default: '80',
},
{
label: this.t('hpa.metricTarget.utilization.label'),
@ -54,7 +53,6 @@ export default {
value: 'Value',
specKey: 'value',
validTypes: ['object', 'external'],
default: '80',
},
];
@ -74,6 +72,7 @@ export default {
watch: {
resourceName(newRn, _oldRn) {
// debugger;
const {
value: { type: metricType },
targetTypes,
@ -90,10 +89,11 @@ export default {
}
this.$set(this.value, match?.specKey, nueDefault);
this.quantity = match?.default ?? null;
this.quantity = nueDefault;
},
'value.type'(targetType, oldType) {
// debugger;
const { targetTypes, resourceName } = this;
const toDelete = findBy(targetTypes, { value: oldType });
const nue = findBy(targetTypes, { value: targetType });
@ -110,7 +110,7 @@ export default {
delete this.value[toDelete.specKey];
this.$set(this.value, nue?.specKey, nueDefault);
this.quantity = nue?.default ?? null;
this.quantity = nueDefault;
},
},
@ -138,20 +138,10 @@ export default {
return quantity;
},
updateQuantityValue(val) {
switch (this.value.type) {
case 'Value':
if (this.value?.type === 'Value') {
this.$set(this.value, 'value', val);
break;
case 'AverageValue':
default:
if (this.resourceName === 'cpu') {
this.$set(this.value, 'averageValue', `${ val }m`);
} else if (this.resourceName === 'memory') {
this.$set(this.value, 'averageValue', `${ val }Mi`);
} else {
this.$set(this.value, 'averageValue', val);
}
break;
} else {
this.$set(this.value, 'averageValue', val);
}
},
},

View File

@ -11,7 +11,6 @@ import { HCI } from '@/config/types';
import { sortBy } from '@/utils/sort';
import { InterfaceOption } from '@/config/harvester-map';
import { _CREATE } from '@/config/query-params';
import { formatSi, parseSi } from '@/utils/units';
import CreateEditView from '@/mixins/create-edit-view';
import { HCI as HCI_ANNOTATIONS } from '@/config/labels-annotations';
@ -39,7 +38,7 @@ export default {
this.value.spec.accessModes = ['ReadWriteMany'];
}
const storage = this.getSize(this.value.spec.resources.requests.storage);
const storage = this.value?.spec?.resources?.requests?.storage || null;
const imageId = get(this.value, `metadata.annotations."${ HCI_ANNOTATIONS.IMAGE_ID }"`);
const source = !imageId ? 'blank' : 'url';
@ -107,7 +106,7 @@ export default {
const spec = {
...this.value.spec,
resources: { requests: { storage: `${ this.storage }Gi` } },
resources: { requests: { storage: this.storage } },
storageClassName
};
@ -116,20 +115,6 @@ export default {
this.$set(this.value, 'spec', spec);
},
getSize(storage, addSuffix = false) {
if (!storage) {
return null;
}
const kibUnitSize = parseSi(storage);
return formatSi(kibUnitSize, {
addSuffix,
increment: 1024,
minExponent: 3,
maxExponent: 3
});
}
}
};
</script>
@ -174,7 +159,9 @@ export default {
<UnitInput
v-model="storage"
:label="t('harvester.volume.size')"
suffix="MiB"
:input-exponent="3"
:output-modifier="true"
:increment="1024"
:mode="mode"
required
class="mb-20"