From ae0f3f30f938b7b19a87f968e5a57c6177fb2c87 Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:44:02 -0500 Subject: [PATCH] new: Represent region-specific pricing when configuring LKE Node Pools (#5065) * Add support for region-specific pricing * fix grammar --- .../driver-linodelke/component.js | 37 ++++++++++++++++++- .../driver-linodelke/template.hbs | 15 ++++++-- translations/en-us.yaml | 5 ++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js b/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js index 7e066903a5..34918fe721 100644 --- a/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-linodelke/component.js @@ -112,7 +112,17 @@ export default Component.extend(ClusterDriver, { errors: [], step: 2, regions: responses.regions.data.filter((region) => (region.status === 'ok' && region.capabilities.includes('Kubernetes'))), - nodeTypes: responses.nodeTypes.data.filter((type) => (['standard', 'highmem', 'dedicated'].includes(type.class))), + nodeTypes: responses.nodeTypes.data.filter( + (type) => (['standard', 'highmem', 'dedicated'].includes(type.class)) + ).map((type) => { + // We need to set default values for effective prices + return { + ...type, + isException: false, + effectiveHourly: type.price.hourly, + effectiveMonthly: type.price.monthly + } + }), k8sVersions: responses.k8sVersions.data, }); @@ -239,8 +249,9 @@ export default Component.extend(ClusterDriver, { const selectedNodePoolList = get(this, 'selectedNodePoolList'); const nodePools = selectedNodePoolList.map((np) => { return `${ np.id }=${ np.count }` - }) + }); + set(this, 'configHasRegionException', selectedNodePoolList.filter((type) => type.isException).length > 0) set(this, 'cluster.lkeEngineConfig.nodePools', nodePools); }), @@ -249,6 +260,28 @@ export default Component.extend(ClusterDriver, { this.prefillSelectedNodePoolList(); }), + updateEffectiveTypePrices: observer('cluster.lkeEngineConfig.region', function() { + // We need special handling for regional price exceptions + const nodeTypes = this.nodeTypes.map((type) => { + let override = undefined; + + if (type['region_prices'] !== undefined) { + override = type.region_prices.find((override) => override.id === this.cluster.lkeEngineConfig.region); + } + + const isException = override !== undefined; + + return { + ...type, + isException, + effectiveHourly: isException ? override.hourly : type.price.hourly, + effectiveMonthly: isException ? override.monthly : type.price.monthly + } + }); + + set(this, 'nodeTypes', nodeTypes); + }), + // Any computed properties or custom logic can go here // for region choises diff --git a/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs b/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs index 6ed2f38ada..2b9743a96e 100644 --- a/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs +++ b/lib/shared/addon/components/cluster-driver/driver-linodelke/template.hbs @@ -191,13 +191,13 @@
{{t "clusterNew.linodelke.nodePoolConfig.monthly"}}:
- {{format-number this.selectedNodePoolObj.price.monthly style='currency' currency='USD' allowEmpty=true}} + {{format-number this.selectedNodePoolObj.effectiveMonthly style='currency' currency='USD' allowEmpty=true}}
{{t "clusterNew.linodelke.nodePoolConfig.hourly"}}:
- {{format-number this.selectedNodePoolObj.price.hourly style='currency' currency='USD' allowEmpty=true}} + {{format-number this.selectedNodePoolObj.effectiveHourly style='currency' currency='USD' allowEmpty=true}}
@@ -255,6 +255,13 @@
+ {{# if this.configHasRegionException}} + {{banner-message + icon="icon-alert" + color="bg-warning mb-10" + message=(t "clusterNew.linodelke.selectedNodePoolType.regionPriceWarning") + }} + {{/if}} {{#sortable-table classNames="grid fixed mb-0 sortable-table" sortBy=sortBy @@ -274,10 +281,10 @@ {{member.label}} - {{format-number member.price.monthly style='currency' currency='USD' allowEmpty=true}} + {{format-number member.effectiveMonthly style='currency' currency='USD' allowEmpty=true}} - {{format-number member.price.hourly style='currency' currency='USD' allowEmpty=true}} + {{format-number member.effectiveHourly style='currency' currency='USD' allowEmpty=true}} {{member.memoryGb}} {{t "generic.gigabyte"}} diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 9c9cdd6893..780410b8e2 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -3347,7 +3347,7 @@ clusterNew: fleet: Fleet Agent Configuration accordionDetail: cluster: Customize scheduling fields and resource limits for the Rancher cluster agent - fleet: Customize scheduling fields and resource limits for the Rancher fleet agent + fleet: Customize scheduling fields and resource limits for the Rancher fleet agent banners: advanced: These are advanced configuration options. Generally, they should be left as-is. resourceRequests: Pod Requests and Limits do not have a default configuration. @@ -3621,7 +3621,7 @@ clusterNew: parsedDockerBridgeCidr: Docker bridge address can not overlap with the selected Virtual Network or the Kubernetes service address range parsedServiceCidr: Kubernetes service address range must fall within the selected Virtual Network range. serviceCidr: Kubernetes service address range must be valid CIDR format. - nodeResourceGroup: + nodeResourceGroup: length: "{key} name cannot exceed 80 characters." chars: "{key} name may only consist of underscores, periods, hyphens, parentheses, and letters or digits." periodEnd: "{key} name cannot end with a period." @@ -4396,6 +4396,7 @@ clusterNew: selectedNodePoolType: label: Select type placeholder: Select a node pool type + regionPriceWarning: One or more node pools in this configuration are subject to region-specific pricing. These prices are reflected in the displayed configuration below. shortLabel: Linode LKE tags: label: Tags