[arvados] updated: 2.7.0-5606-g5b8cf7d21b

git repository hosting git at public.arvados.org
Tue Dec 19 21:23:28 UTC 2023


Summary of changes:
 .../instance-types-panel.test.tsx                  | 48 +++++++++++++++++-----
 .../instance-types-panel/instance-types-panel.tsx  | 27 +++++++++---
 2 files changed, 59 insertions(+), 16 deletions(-)

       via  5b8cf7d21b16a859c7d7429e5e7dfd17d50f93ed (commit)
       via  33185e9e58d5e492eaff61eea64d5d2e6eeb71a3 (commit)
      from  6f15deea24d3544e08ba6c5681d2a2a11de40971 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5b8cf7d21b16a859c7d7429e5e7dfd17d50f93ed
Author: Stephen Smith <stephen at curii.com>
Date:   Tue Dec 19 16:22:50 2023 -0500

    19675: Add keep buffer and discount ram accounting to instance types panel
    with tests
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/services/workbench2/src/views/instance-types-panel/instance-types-panel.test.tsx b/services/workbench2/src/views/instance-types-panel/instance-types-panel.test.tsx
index ca2705177f..a9d87b942b 100644
--- a/services/workbench2/src/views/instance-types-panel/instance-types-panel.test.tsx
+++ b/services/workbench2/src/views/instance-types-panel/instance-types-panel.test.tsx
@@ -4,11 +4,11 @@
 
 import React from 'react';
 import { configure, mount } from "enzyme";
-import { InstanceTypesPanel } from './instance-types-panel';
+import { InstanceTypesPanel, calculateKeepBufferOverhead, discountRamByPercent } from './instance-types-panel';
 import Adapter from "enzyme-adapter-react-16";
 import { combineReducers, createStore } from "redux";
 import { Provider } from "react-redux";
-import { formatFileSize } from 'common/formatters';
+import { formatFileSize, formatCWLResourceSize } from 'common/formatters';
 
 configure({ adapter: new Adapter() });
 
@@ -70,17 +70,43 @@ describe('<InstanceTypesPanel />', () => {
             const item = panel.find(`Grid[data-cy="${instanceKey}"]`)
 
             expect(item.find('h6').text()).toContain(instanceKey);
-            expect(item.text()).toContain(`Provider type: ${instanceType.ProviderType}`);
-            expect(item.text()).toContain(`Price: $${instanceType.Price}`);
-            expect(item.text()).toContain(`Cores: ${instanceType.VCPUs}`);
-            expect(item.text()).toContain(`Preemptible: ${instanceType.Preemptible.toString()}`);
-            expect(item.text()).toContain(`Max disk request: ${formatFileSize(instanceType.IncludedScratch)}`);
-            expect(item.text()).toContain(`Max ram request: ${formatFileSize(instanceType.RAM - initialAuthState.config.clusterConfig.Containers.ReserveExtraRAM)}`);
+            expect(item.text()).toContain(`Provider type${instanceType.ProviderType}`);
+            expect(item.text()).toContain(`Price$${instanceType.Price}`);
+            expect(item.text()).toContain(`Cores${instanceType.VCPUs}`);
+            expect(item.text()).toContain(`Preemptible${instanceType.Preemptible.toString()}`);
+            expect(item.text()).toContain(`Max disk request${formatCWLResourceSize(instanceType.IncludedScratch)} (${formatFileSize(instanceType.IncludedScratch)})`);
             if (instanceType.CUDA && instanceType.CUDA.DeviceCount > 0) {
-                expect(item.text()).toContain(`CUDA GPUs: ${instanceType.CUDA.DeviceCount}`);
-                expect(item.text()).toContain(`Hardware capability: ${instanceType.CUDA.HardwareCapability}`);
-                expect(item.text()).toContain(`Driver version: ${instanceType.CUDA.DriverVersion}`);
+                expect(item.text()).toContain(`CUDA GPUs${instanceType.CUDA.DeviceCount}`);
+                expect(item.text()).toContain(`Hardware capability${instanceType.CUDA.HardwareCapability}`);
+                expect(item.text()).toContain(`Driver version${instanceType.CUDA.DriverVersion}`);
             }
         });
     });
 });
+
+describe('calculateKeepBufferOverhead', () => {
+    it('should calculate correct buffer size', () => {
+        const testCases = [
+            {input: 0, output: (220<<20)},
+            {input: 1, output: (220<<20) + ((1<<26) * (11/10))},
+            {input: 2, output: (220<<20) + 2*((1<<26) * (11/10))},
+        ];
+
+        for (const {input, output} of testCases) {
+            expect(calculateKeepBufferOverhead(input)).toBe(output);
+        }
+    });
+});
+
+describe('discountRamByPercent', () => {
+    it('should inflate ram requirement by 5% of final amount', () => {
+        const testCases = [
+            {input: 0, output: 0},
+            {input: 114, output: 120},
+        ];
+
+        for (const {input, output} of testCases) {
+            expect(discountRamByPercent(input)).toBe(output);
+        }
+    });
+});
diff --git a/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx b/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
index 13c0d9c130..2f240c8228 100644
--- a/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
+++ b/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
@@ -77,8 +77,9 @@ export const InstanceTypesPanel = withStyles(styles)(connect(mapStateToProps)(
                         }
                     }).map((instanceKey) => {
                         const instanceType = instances[instanceKey];
-                        const diskRequest = instanceType.IncludedScratch;
-                        const ramRequest = instanceType.RAM - config.Containers.ReserveExtraRAM;
+                        const maxDiskRequest = instanceType.IncludedScratch;
+                        const keepBufferOverhead = calculateKeepBufferOverhead(instanceType.VCPUs);
+                        const maxRamRequest = discountRamByPercent(instanceType.RAM - config.Containers.ReserveExtraRAM - keepBufferOverhead);
 
                         return <Grid data-cy={instanceKey} className={classes.instanceType} item sm={6} xs={12} key={instanceKey}>
                             <Card>
@@ -96,10 +97,10 @@ export const InstanceTypesPanel = withStyles(styles)(connect(mapStateToProps)(
                                         <DetailsAttribute label="Cores" value={instanceType.VCPUs} />
                                     </Grid>
                                     <Grid item xs={12}>
-                                        <DetailsAttribute label="Max RAM request" value={`${formatCWLResourceSize(ramRequest)} (${formatFileSize(ramRequest)})`} />
+                                        <DetailsAttribute label="Max RAM request" value={`${formatCWLResourceSize(maxRamRequest)} (${formatFileSize(maxRamRequest)})`} />
                                     </Grid>
                                     <Grid item xs={12}>
-                                        <DetailsAttribute label="Max disk request" value={`${formatCWLResourceSize(diskRequest)} (${formatFileSize(diskRequest)})`} />
+                                        <DetailsAttribute label="Max disk request" value={`${formatCWLResourceSize(maxDiskRequest)} (${formatFileSize(maxDiskRequest)})`} />
                                     </Grid>
                                     <Grid item xs={12}>
                                         <DetailsAttribute label="Preemptible" value={instanceType.Preemptible.toString()} />
@@ -129,3 +130,19 @@ export const InstanceTypesPanel = withStyles(styles)(connect(mapStateToProps)(
         </Grid>;
     }
 ));
+
+export const calculateKeepBufferOverhead = (coreCount: number): number => {
+    // TODO replace with exported server config
+    const buffersPerVCPU = 1;
+
+    // Returns 220 MiB + 64MiB+10% per buffer
+    return (220 << 20) + (buffersPerVCPU * coreCount * (1 << 26) * (11/10))
+};
+
+export const discountRamByPercent = (requestedRamBytes: number): number => {
+    // TODO replace this with exported server config or remove when no longer
+    // used by server in ram calculation
+    const discountPercent = 5;
+
+    return requestedRamBytes * 100 / (100-discountPercent);
+};

commit 33185e9e58d5e492eaff61eea64d5d2e6eeb71a3
Author: Stephen Smith <stephen at curii.com>
Date:   Tue Dec 19 16:22:26 2023 -0500

    19675: Restore accidentally removed cost formatter
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx b/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
index 22617d8c86..13c0d9c130 100644
--- a/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
+++ b/services/workbench2/src/views/instance-types-panel/instance-types-panel.tsx
@@ -90,7 +90,7 @@ export const InstanceTypesPanel = withStyles(styles)(connect(mapStateToProps)(
                                         <DetailsAttribute label="Provider type" value={instanceType.ProviderType} />
                                     </Grid>
                                     <Grid item xs={12}>
-                                        <DetailsAttribute label="Price" value={instanceType.Price} />
+                                        <DetailsAttribute label="Price" value={formatCost(instanceType.Price)} />
                                     </Grid>
                                     <Grid item xs={12}>
                                         <DetailsAttribute label="Cores" value={instanceType.VCPUs} />

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list