Skip to content

Commit

Permalink
update memory units
Browse files Browse the repository at this point in the history
update tests

apply concatenation to units in workbenches table view

update parsing logic

fix TS errors

revert to text component to initial content formatting
  • Loading branch information
jenny-s51 committed Oct 15, 2024
1 parent 63e8206 commit 8e5fff4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ describe('ClusterStorage', () => {
clusterStorageRow.findKebabAction('Edit storage').click();
updateClusterStorageModal.findNameInput().should('have.value', 'Test Storage');
updateClusterStorageModal.findPVSizeInput().should('have.value', '5');
updateClusterStorageModal.shouldHavePVSizeSelectValue('Gi');
updateClusterStorageModal.shouldHavePVSizeSelectValue('GiB');
updateClusterStorageModal.findPersistentStorageWarning().should('exist');
updateClusterStorageModal.findSubmitButton().should('be.enabled');
updateClusterStorageModal.findNameInput().fill('test-updated');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe('Workbench page', () => {
createSpawnerPage.findPVSizeInput().should('have.value', '19');
createSpawnerPage.findPVSizePlusButton().click();
createSpawnerPage.findPVSizeInput().should('have.value', '20');
createSpawnerPage.selectPVSize('Mi');
createSpawnerPage.selectPVSize('MiB');

//add existing cluster storage
createSpawnerPage.findExistingStorageRadio().click();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/projects/components/StorageSizeBars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const StorageSizeBar: React.FC<StorageSizeBarProps> = ({ pvc }) => {
);
}

const inUseValue = `${bytesAsRoundedGiB(inUseInBytes)}Gi`;
const inUseValue = `${bytesAsRoundedGiB(inUseInBytes)}GiB`;
const percentage = ((parseFloat(inUseValue) / parseFloat(maxValue)) * 100).toFixed(2);
const percentageLabel = error ? '' : `Storage is ${percentage}% full`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@ const NotebookSizeDetails: React.FC<NotebookSizeDetailsProps> = ({ notebookSize
resources: { requests, limits },
} = notebookSize;

const formatMemory = (memory: string | undefined): string => {
if (!memory) {
return 'Unknown';
}
if (/(Gi|Mi)$/.test(memory)) {
return `${memory}B`;
}
return memory;
};

return (
<DescriptionList>
<DescriptionListGroup>
<DescriptionListTerm>Limits</DescriptionListTerm>
<DescriptionListDescription>
{limits?.cpu ?? 'Unknown'} CPU, {limits?.memory ?? 'Unknown'} Memory
{limits?.cpu ?? 'Unknown'} CPU, {formatMemory(limits?.memory)} Memory
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Requests</DescriptionListTerm>
<DescriptionListDescription>
{requests?.cpu ?? 'Unknown'} CPU, {requests?.memory ?? 'Unknown'} Memory
{requests?.cpu ?? 'Unknown'} CPU, {formatMemory(requests?.memory)} Memory
</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/pages/projects/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { NotebookState } from './notebook/types';
export const getNotebookStatusPriority = (notebookState: NotebookState): number =>
notebookState.isRunning ? 1 : notebookState.isStarting ? 2 : 3;

export const getPvcTotalSize = (pvc: PersistentVolumeClaimKind): string =>
pvc.status?.capacity?.storage || pvc.spec.resources.requests.storage;
export const getPvcTotalSize = (pvc: PersistentVolumeClaimKind): string => {
const storage = pvc.status?.capacity?.storage || pvc.spec.resources.requests.storage;
return /(Gi|Mi)$/.test(storage) ? `${storage}B` : storage;
};

export const getCustomNotebookSize = (
existingNotebook: NotebookKind | undefined,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utilities/valueUnits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const CPU_UNITS: UnitOption[] = [
{ name: 'Milicores', unit: 'm', weight: 1 },
];
export const MEMORY_UNITS_FOR_SELECTION: UnitOption[] = [
{ name: 'Gi', unit: 'Gi', weight: 1024 },
{ name: 'Mi', unit: 'Mi', weight: 1 },
{ name: 'GiB', unit: 'Gi', weight: 1024 },
{ name: 'MiB', unit: 'Mi', weight: 1 },
];
export const MEMORY_UNITS_FOR_PARSING: UnitOption[] = [
{ name: 'EB', unit: 'E', weight: 1000 ** 6 },
Expand Down

0 comments on commit 8e5fff4

Please sign in to comment.