diff --git a/charts/kubedbcom-clickhouse-editor/ui/functions.js b/charts/kubedbcom-clickhouse-editor/ui/functions.js index 1c4344f943..2310b1579b 100644 --- a/charts/kubedbcom-clickhouse-editor/ui/functions.js +++ b/charts/kubedbcom-clickhouse-editor/ui/functions.js @@ -30,8 +30,13 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} async function getDbDetails() { + const annotations = + getValue(model, '/resources/autoscalingKubedbComClickHouseAutoscaler/metadata/annotations') || + {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' @@ -225,15 +230,20 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComClickHouseAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + return { machine: machineName || '', cpu: '', memory: '' } } async function getMachines(minmax) { @@ -242,16 +252,23 @@ export const useFunc = (model) => { const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -266,16 +283,19 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComClickHouseAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { @@ -291,7 +311,7 @@ export const useFunc = (model) => { }) commit('wizard/model$update', { path: annoPath, - value: { ...annotations }, + value: annotations, force: true, }) } diff --git a/charts/kubedbcom-druid-editor/ui/edit-ui.yaml b/charts/kubedbcom-druid-editor/ui/edit-ui.yaml index 038c53ba1a..3abb1a9367 100644 --- a/charts/kubedbcom-druid-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-druid-editor/ui/edit-ui.yaml @@ -89,72 +89,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-brokers-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|brokers|min + loader: + name: getMachines|brokers|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-brokers-max + watcher: + func: onMachineChange|brokers + paths: + - temp/properties/allowedMachine-brokers-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-brokers-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|brokers|max + loader: + name: getMachines|brokers|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-brokers-min + watcher: + func: onMachineChange|brokers + paths: + - temp/properties/allowedMachine-brokers-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-brokers-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|brokers|min - loader: - name: getMachines|brokers|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-brokers-max - watcher: - func: onMachineChange|brokers - paths: - - temp/properties/allowedMachine-brokers-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-brokers-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|brokers|max - loader: - name: getMachines|brokers|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-brokers-min - watcher: - func: onMachineChange|brokers - paths: - - temp/properties/allowedMachine-brokers-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/brokers/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|brokers @@ -191,72 +191,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-coordinators-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|coordinators|min + loader: + name: getMachines|coordinators|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-coordinators-max + watcher: + func: onMachineChange|coordinators + paths: + - temp/properties/allowedMachine-coordinators-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-coordinators-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|coordinators|max + loader: + name: getMachines|coordinators|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-coordinators-min + watcher: + func: onMachineChange|coordinators + paths: + - temp/properties/allowedMachine-coordinators-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-coordinators-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|coordinators|min - loader: - name: getMachines|coordinators|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-coordinators-max - watcher: - func: onMachineChange|coordinators - paths: - - temp/properties/allowedMachine-coordinators-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-coordinators-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|coordinators|max - loader: - name: getMachines|coordinators|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-coordinators-min - watcher: - func: onMachineChange|coordinators - paths: - - temp/properties/allowedMachine-coordinators-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/coordinators/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|coordinators @@ -293,72 +293,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-historicals-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|historicals|min + loader: + name: getMachines|historicals|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-historicals-max + watcher: + func: onMachineChange|historicals + paths: + - temp/properties/allowedMachine-historicals-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-historicals-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|historicals|max + loader: + name: getMachines|historicals|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-historicals-min + watcher: + func: onMachineChange|historicals + paths: + - temp/properties/allowedMachine-historicals-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-historicals-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|historicals|min - loader: - name: getMachines|historicals|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-historicals-max - watcher: - func: onMachineChange|historicals - paths: - - temp/properties/allowedMachine-historicals-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-historicals-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|historicals|max - loader: - name: getMachines|historicals|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-historicals-min - watcher: - func: onMachineChange|historicals - paths: - - temp/properties/allowedMachine-historicals-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/historicals/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|historicals @@ -396,72 +396,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-middleManagers-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|middleManagers|min + loader: + name: getMachines|middleManagers|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-middleManagers-max + watcher: + func: onMachineChange|middleManagers + paths: + - temp/properties/allowedMachine-middleManagers-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-middleManagers-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|middleManagers|max + loader: + name: getMachines|middleManagers|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-middleManagers-min + watcher: + func: onMachineChange|middleManagers + paths: + - temp/properties/allowedMachine-middleManagers-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-middleManagers-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|middleManagers|min - loader: - name: getMachines|middleManagers|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-middleManagers-max - watcher: - func: onMachineChange|middleManagers - paths: - - temp/properties/allowedMachine-middleManagers-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-middleManagers-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|middleManagers|max - loader: - name: getMachines|middleManagers|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-middleManagers-min - watcher: - func: onMachineChange|middleManagers - paths: - - temp/properties/allowedMachine-middleManagers-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComDruidAutoscaler/properties/spec/properties/compute/properties/middleManagers/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|middleManagers diff --git a/charts/kubedbcom-druid-editor/ui/functions.js b/charts/kubedbcom-druid-editor/ui/functions.js index fbcc218269..08171aae9d 100644 --- a/charts/kubedbcom-druid-editor/ui/functions.js +++ b/charts/kubedbcom-druid-editor/ui/functions.js @@ -1395,7 +1395,6 @@ export const useFunc = (model) => { * @param {string} type - Type of value ('bound' or 'scalingRules') */ function handleUnit(path, type = 'bound') { - console.log('handleUnit') let value = getValue(model, `/resources/${path}`) if (type === 'scalingRules') { const updatedValue = [] @@ -1438,7 +1437,13 @@ export const useFunc = (model) => { * Fetches database details for autoscaling configuration * Retrieves the Druid database resource to determine topology and settings */ + let instance = {} async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComDruidAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -1549,7 +1554,11 @@ export const useFunc = (model) => { * @returns {Array} List of available machine profiles with their specifications */ async function fetchTopologyMachines() { - const instance = hasAnnotations() + const annotations = getValue( + model, + '/resources/autoscalingKubedbComDruidAutoscaler/metadata/annotations', + ) + const instance = annotations['kubernetes.io/instance-type'] const user = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') @@ -1560,10 +1569,11 @@ export const useFunc = (model) => { const nodeGroups = resp.data?.spec?.nodeGroups || [] setDiscriminatorValue('/topologyMachines', nodeGroups) - return nodeGroups + // return nodeGroups } catch (e) { console.log(e) - return [] + // return [] + setDiscriminatorValue('/topologyMachines', []) } } } @@ -1575,22 +1585,30 @@ export const useFunc = (model) => { * @param {string} minmax - Either 'min' or 'max' to indicate which constraint to get * @returns {Array} Filtered list of machine profiles with CPU and memory specifications */ - function getMachines(nodeType, minmax) { + function getMachines(type, minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' - const dependantPath = `/allowedMachine-${nodeType}-${depends}` + const dependantPath = `/allowedMachine-${type}-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -1600,12 +1618,7 @@ export const useFunc = (model) => { return dependantIndex === -1 ? machines : filteredMachine } - function setAllowedMachine(nodeType, minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComDruidAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] + function setAllowedMachine(type, minmax) { let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -1614,17 +1627,34 @@ export const useFunc = (model) => { parsedInstance = {} } - const machine = parsedInstance[nodeType] || '' + const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } function onMachineChange(nodeType) { const annoPath = '/resources/autoscalingKubedbComDruidAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { @@ -1634,19 +1664,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${nodeType}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${nodeType}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${nodeType}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${nodeType}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[nodeType] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComDruidAutoscaler/spec/compute/${nodeType}` if (minMachine && maxMachine && instance !== instanceString) { @@ -1668,9 +1703,9 @@ export const useFunc = (model) => { } } - function setControlledResources(nodeType) { + function setControlledResources(type) { const list = ['cpu', 'memory'] - const path = `/resources/autoscalingKubedbComDruidAutoscaler/spec/compute/${nodeType}/controlledResources` + const path = `/resources/autoscalingKubedbComDruidAutoscaler/spec/${type}/controlledResources` commit('wizard/model$update', { path: path, value: list, diff --git a/charts/kubedbcom-elasticsearch-editor/ui/edit-ui.yaml b/charts/kubedbcom-elasticsearch-editor/ui/edit-ui.yaml index 571d872941..21ae993ec4 100644 --- a/charts/kubedbcom-elasticsearch-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-elasticsearch-editor/ui/edit-ui.yaml @@ -449,72 +449,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-node-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|node|min + loader: + name: getMachines|node|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-node-max + watcher: + func: onMachineChange|node + paths: + - temp/properties/allowedMachine-node-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-node-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|node|min - loader: - name: getMachines|node|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-node-max - watcher: - func: onMachineChange|node - paths: - - temp/properties/allowedMachine-node-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-node-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|node|max - loader: - name: getMachines|node|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-node-min - watcher: - func: onMachineChange|node - paths: - - temp/properties/allowedMachine-node-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-node-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|node|max + loader: + name: getMachines|node|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-node-min + watcher: + func: onMachineChange|node + paths: + - temp/properties/allowedMachine-node-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/node @@ -562,72 +562,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-data-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|data|min + loader: + name: getMachines|data|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-data-max + watcher: + func: onMachineChange|data + paths: + - temp/properties/allowedMachine-data-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-data-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|data|min - loader: - name: getMachines|data|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-data-max - watcher: - func: onMachineChange|data - paths: - - temp/properties/allowedMachine-data-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-data-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|data|max - loader: - name: getMachines|data|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-data-min - watcher: - func: onMachineChange|data - paths: - - temp/properties/allowedMachine-data-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-data-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|data|max + loader: + name: getMachines|data|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-data-min + watcher: + func: onMachineChange|data + paths: + - temp/properties/allowedMachine-data-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/data/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/data @@ -668,10 +668,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-ingest-min if: type: function @@ -704,6 +703,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/ingest/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-ingest-max if: type: function @@ -774,10 +774,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-master-min if: type: function @@ -810,6 +809,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComElasticsearchAutoscaler/properties/spec/properties/compute/properties/master/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-master-max if: type: function diff --git a/charts/kubedbcom-elasticsearch-editor/ui/functions.js b/charts/kubedbcom-elasticsearch-editor/ui/functions.js index d1810680cd..bd9bd62b28 100644 --- a/charts/kubedbcom-elasticsearch-editor/ui/functions.js +++ b/charts/kubedbcom-elasticsearch-editor/ui/functions.js @@ -652,8 +652,13 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} - + let instance = {} async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComElasticsearchAutoscaler/metadata/annotations', + ) + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -801,11 +806,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComElasticsearchAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -813,29 +813,53 @@ export const useFunc = (model) => { console.log(e) parsedInstance = {} } - const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } function getMachines(type, minmax) { const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -847,7 +871,7 @@ export const useFunc = (model) => { function onMachineChange(type) { const annoPath = '/resources/autoscalingKubedbComElasticsearchAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { @@ -857,19 +881,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComElasticsearchAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) { diff --git a/charts/kubedbcom-ferretdb-editor/ui/edit-ui.yaml b/charts/kubedbcom-ferretdb-editor/ui/edit-ui.yaml index b564b10adf..7541e619cc 100644 --- a/charts/kubedbcom-ferretdb-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-ferretdb-editor/ui/edit-ui.yaml @@ -93,72 +93,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-primary-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|primary|min + loader: + name: getMachines|primary|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-primary-max + watcher: + func: onMachineChange|primary + paths: + - temp/properties/allowedMachine-primary-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-primary-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|primary|max + loader: + name: getMachines|primary|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-primary-min + watcher: + func: onMachineChange|primary + paths: + - temp/properties/allowedMachine-primary-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-primary-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|primary|min - loader: - name: getMachines|primary|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-primary-max - watcher: - func: onMachineChange|primary - paths: - - temp/properties/allowedMachine-primary-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-primary-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|primary|max - loader: - name: getMachines|primary|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-primary-min - watcher: - func: onMachineChange|primary - paths: - - temp/properties/allowedMachine-primary-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/primary/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/primary @@ -211,72 +211,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-secondary-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|secondary|min + loader: + name: getMachines|secondary|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-secondary-max + watcher: + func: onMachineChange|secondary + paths: + - temp/properties/allowedMachine-secondary-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-secondary-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|secondary|max + loader: + name: getMachines|secondary|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-secondary-min + watcher: + func: onMachineChange|secondary + paths: + - temp/properties/allowedMachine-secondary-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-secondary-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|secondary|min - loader: - name: getMachines|secondary|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-secondary-max - watcher: - func: onMachineChange|secondary - paths: - - temp/properties/allowedMachine-secondary-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-secondary-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|secondary|max - loader: - name: getMachines|secondary|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-secondary-min - watcher: - func: onMachineChange|secondary - paths: - - temp/properties/allowedMachine-secondary-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComFerretDBAutoscaler/properties/spec/properties/compute/properties/secondary/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/secondary diff --git a/charts/kubedbcom-ferretdb-editor/ui/functions.js b/charts/kubedbcom-ferretdb-editor/ui/functions.js index 6169859d7d..c84b2e7f1d 100644 --- a/charts/kubedbcom-ferretdb-editor/ui/functions.js +++ b/charts/kubedbcom-ferretdb-editor/ui/functions.js @@ -33,6 +33,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} function isConsole() { const isKube = isKubedb() @@ -68,8 +69,12 @@ export const useFunc = (model) => { return !isKube } - + async function getDbDetails() { + const annotations = + getValue(model, '/resources/autoscalingKubedbComFerretDBAutoscaler/metadata/annotations') || + {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -243,10 +248,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComFerretDBAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -258,27 +259,52 @@ export const useFunc = (model) => { const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(type, minmax) { + function getMachines(type, minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -300,19 +326,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComFerretDBAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) { @@ -338,27 +369,6 @@ export const useFunc = (model) => { return !hasAnnotations() } - function setAllowedMachine(type, minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComFerretDBAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] - let parsedInstance = {} - try { - if (instance) parsedInstance = JSON.parse(instance) - } catch (e) { - console.log(e) - parsedInstance = {} - } - - const machine = parsedInstance[type] || '' - const mx = machine?.includes(',') ? machine.split(',')[1] : '' - const mn = machine?.includes(',') ? machine.split(',')[0] : '' - - if (minmax === 'min') return mn - else return mx - } - function setControlledResources(type) { const list = ['cpu', 'memory'] const path = `/resources/autoscalingKubedbComFerretDBAutoscaler/spec/compute/${type}/controlledResources` @@ -407,7 +417,6 @@ export const useFunc = (model) => { } function showOpsRequestOptions() { - console.log('isKubedb:') if (isKubedb() === true) return true // watchDependency('model#/resources/autoscalingKubedbComFerretDBAutoscaler/spec/databaseRef/name') // watchDependency('discriminator#/autoscalingType') diff --git a/charts/kubedbcom-kafka-editor/ui/edit-ui.yaml b/charts/kubedbcom-kafka-editor/ui/edit-ui.yaml index 2391e40c91..3641eaf215 100644 --- a/charts/kubedbcom-kafka-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-kafka-editor/ui/edit-ui.yaml @@ -102,72 +102,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-broker-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|broker|min + loader: + name: getMachines|broker|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-broker-max + watcher: + func: onMachineChange|broker + paths: + - temp/properties/allowedMachine-broker-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-broker-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|broker|min - loader: - name: getMachines|broker|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-broker-max - watcher: - func: onMachineChange|broker - paths: - - temp/properties/allowedMachine-broker-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-broker-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|broker|max - loader: - name: getMachines|broker|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-broker-min - watcher: - func: onMachineChange|broker - paths: - - temp/properties/allowedMachine-broker-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-broker-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|broker|max + loader: + name: getMachines|broker|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-broker-min + watcher: + func: onMachineChange|broker + paths: + - temp/properties/allowedMachine-broker-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/broker/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/broker @@ -216,72 +216,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-controller-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|controller|min + loader: + name: getMachines|controller|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-controller-max + watcher: + func: onMachineChange|controller + paths: + - temp/properties/allowedMachine-controller-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-controller-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|controller|max + loader: + name: getMachines|controller|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-controller-min + watcher: + func: onMachineChange|controller + paths: + - temp/properties/allowedMachine-controller-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-controller-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|controller|min - loader: - name: getMachines|controller|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-controller-max - watcher: - func: onMachineChange|controller - paths: - - temp/properties/allowedMachine-controller-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-controller-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|controller|max - loader: - name: getMachines|controller|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-controller-min - watcher: - func: onMachineChange|controller - paths: - - temp/properties/allowedMachine-controller-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/controller/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/controller @@ -339,72 +339,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-node-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|node|min + loader: + name: getMachines|node|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-node-max + watcher: + func: onMachineChange|node + paths: + - temp/properties/allowedMachine-node-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-node-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|node|max + loader: + name: getMachines|node|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-node-min + watcher: + func: onMachineChange|node + paths: + - temp/properties/allowedMachine-node-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-node-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|node|min - loader: - name: getMachines|node|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-node-max - watcher: - func: onMachineChange|node - paths: - - temp/properties/allowedMachine-node-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-node-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|node|max - loader: - name: getMachines|node|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-node-min - watcher: - func: onMachineChange|node - paths: - - temp/properties/allowedMachine-node-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComKafkaAutoscaler/properties/spec/properties/compute/properties/node/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/node diff --git a/charts/kubedbcom-kafka-editor/ui/functions.js b/charts/kubedbcom-kafka-editor/ui/functions.js index bff182a19d..725916f3ca 100644 --- a/charts/kubedbcom-kafka-editor/ui/functions.js +++ b/charts/kubedbcom-kafka-editor/ui/functions.js @@ -33,6 +33,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} function isKubedb() { return !!storeGet('/route/params/actions') @@ -74,6 +75,9 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = + getValue(model, '/resources/autoscalingKubedbComKafkaAutoscaler/metadata/annotations') || {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -221,9 +225,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComKafkaAutoscaler/metadata/annotations') || {} - const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -235,27 +236,52 @@ export const useFunc = (model) => { const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(type, minmax) { + function getMachines(type, minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -277,19 +303,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComKafkaAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) { diff --git a/charts/kubedbcom-mariadb-editor/ui/edit-ui.yaml b/charts/kubedbcom-mariadb-editor/ui/edit-ui.yaml index 9989de6555..00df19595c 100644 --- a/charts/kubedbcom-mariadb-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-mariadb-editor/ui/edit-ui.yaml @@ -241,10 +241,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function @@ -258,7 +257,7 @@ step: - temp/properties/topologyMachines - temp/properties/allowedMachine-max watcher: - func: onMachineChange|mariadb + func: onMachineChange paths: - temp/properties/allowedMachine-min - type: block-layout @@ -277,6 +276,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMariaDBAutoscaler/properties/spec/properties/compute/properties/mariadb/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function @@ -290,7 +290,7 @@ step: - temp/properties/topologyMachines - temp/properties/allowedMachine-min watcher: - func: onMachineChange|mariadb + func: onMachineChange paths: - temp/properties/allowedMachine-max - type: block-layout diff --git a/charts/kubedbcom-mariadb-editor/ui/functions.js b/charts/kubedbcom-mariadb-editor/ui/functions.js index 497754f7ad..520f4ecdeb 100644 --- a/charts/kubedbcom-mariadb-editor/ui/functions.js +++ b/charts/kubedbcom-mariadb-editor/ui/functions.js @@ -738,8 +738,15 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComMariaDBAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] + const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' @@ -955,32 +962,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComMariaDBAutoscaler/metadata/annotations') || {} - const instance = annotations?.['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -995,16 +1024,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComMariaDBAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-memcached-editor/ui/edit-ui.yaml b/charts/kubedbcom-memcached-editor/ui/edit-ui.yaml index 735b5b0f93..20c018ba96 100644 --- a/charts/kubedbcom-memcached-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-memcached-editor/ui/edit-ui.yaml @@ -326,72 +326,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|min + loader: + name: getMachines|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-max + watcher: + func: onMachineChange|memcached + paths: + - temp/properties/allowedMachine-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|max + loader: + name: getMachines|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-min + watcher: + func: onMachineChange|memcached + paths: + - temp/properties/allowedMachine-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|min - loader: - name: getMachines|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-max - watcher: - func: onMachineChange|memcached - paths: - - temp/properties/allowedMachine-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|max - loader: - name: getMachines|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-min - watcher: - func: onMachineChange|memcached - paths: - - temp/properties/allowedMachine-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMemcachedAutoscaler/properties/spec/properties/compute/properties/memcached/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|memcached diff --git a/charts/kubedbcom-memcached-editor/ui/functions.js b/charts/kubedbcom-memcached-editor/ui/functions.js index 72b7f8f6ab..499b412605 100644 --- a/charts/kubedbcom-memcached-editor/ui/functions.js +++ b/charts/kubedbcom-memcached-editor/ui/functions.js @@ -9,8 +9,12 @@ export const useFunc = (model) => { ) setDiscriminatorValue('/enableMonitoring', false) - + let instance = {} async function getDbDetails() { + const annotations = + getValue(model, '/resources/autoscalingKubedbComMemcachedAutoscaler/metadata/annotations') || + {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -222,16 +226,20 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComMemcachedAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + return { machine: machineName || '', cpu: '', memory: '' } } async function getMachines(minmax) { @@ -240,16 +248,23 @@ export const useFunc = (model) => { const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -261,19 +276,22 @@ export const useFunc = (model) => { function onMachineChange(type) { const annoPath = '/resources/autoscalingKubedbComMemcachedAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComMemcachedAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { @@ -289,7 +307,7 @@ export const useFunc = (model) => { }) commit('wizard/model$update', { path: annoPath, - value: { ...annotations }, + value: annotations, force: true, }) } diff --git a/charts/kubedbcom-mongodb-editor/ui/edit-ui.yaml b/charts/kubedbcom-mongodb-editor/ui/edit-ui.yaml index 3a00292d63..34908f40c3 100644 --- a/charts/kubedbcom-mongodb-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-mongodb-editor/ui/edit-ui.yaml @@ -452,72 +452,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-standalone-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|standalone|min + loader: + name: getMachines|standalone|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-standalone-max + watcher: + func: onMachineChange|standalone + paths: + - temp/properties/allowedMachine-standalone-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-standalone-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|standalone|min - loader: - name: getMachines|standalone|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-standalone-max - watcher: - func: onMachineChange|standalone - paths: - - temp/properties/allowedMachine-standalone-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-standalone-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|standalone|max - loader: - name: getMachines|standalone|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-standalone-min - watcher: - func: onMachineChange|standalone - paths: - - temp/properties/allowedMachine-standalone-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-standalone-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|standalone|max + loader: + name: getMachines|standalone|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-standalone-min + watcher: + func: onMachineChange|standalone + paths: + - temp/properties/allowedMachine-standalone-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/standalone @@ -534,6 +534,9 @@ step: - type: block-layout label: In Memory Storage showLabels: true + if: + type: function + name: showStorageMemoryOption # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/standalone/properties/inMemoryStorage elements: - type: threshold-input @@ -588,72 +591,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-replicaSet-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|replicaSet|min + loader: + name: getMachines|replicaSet|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-replicaSet-max + watcher: + func: onMachineChange|replicaSet + paths: + - temp/properties/allowedMachine-replicaSet-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-replicaSet-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|replicaSet|min - loader: - name: getMachines|replicaSet|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-replicaSet-max - watcher: - func: onMachineChange|replicaSet - paths: - - temp/properties/allowedMachine-replicaSet-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-replicaSet-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|replicaSet|max - loader: - name: getMachines|replicaSet|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-replicaSet-min - watcher: - func: onMachineChange|replicaSet - paths: - - temp/properties/allowedMachine-replicaSet-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-replicaSet-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|replicaSet|max + loader: + name: getMachines|replicaSet|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-replicaSet-min + watcher: + func: onMachineChange|replicaSet + paths: + - temp/properties/allowedMachine-replicaSet-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/replicaSet @@ -669,6 +672,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/replicaSet/properties/inMemoryStorage elements: @@ -718,72 +724,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-shard-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|shard|min + loader: + name: getMachines|shard|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-shard-max + watcher: + func: onMachineChange|shard + paths: + - temp/properties/allowedMachine-shard-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-shard-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|shard|max + loader: + name: getMachines|shard|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-shard-min + watcher: + func: onMachineChange|shard + paths: + - temp/properties/allowedMachine-shard-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-shard-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|shard|min - loader: - name: getMachines|shard|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-shard-max - watcher: - func: onMachineChange|shard - paths: - - temp/properties/allowedMachine-shard-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-shard-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|shard|max - loader: - name: getMachines|shard|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-shard-min - watcher: - func: onMachineChange|shard - paths: - - temp/properties/allowedMachine-shard-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/shard @@ -799,6 +805,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/shard/properties/inMemoryStorage elements: @@ -842,72 +851,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-configServer-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|configServer|min + loader: + name: getMachines|configServer|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-configServer-max + watcher: + func: onMachineChange|configServer + paths: + - temp/properties/allowedMachine-configServer-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-configServer-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|configServer|min - loader: - name: getMachines|configServer|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-configServer-max - watcher: - func: onMachineChange|configServer - paths: - - temp/properties/allowedMachine-configServer-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-configServer-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|configServer|max - loader: - name: getMachines|configServer|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-configServer-min - watcher: - func: onMachineChange|configServer - paths: - - temp/properties/allowedMachine-configServer-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-configServer-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|configServer|max + loader: + name: getMachines|configServer|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-configServer-min + watcher: + func: onMachineChange|configServer + paths: + - temp/properties/allowedMachine-configServer-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/configServer @@ -923,6 +932,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/configServer/properties/inMemoryStorage elements: @@ -966,72 +978,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-arbiter-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|arbiter|min + loader: + name: getMachines|arbiter|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-arbiter-max + watcher: + func: onMachineChange|arbiter + paths: + - temp/properties/allowedMachine-arbiter-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-arbiter-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|arbiter|max + loader: + name: getMachines|arbiter|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-arbiter-min + watcher: + func: onMachineChange|arbiter + paths: + - temp/properties/allowedMachine-arbiter-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-arbiter-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|arbiter|min - loader: - name: getMachines|arbiter|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-arbiter-max - watcher: - func: onMachineChange|arbiter - paths: - - temp/properties/allowedMachine-arbiter-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-arbiter-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|arbiter|max - loader: - name: getMachines|arbiter|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-arbiter-min - watcher: - func: onMachineChange|arbiter - paths: - - temp/properties/allowedMachine-arbiter-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/arbiter @@ -1047,6 +1059,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/arbiter/properties/inMemoryStorage elements: @@ -1090,72 +1105,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-hidden-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|hidden|min + loader: + name: getMachines|hidden|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-hidden-max + watcher: + func: onMachineChange|hidden + paths: + - temp/properties/allowedMachine-hidden-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-hidden-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|hidden|min - loader: - name: getMachines|hidden|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-hidden-max - watcher: - func: onMachineChange|hidden - paths: - - temp/properties/allowedMachine-hidden-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-hidden-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|hidden|max - loader: - name: getMachines|hidden|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-hidden-min - watcher: - func: onMachineChange|hidden - paths: - - temp/properties/allowedMachine-hidden-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-hidden-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|hidden|max + loader: + name: getMachines|hidden|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-hidden-min + watcher: + func: onMachineChange|hidden + paths: + - temp/properties/allowedMachine-hidden-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/hidden @@ -1171,6 +1186,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/hidden/properties/inMemoryStorage elements: @@ -1213,72 +1231,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-mongos-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|mongos|min + loader: + name: getMachines|mongos|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-mongos-max + watcher: + func: onMachineChange|mongos + paths: + - temp/properties/allowedMachine-mongos-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-mongos-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|mongos|max + loader: + name: getMachines|mongos|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-mongos-min + watcher: + func: onMachineChange|mongos + paths: + - temp/properties/allowedMachine-mongos-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-mongos-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|mongos|min - loader: - name: getMachines|mongos|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-mongos-max - watcher: - func: onMachineChange|mongos - paths: - - temp/properties/allowedMachine-mongos-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-mongos-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|mongos|max - loader: - name: getMachines|mongos|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-mongos-min - watcher: - func: onMachineChange|mongos - paths: - - temp/properties/allowedMachine-mongos-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/mongos @@ -1294,6 +1312,9 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/containerControlledValues - type: block-layout label: In Memory Storage + if: + type: function + name: showStorageMemoryOption showLabels: true # schema: schema/properties/resources/properties/autoscalingKubedbComMongoDBAutoscaler/properties/spec/properties/compute/properties/mongos/properties/inMemoryStorage elements: diff --git a/charts/kubedbcom-mongodb-editor/ui/functions.js b/charts/kubedbcom-mongodb-editor/ui/functions.js index 9552a86f47..0a726dcde1 100644 --- a/charts/kubedbcom-mongodb-editor/ui/functions.js +++ b/charts/kubedbcom-mongodb-editor/ui/functions.js @@ -2761,6 +2761,7 @@ export const useFunc = (model) => { ) } let instance = {} + let showStoragememory = false async function getDbDetails() { const annotations = getValue( model, @@ -2780,7 +2781,7 @@ export const useFunc = (model) => { `/clusters/${owner}/${cluster}/proxy/kubedb.com/v1alpha2/namespaces/${namespace}/mongodbs/${name}`, ) dbDetails = resp.data || {} - + showStoragememory = dbDetails?.spec?.storageEngine === 'inMemory' setDiscriminatorValue('/dbDetails', true) } catch (e) { console.log(e) @@ -2809,6 +2810,11 @@ export const useFunc = (model) => { }) } + function showStorageMemoryOption() { + return showStoragememory + } + + function mongoTypeEqualsTo(mongoType, type) { // watchDependency('discriminator#/dbDetails') autoscaleType = type @@ -3125,7 +3131,6 @@ export const useFunc = (model) => { const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' const machineName = minmax === 'min' ? mn : mx - // Find the machine details from topologyMachines const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const machineData = nodeGroups.find((item) => item.topologyValue === machineName) @@ -3482,5 +3487,6 @@ export const useFunc = (model) => { setValueFromDbDetails, isHidden, setPausedValue, + showStorageMemoryOption } } diff --git a/charts/kubedbcom-mssqlserver-editor/ui/edit-ui.yaml b/charts/kubedbcom-mssqlserver-editor/ui/edit-ui.yaml index 990d1f08ca..f56cd31d7d 100644 --- a/charts/kubedbcom-mssqlserver-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-mssqlserver-editor/ui/edit-ui.yaml @@ -618,10 +618,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-mssqlserver-min if: type: function @@ -654,6 +653,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComMSSQLServerAutoscaler/properties/spec/properties/compute/properties/mssqlserver/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-mssqlserver-max if: type: function diff --git a/charts/kubedbcom-mssqlserver-editor/ui/functions.js b/charts/kubedbcom-mssqlserver-editor/ui/functions.js index 2d4d7f0ebc..f386d2d9c3 100644 --- a/charts/kubedbcom-mssqlserver-editor/ui/functions.js +++ b/charts/kubedbcom-mssqlserver-editor/ui/functions.js @@ -594,6 +594,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' function isConsole() { const isKube = isKubedb() @@ -635,6 +636,12 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComMSSQLServerAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] + const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -799,35 +806,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue( - model, - '/resources/autoscalingKubedbComMSSQLServerAutoscaler/metadata/annotations', - ) || {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -857,16 +883,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComMSSQLServerAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml b/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml index c148776428..4bd37a704a 100644 --- a/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-mysql-editor/ui/edit-ui.yaml @@ -150,6 +150,7 @@ step: - type: single-step-form id: compute-autoscaler + loader: getMysqlDbs elements: - type: block-layout if: @@ -240,58 +241,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|mysql|min + loader: + name: getMachines|mysql|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-max + watcher: + func: onMachineChange|mysql + paths: + - temp/properties/allowedMachine-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|mysql|max + loader: + name: getMachines|mysql|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-min + watcher: + func: onMachineChange|mysql + paths: + - temp/properties/allowedMachine-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-min - if: - type: function - name: hasAnnotations - loader: - name: getMachines|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-max - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-max - if: - type: function - name: hasAnnotations - loader: - name: getMachines|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-min - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|mysql @@ -308,6 +323,9 @@ step: - type: block-layout label: In Memory Storage showLabels: true + if: + type: function + name: showStorageMemoryOption # schema: schema/properties/resources/properties/autoscalingKubedbComMySQLAutoscaler/properties/spec/properties/compute/properties/mysql/properties/inMemoryStorage elements: - type: threshold-input diff --git a/charts/kubedbcom-mysql-editor/ui/functions.js b/charts/kubedbcom-mysql-editor/ui/functions.js index 1c51de795c..745f521280 100644 --- a/charts/kubedbcom-mysql-editor/ui/functions.js +++ b/charts/kubedbcom-mysql-editor/ui/functions.js @@ -41,6 +41,7 @@ export const useFunc = (model) => { setDiscriminatorValue('/allowedMachine-configServer-max', '') setDiscriminatorValue('/allowedMachine-mongos-min', '') setDiscriminatorValue('/allowedMachine-mongos-max', '') + let showStoragememory = false function initScheduleBackupForEdit() { const { stashAppscodeComBackupConfiguration, isBluePrint } = getBackupConfigsAndAnnotations( @@ -541,6 +542,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' function isKubedb() { return !!storeGet('/route/params/actions') @@ -626,7 +628,8 @@ export const useFunc = (model) => { ) const owner = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') - + const storageEngine = getValue(model, '/resources/kubedbComMySQL/spec/storageEngine') + showStoragememory = storageEngine === 'inMemory' const resp = await axios.get( `/clusters/${owner}/${cluster}/proxy/kubedb.com/v1alpha2/namespaces/${namespace}/mysqls`, { @@ -667,8 +670,9 @@ export const useFunc = (model) => { } async function fetchTopologyMachines() { - const instance = hasAnnotations() - + const annotations = + getValue(model, '/resources/autoscalingKubedbComMySQLAutoscaler/metadata/annotations') || {} + instance = annotations['kubernetes.io/instance-type'] const user = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') if (instance) { @@ -688,14 +692,11 @@ export const useFunc = (model) => { function setTrigger(path) { let value = getValue(model, `/resources/${path}`) - console.log('setTrigger', value, path) - return value === 'On' } function onTriggerChange(type) { const trigger = getValue(discriminator, `/${type}/trigger`) - console.log('trigger', trigger, type) const commitPath = `/resources/autoscalingKubedbComMySQLAutoscaler/spec/${type}/trigger` commit('wizard/model$update', { @@ -714,32 +715,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComMySQLAutoscaler/metadata/annotations') || {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -754,16 +777,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComMySQLAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { @@ -1312,6 +1340,9 @@ export const useFunc = (model) => { const value = getValue(model, path) return value } + function showStorageMemoryOption() { + return showStoragememory + } return { initScheduleBackup, @@ -1389,5 +1420,6 @@ export const useFunc = (model) => { addOrRemoveBinding, setValueFromDbDetails, + showStorageMemoryOption, } } diff --git a/charts/kubedbcom-perconaxtradb-editor/ui/edit-ui.yaml b/charts/kubedbcom-perconaxtradb-editor/ui/edit-ui.yaml index 0e8745d00e..0d9ba37dac 100644 --- a/charts/kubedbcom-perconaxtradb-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-perconaxtradb-editor/ui/edit-ui.yaml @@ -93,72 +93,72 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout + - type: machine-compare + label: Min Allowed Profile + header: Minimum Resource Limit + schema: temp/properties/allowedMachine-perconaxtradb-min + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|perconaxtradb|min + loader: + name: getMachines|perconaxtradb|min + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-perconaxtradb-max + watcher: + func: onMachineChange|perconaxtradb + paths: + - temp/properties/allowedMachine-perconaxtradb-min + - type: block-layout + label: Min Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true + elements: + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/minAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/minAllowed/properties/memory + - type: machine-compare + label: Max Allowed Profile + header: Maximum Resource Limit + schema: temp/properties/allowedMachine-perconaxtradb-max + if: + type: function + name: hasAnnotations + init: + type: func + value: setAllowedMachine|perconaxtradb|max + loader: + name: getMachines|perconaxtradb|max + watchPaths: + - temp/properties/topologyMachines + - temp/properties/allowedMachine-perconaxtradb-min + watcher: + func: onMachineChange|perconaxtradb + paths: + - temp/properties/allowedMachine-perconaxtradb-max + - type: block-layout + label: Max Allowed + fixedBlock: true + if: + type: function + name: hasNoAnnotations + showLabels: true elements: - - type: machine-compare - label: Min Allowed Profile - schema: temp/properties/allowedMachine-perconaxtradb-min - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|perconaxtradb|min - loader: - name: getMachines|perconaxtradb|min - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-perconaxtradb-max - watcher: - func: onMachineChange|perconaxtradb - paths: - - temp/properties/allowedMachine-perconaxtradb-min - - type: block-layout - label: Min Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/minAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/minAllowed/properties/memory - - type: machine-compare - label: Max Allowed Profile - schema: temp/properties/allowedMachine-perconaxtradb-max - if: - type: function - name: hasAnnotations - init: - type: func - value: setAllowedMachine|perconaxtradb|max - loader: - name: getMachines|perconaxtradb|max - watchPaths: - - temp/properties/topologyMachines - - temp/properties/allowedMachine-perconaxtradb-min - watcher: - func: onMachineChange|perconaxtradb - paths: - - temp/properties/allowedMachine-perconaxtradb-max - - type: block-layout - label: Max Allowed - fixedBlock: true - if: - type: function - name: hasNoAnnotations - showLabels: true - elements: - - type: input-compare - label: Cpu - schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/maxAllowed/properties/cpu - - type: input-compare - label: Memory - schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/maxAllowed/properties/memory + - type: input-compare + label: Cpu + schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/maxAllowed/properties/cpu + - type: input-compare + label: Memory + schema: schema/properties/resources/properties/autoscalingKubedbComPerconaXtraDBAutoscaler/properties/spec/properties/compute/properties/perconaxtradb/properties/maxAllowed/properties/memory - type: select label: Controlled Resources loader: setControlledResources|compute/perconaxtradb diff --git a/charts/kubedbcom-perconaxtradb-editor/ui/functions.js b/charts/kubedbcom-perconaxtradb-editor/ui/functions.js index 99824523c4..baac20bdad 100644 --- a/charts/kubedbcom-perconaxtradb-editor/ui/functions.js +++ b/charts/kubedbcom-perconaxtradb-editor/ui/functions.js @@ -30,6 +30,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} function isConsole() { const isKube = isKubedb() @@ -71,6 +72,12 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = + getValue( + model, + '/resources/autoscalingKubedbComPerconaXtraDBAutoscaler/metadata/annotations', + ) || {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -287,17 +294,20 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue( - model, - '/resources/autoscalingKubedbComPerconaXtraDBAutoscaler/metadata/annotations', - ) || {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + return { machine: machineName || '', cpu: '', memory: '' } } async function getMachines(minmax) { @@ -306,16 +316,23 @@ export const useFunc = (model) => { const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -330,16 +347,19 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComPerconaXtraDBAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-pgbouncer-editor/ui/edit-ui.yaml b/charts/kubedbcom-pgbouncer-editor/ui/edit-ui.yaml index 8e6213fbe3..ea8a9575e5 100644 --- a/charts/kubedbcom-pgbouncer-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-pgbouncer-editor/ui/edit-ui.yaml @@ -99,10 +99,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function @@ -135,6 +134,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComPgBouncerAutoscaler/properties/spec/properties/compute/properties/pgbouncer/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function diff --git a/charts/kubedbcom-pgbouncer-editor/ui/functions.js b/charts/kubedbcom-pgbouncer-editor/ui/functions.js index f04c1feba4..75a273b77a 100644 --- a/charts/kubedbcom-pgbouncer-editor/ui/functions.js +++ b/charts/kubedbcom-pgbouncer-editor/ui/functions.js @@ -30,6 +30,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' function isConsole() { const isKube = isKubedb() @@ -71,6 +72,12 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComPgBouncerAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] + const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -253,15 +260,20 @@ export const useFunc = (model) => { return !hasAnnotations() } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComPgBouncerAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + return { machine: machineName || '', cpu: '', memory: '' } } async function getMachines(minmax) { @@ -270,16 +282,23 @@ export const useFunc = (model) => { const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -294,16 +313,19 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComPgBouncerAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-pgpool-editor/ui/edit-ui.yaml b/charts/kubedbcom-pgpool-editor/ui/edit-ui.yaml index 03cd8b6b4d..7ee408947e 100644 --- a/charts/kubedbcom-pgpool-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-pgpool-editor/ui/edit-ui.yaml @@ -93,10 +93,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function @@ -129,6 +128,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComPgpoolAutoscaler/properties/spec/properties/compute/properties/pgpool/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function diff --git a/charts/kubedbcom-pgpool-editor/ui/functions.js b/charts/kubedbcom-pgpool-editor/ui/functions.js index ed9d890605..b10fb34e88 100644 --- a/charts/kubedbcom-pgpool-editor/ui/functions.js +++ b/charts/kubedbcom-pgpool-editor/ui/functions.js @@ -22,6 +22,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} function isConsole() { const isKube = isKubedb() @@ -125,6 +126,9 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = + getValue(model, '/resources/autoscalingKubedbComPgpoolAutoscaler/metadata/annotations') || {} + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -255,7 +259,7 @@ export const useFunc = (model) => { function onTriggerChange(path) { const value = getValue(discriminator, `/temp/${path}/trigger`) const modelPath = `/resources/autoscalingKubedbComPgpoolAutoscaler/spec/${path}/trigger` - + commit('wizard/model$update', { path: modelPath, value: value === 'On' ? 'On' : 'Off', @@ -288,10 +292,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComPgpoolAutoscaler/metadata/annotations') || {} - const instance = annotations['kubernetes.io/instance-type'] - // For pgpool, the instance format is stored as: "min,max" or as a JSON object like {"pgpool": "min,max"} let instanceValue = instance try { @@ -300,30 +300,55 @@ export const useFunc = (model) => { } catch (e) { // If not JSON, use as-is } - + const mx = instanceValue?.includes(',') ? instanceValue.split(',')[1] : '' const mn = instanceValue?.includes(',') ? instanceValue.split(',')[0] : '' - console.log('values', mn, mx) - if (minmax === 'min') return mn - else return mx + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(type, minmax) { + function getMachines(type, minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -350,10 +375,13 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` - + // Store as JSON object like MongoDB: {"pgpool": "min,max"} let parsedInstance = {} try { @@ -362,15 +390,17 @@ export const useFunc = (model) => { // If not JSON, treat as pgpool value parsedInstance = {} } - + parsedInstance[type] = minMaxMachine annotations['kubernetes.io/instance-type'] = JSON.stringify(parsedInstance) - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComPgpoolAutoscaler/spec/compute/${type}` if (minMachine && maxMachine) { diff --git a/charts/kubedbcom-postgres-editor/ui/edit-ui.yaml b/charts/kubedbcom-postgres-editor/ui/edit-ui.yaml index eb7836660f..be188275bb 100644 --- a/charts/kubedbcom-postgres-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-postgres-editor/ui/edit-ui.yaml @@ -241,19 +241,18 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|min + value: setAllowedMachine|postgres|min loader: - name: getMachines|min + name: getMachines|postgres|min watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-max @@ -277,15 +276,16 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComPostgresAutoscaler/properties/spec/properties/compute/properties/postgres/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|max + value: setAllowedMachine|postgres|max loader: - name: getMachines|max + name: getMachines|postgres|max watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-min @@ -323,6 +323,9 @@ step: - type: block-layout label: In Memory Storage showLabels: true + if: + type: function + name: showStorageMemoryOption # schema: schema/properties/resources/properties/autoscalingKubedbComPostgresAutoscaler/properties/spec/properties/compute/properties/postgres/properties/inMemoryStorage elements: - type: threshold-input diff --git a/charts/kubedbcom-postgres-editor/ui/functions.js b/charts/kubedbcom-postgres-editor/ui/functions.js index 459c47265e..4fdc6bd9f8 100644 --- a/charts/kubedbcom-postgres-editor/ui/functions.js +++ b/charts/kubedbcom-postgres-editor/ui/functions.js @@ -163,6 +163,7 @@ export const useFunc = (model) => { let initialArchiver = {} let isArchiverAvailable = false let archiverObjectToCommit = {} + let showStoragememory = false async function initBackupData() { // set initial model for further usage @@ -581,8 +582,15 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComPostgresAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] + const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' @@ -601,6 +609,8 @@ export const useFunc = (model) => { `/clusters/${owner}/${cluster}/proxy/kubedb.com/v1alpha2/namespaces/${namespace}/postgreses/${name}`, ) dbDetails = resp.data || {} + showStoragememory = dbDetails?.spec?.storageEngine === 'inMemory' + console.log('showStoragememory', showStoragememory) setDiscriminatorValue('/dbDetails', true) } catch (e) { @@ -784,14 +794,11 @@ export const useFunc = (model) => { function setTrigger(path) { let value = getValue(model, `/resources/${path}`) - console.log('setTrigger', value, path) - return value === 'On' } function onTriggerChange(type) { const trigger = getValue(discriminator, `/${type}/trigger`) - console.log('trigger', trigger, type) const commitPath = `/resources/autoscalingKubedbComPostgresAutoscaler/spec/${type}/trigger` commit('wizard/model$update', { @@ -811,33 +818,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComPostgresAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -852,16 +880,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComPostgresAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { @@ -1263,9 +1296,6 @@ export const useFunc = (model) => { model, '/resources/kubedbComPostgres/spec/monitor/prometheus/exporter/env/items/valueFrom/configMapKeyRef/name', ) - - console.log({ configMapName }) - // watchDependency('data#/namespace') // watchDependency('rootModel#/valueFrom/configMapKeyRef/name') @@ -1401,6 +1431,10 @@ export const useFunc = (model) => { } } + function showStorageMemoryOption() { + return showStoragememory + } + return { initScheduleBackup, initScheduleBackupForEdit, @@ -1484,5 +1518,6 @@ export const useFunc = (model) => { isBindingAlreadyOn, addOrRemoveBinding, + showStorageMemoryOption } } diff --git a/charts/kubedbcom-proxysql-editor/ui/edit-ui.yaml b/charts/kubedbcom-proxysql-editor/ui/edit-ui.yaml index 5b77781e96..f207ba3168 100644 --- a/charts/kubedbcom-proxysql-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-proxysql-editor/ui/edit-ui.yaml @@ -93,10 +93,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-proxysql-min if: type: function @@ -129,6 +128,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComProxySQLAutoscaler/properties/spec/properties/compute/properties/proxysql/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-proxysql-max if: type: function diff --git a/charts/kubedbcom-proxysql-editor/ui/functions.js b/charts/kubedbcom-proxysql-editor/ui/functions.js index a6a882b192..a812313532 100644 --- a/charts/kubedbcom-proxysql-editor/ui/functions.js +++ b/charts/kubedbcom-proxysql-editor/ui/functions.js @@ -28,6 +28,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' function isConsole() { const isKube = isKubedb() @@ -259,7 +260,9 @@ export const useFunc = (model) => { } async function fetchTopologyMachines() { - const instance = hasAnnotations() + const annotations = + getValue(model, '/resources/autoscalingKubedbComProxySQLAutoscaler/metadata/annotations') || {} + instance = annotations['kubernetes.io/instance-type'] const user = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') @@ -279,35 +282,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComProxySQLAutoscaler/metadata/annotations') || - {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { - // watchDependency('discriminator#/topologyMachines') + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] - console.log(nodeGroups) const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -335,16 +357,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComProxySQLAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-rabbitmq-editor/ui/edit-ui.yaml b/charts/kubedbcom-rabbitmq-editor/ui/edit-ui.yaml index 6ed52dddc5..81352263b7 100644 --- a/charts/kubedbcom-rabbitmq-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-rabbitmq-editor/ui/edit-ui.yaml @@ -91,10 +91,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function @@ -127,6 +126,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComRabbitMQAutoscaler/properties/spec/properties/compute/properties/rabbitmq/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function diff --git a/charts/kubedbcom-rabbitmq-editor/ui/functions.js b/charts/kubedbcom-rabbitmq-editor/ui/functions.js index 4d7df57fa1..e9aefd86a4 100644 --- a/charts/kubedbcom-rabbitmq-editor/ui/functions.js +++ b/charts/kubedbcom-rabbitmq-editor/ui/functions.js @@ -466,6 +466,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' function isConsole() { const isKube = isKubedb() @@ -720,7 +721,9 @@ export const useFunc = (model) => { } async function fetchTopologyMachines() { - const instance = hasAnnotations() + const annotations = + getValue(model, '/resources/autoscalingKubedbComRabbitMQAutoscaler/metadata/annotations') || {} + instance = annotations['kubernetes.io/instance-type'] const user = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') @@ -740,34 +743,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComRabbitMQAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -792,19 +815,24 @@ export const useFunc = (model) => { function onMachineChange(type) { const annoPath = '/resources/autoscalingKubedbComRabbitMQAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComRabbitMQAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-redis-editor/ui/edit-ui.yaml b/charts/kubedbcom-redis-editor/ui/edit-ui.yaml index 7af70ebe7b..20bc1e2ff2 100644 --- a/charts/kubedbcom-redis-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-redis-editor/ui/edit-ui.yaml @@ -251,19 +251,18 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|min + value: setAllowedMachine|standalone|min loader: - name: getMachines|min + name: getMachines|standalone|min watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-max @@ -287,15 +286,16 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComRedisAutoscaler/properties/spec/properties/compute/properties/standalone/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|max + value: setAllowedMachine|standalone|max loader: - name: getMachines|max + name: getMachines|standalone|max watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-min @@ -368,19 +368,18 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|min + value: setAllowedMachine|cluster|min loader: - name: getMachines|min + name: getMachines|cluster|min watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-max @@ -404,15 +403,16 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComRedisAutoscaler/properties/spec/properties/compute/properties/cluster/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function name: hasAnnotations init: type: func - value: setAllowedMachine|max + value: setAllowedMachine|cluster|max loader: - name: getMachines|max + name: getMachines|cluster|max watchPaths: - temp/properties/topologyMachines - temp/properties/allowedMachine-min @@ -469,10 +469,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-min if: type: function @@ -505,6 +504,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComRedisAutoscaler/properties/spec/properties/compute/properties/sentinel/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-max if: type: function diff --git a/charts/kubedbcom-redis-editor/ui/functions.js b/charts/kubedbcom-redis-editor/ui/functions.js index 00b577c38b..d27e040902 100644 --- a/charts/kubedbcom-redis-editor/ui/functions.js +++ b/charts/kubedbcom-redis-editor/ui/functions.js @@ -580,8 +580,15 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = '' async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComRedisAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] + const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' @@ -749,14 +756,11 @@ export const useFunc = (model) => { function setTrigger(path) { let value = getValue(model, `/resources/${path}`) - console.log('setTrigger', value, path) - return value === 'On' // Returns boolean instead of string } function onTriggerChange(type) { const trigger = getValue(discriminator, `/${type}/trigger`) - console.log('trigger', trigger, type) const commitPath = `/resources/autoscalingKubedbComRedisAutoscaler/spec/${type}/trigger` commit('wizard/model$update', { @@ -775,32 +779,54 @@ export const useFunc = (model) => { } function setAllowedMachine(minmax) { - const annotations = - getValue(model, '/resources/autoscalingKubedbComRedisAutoscaler/metadata/annotations') || {} - const instance = annotations['kubernetes.io/instance-type'] const mx = instance?.includes(',') ? instance.split(',')[1] : '' const mn = instance?.includes(',') ? instance.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx + + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) - if (minmax === 'min') return mn - else return mx + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(minmax) { + function getMachines(minmax) { // watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${depends}` // watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -815,16 +841,21 @@ export const useFunc = (model) => { const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] - const minMachine = getValue(discriminator, '/allowedMachine-min') - const maxMachine = getValue(discriminator, '/allowedMachine-max') + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, '/allowedMachine-min') + const maxMachineObj = getValue(discriminator, '/allowedMachine-max') + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` annotations['kubernetes.io/instance-type'] = minMaxMachine - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComRedisAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== minMaxMachine) { diff --git a/charts/kubedbcom-singlestore-editor/ui/edit-ui.yaml b/charts/kubedbcom-singlestore-editor/ui/edit-ui.yaml index 75a563af55..9f9b5d005e 100644 --- a/charts/kubedbcom-singlestore-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-singlestore-editor/ui/edit-ui.yaml @@ -209,6 +209,7 @@ step: type: function name: dbTypeEqualsTo|topology showLabels: false + loader: fetchTopologyMachines # schema: schema/properties/resources/properties/autoscalingKubedbComSinglestoreAutoscaler/properties/spec/properties/compute elements: # Aggregator section @@ -245,10 +246,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-aggregator-min if: type: function @@ -281,6 +281,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSinglestoreAutoscaler/properties/spec/properties/compute/properties/aggregator/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-aggregator-max if: type: function @@ -351,10 +352,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-leaf-min if: type: function @@ -387,6 +387,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSinglestoreAutoscaler/properties/spec/properties/compute/properties/leaf/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-leaf-max if: type: function @@ -430,6 +431,7 @@ step: type: function name: dbTypeEqualsTo|standalone showLabels: false + loader: fetchTopologyMachines # schema: schema/properties/resources/properties/autoscalingKubedbComSinglestoreAutoscaler/properties/spec/properties/compute elements: # Node section @@ -466,10 +468,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-node-min if: type: function @@ -502,6 +503,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSinglestoreAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-node-max if: type: function diff --git a/charts/kubedbcom-singlestore-editor/ui/functions.js b/charts/kubedbcom-singlestore-editor/ui/functions.js index f87d71bbe8..06601ce699 100644 --- a/charts/kubedbcom-singlestore-editor/ui/functions.js +++ b/charts/kubedbcom-singlestore-editor/ui/functions.js @@ -180,6 +180,7 @@ export const useFunc = (model) => { let initialArchiver = {} let isArchiverAvailable = false let archiverObjectToCommit = {} + let instance = {} async function initBackupData() { // set initial model for further usage @@ -699,6 +700,11 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComSinglestoreAutoscaler/metadata/annotations', + ) + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -929,7 +935,7 @@ export const useFunc = (model) => { function onMachineChange(type) { const annoPath = '/resources/autoscalingKubedbComSinglestoreAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { @@ -939,19 +945,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComSinglestoreAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) { @@ -1478,11 +1489,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComSinglestoreAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -1494,25 +1500,50 @@ export const useFunc = (model) => { const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } function getMachines(type, minmax) { const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => diff --git a/charts/kubedbcom-solr-editor/ui/edit-ui.yaml b/charts/kubedbcom-solr-editor/ui/edit-ui.yaml index 82f4b60218..2b923eaf48 100644 --- a/charts/kubedbcom-solr-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-solr-editor/ui/edit-ui.yaml @@ -477,10 +477,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-coordinator-min if: type: function @@ -513,6 +512,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSolrAutoscaler/properties/spec/properties/compute/properties/coordinator/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-coordinator-max if: type: function @@ -603,10 +603,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-data-min if: type: function @@ -639,6 +638,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSolrAutoscaler/properties/spec/properties/compute/properties/data/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-data-max if: type: function @@ -729,10 +729,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-overseer-min if: type: function @@ -765,6 +764,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSolrAutoscaler/properties/spec/properties/compute/properties/overseer/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-overseer-max if: type: function @@ -855,10 +855,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-node-min if: type: function @@ -891,6 +890,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComSolrAutoscaler/properties/spec/properties/compute/properties/node/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-node-max if: type: function diff --git a/charts/kubedbcom-solr-editor/ui/functions.js b/charts/kubedbcom-solr-editor/ui/functions.js index 63de8e74de..df12c74bbc 100644 --- a/charts/kubedbcom-solr-editor/ui/functions.js +++ b/charts/kubedbcom-solr-editor/ui/functions.js @@ -35,6 +35,7 @@ export const useFunc = (model) => { let autoscaleType = '' let dbDetails = {} + let instance = {} function isConsole() { const isKube = isKubedb() @@ -129,6 +130,11 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComSolrAutoscaler/metadata/annotations', + ) + instance = annotations['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -293,11 +299,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComSolrAutoscaler/metadata/annotations', - ) - const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -309,27 +310,52 @@ export const useFunc = (model) => { const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(type, minmax) { + function getMachines(type, minmax) { watchDependency('discriminator#/topologyMachines') const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` watchDependency(`discriminator#${dependantPath}`) - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -355,7 +381,7 @@ export const useFunc = (model) => { function onMachineChange(type) { const annoPath = '/resources/autoscalingKubedbComSolrAutoscaler/metadata/annotations' - const annotations = getValue(model, annoPath) + const annotations = getValue(model, annoPath) || {} const instance = annotations['kubernetes.io/instance-type'] let parsedInstance = {} try { @@ -365,19 +391,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComSolrAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) { diff --git a/charts/kubedbcom-zookeeper-editor/ui/edit-ui.yaml b/charts/kubedbcom-zookeeper-editor/ui/edit-ui.yaml index d5fe10a8dc..d9673f5b79 100644 --- a/charts/kubedbcom-zookeeper-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-zookeeper-editor/ui/edit-ui.yaml @@ -241,10 +241,9 @@ step: - type: block-layout showLabels: false elements: - - type: horizontal-layout - elements: - type: machine-compare label: Min Allowed Profile + header: Minimum Resource Limit schema: temp/properties/allowedMachine-zookeeper-min if: type: function @@ -277,6 +276,7 @@ step: schema: schema/properties/resources/properties/autoscalingKubedbComZooKeeperAutoscaler/properties/spec/properties/compute/properties/zookeeper/properties/minAllowed/properties/memory - type: machine-compare label: Max Allowed Profile + header: Maximum Resource Limit schema: temp/properties/allowedMachine-zookeeper-max if: type: function diff --git a/charts/kubedbcom-zookeeper-editor/ui/functions.js b/charts/kubedbcom-zookeeper-editor/ui/functions.js index 554b634bf8..1ed0a60472 100644 --- a/charts/kubedbcom-zookeeper-editor/ui/functions.js +++ b/charts/kubedbcom-zookeeper-editor/ui/functions.js @@ -72,6 +72,7 @@ export const useFunc = (model) => { let initialArchiver = {} let isArchiverAvailable = false let archiverObjectToCommit = {} + let instance = {} async function initBackupData() { // set initial model for further usage @@ -920,6 +921,11 @@ export const useFunc = (model) => { } async function getDbDetails() { + const annotations = getValue( + model, + '/resources/autoscalingKubedbComZooKeeperAutoscaler/metadata/annotations', + ) + instance = annotations?.['kubernetes.io/instance-type'] const owner = storeGet('/route/params/user') || '' const cluster = storeGet('/route/params/cluster') || '' const namespace = @@ -1061,11 +1067,6 @@ export const useFunc = (model) => { } function setAllowedMachine(type, minmax) { - const annotations = getValue( - model, - '/resources/autoscalingKubedbComZooKeeperAutoscaler/metadata/annotations', - ) - const instance = annotations?.['kubernetes.io/instance-type'] let parsedInstance = {} try { if (instance) parsedInstance = JSON.parse(instance) @@ -1077,25 +1078,50 @@ export const useFunc = (model) => { const machine = parsedInstance[type] || '' const mx = machine?.includes(',') ? machine.split(',')[1] : '' const mn = machine?.includes(',') ? machine.split(',')[0] : '' + const machineName = minmax === 'min' ? mn : mx - if (minmax === 'min') return mn - else return mx + // Find the machine details from topologyMachines + const nodeGroups = getValue(discriminator, '/topologyMachines') || [] + const machineData = nodeGroups.find((item) => item.topologyValue === machineName) + + // Return object with machine, cpu, memory (expected format for machine-compare init) + if (machineData) { + return { + machine: machineName, + cpu: machineData.allocatable?.cpu, + memory: machineData.allocatable?.memory, + } + } + // Return empty object if no machine found + return { + machine: machineName || '', + cpu: '', + memory: '', + } } - async function getMachines(type, minmax) { + function getMachines(type, minmax) { const depends = minmax === 'min' ? 'max' : 'min' const dependantPath = `/allowedMachine-${type}-${depends}` - const dependantMachine = getValue(discriminator, dependantPath) + const dependantMachineObj = getValue(discriminator, dependantPath) + const dependantMachine = dependantMachineObj?.machine || '' const nodeGroups = getValue(discriminator, '/topologyMachines') || [] const dependantIndex = nodeGroups?.findIndex((item) => item.topologyValue === dependantMachine) + // Return array with text and value object (expected format for machine-compare loader) const machines = nodeGroups?.map((item) => { - const subText = `CPU: ${item.allocatable.cpu}, Memory: ${item.allocatable.memory}` const text = item.topologyValue - return { text, subText, value: item.topologyValue } + return { + text, + value: { + machine: item.topologyValue, + cpu: item.allocatable?.cpu, + memory: item.allocatable?.memory, + }, + } }) const filteredMachine = machines?.filter((item, ind) => @@ -1131,19 +1157,24 @@ export const useFunc = (model) => { parsedInstance = {} } - const minMachine = getValue(discriminator, `/allowedMachine-${type}-min`) - const maxMachine = getValue(discriminator, `/allowedMachine-${type}-max`) + // Now discriminator values are objects with { machine, cpu, memory } + const minMachineObj = getValue(discriminator, `/allowedMachine-${type}-min`) + const maxMachineObj = getValue(discriminator, `/allowedMachine-${type}-max`) + const minMachine = minMachineObj?.machine || '' + const maxMachine = maxMachineObj?.machine || '' const minMaxMachine = `${minMachine},${maxMachine}` parsedInstance[type] = minMaxMachine const instanceString = JSON.stringify(parsedInstance) annotations['kubernetes.io/instance-type'] = instanceString - const machines = getValue(discriminator, `/topologyMachines`) || [] - const minMachineObj = machines.find((item) => item.topologyValue === minMachine) - const maxMachineObj = machines.find((item) => item.topologyValue === maxMachine) - const minMachineAllocatable = minMachineObj?.allocatable - const maxMachineAllocatable = maxMachineObj?.allocatable + // Use cpu/memory directly from the machine objects + const minMachineAllocatable = minMachineObj + ? { cpu: minMachineObj.cpu, memory: minMachineObj.memory } + : null + const maxMachineAllocatable = maxMachineObj + ? { cpu: maxMachineObj.cpu, memory: maxMachineObj.memory } + : null const allowedPath = `/resources/autoscalingKubedbComZooKeeperAutoscaler/spec/compute/${type}` if (minMachine && maxMachine && instance !== instanceString) {