-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: [M3-7382] - Use object-storage/types
endpoint for pricing data
#10468
refactor: [M3-7382] - Use object-storage/types
endpoint for pricing data
#10468
Conversation
2d092a7
to
c1d423a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the other object-storage endpoint files seemed like a good fit for this, so I created a new file, prices.ts
. I didn't name it types.ts
, since that's another file. This seemed like the most straight-forward way to add the new endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these constants are old and can be cleaned up. They were leftovers from earlier stages of the project, pre-full GA.
? objectStoragePriceIncreaseMap[regionId].storage_overage | ||
: OBJ_STORAGE_PRICE.storage_overage}{' '} | ||
{storageOveragePrice && !isError | ||
? parseFloat(storageOveragePrice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using parseFloat
here to truncate trailing zeros - e.g. we will display $0.02 and not $0.020, but otherwise display to 3 decimal places for the other overage prices.
it('displays placeholder unknown pricing and disables the primary action button if pricing is not available', () => { | ||
queryMocks.useObjectStorageTypesQuery.mockReturnValue({ | ||
data: undefined, | ||
isError: true, | ||
}); | ||
|
||
const { getByTestId, getByText } = render( | ||
wrapWithTheme(<EnableObjectStorageModal regionId="us-east" {...props} />) | ||
); | ||
|
||
const primaryActionButton = getByTestId('enable-obj'); | ||
|
||
expect(getByText(`${UNKNOWN_PRICE}/month`, { exact: false })).toBeVisible(); | ||
expect(primaryActionButton).toBeDisabled(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the UI in this state would require manually manipulating the code, since you can't Create Bucket if prices are invalid, and therefore would not be able to get to this modal. We can confirm error state for invalid pricing in the Enable Object Storage modal works with this test case passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates to this function were to account for the object storage storage overages, which are displayed by their hourly rate. Previously, this util was not flexible enough and calculated only monthly prices and only to a fixed 2 decimal places.
Coverage Report: ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed pricing matches production ✅
packages/manager/src/features/ObjectStorage/BucketLanding/CreateBucketDrawer.tsx
Outdated
Show resolved
Hide resolved
monthly: 5.0, | ||
}, | ||
], | ||
transfer: 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specific to your work, just curious to know what transfer
represents in the payload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the 1TB transfer quota (added to the global network transfer pool) that comes with enabling Object Storage. (Docs)
queryFn: getAllObjectStorageTypes, | ||
queryKey: [queryKey, 'types'], | ||
...queryPresets.oneTimeFetch, | ||
enabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we determine whether enabled
should be true
or false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified the functionality works as expected and test passed locally. I left two questions/comments but those are for my own knowledge. ✅
@@ -19,13 +19,15 @@ import { | |||
useCreateBucketMutation, | |||
useObjectStorageBuckets, | |||
useObjectStorageClusters, | |||
useObjectStorageTypesQuery, | |||
} from 'src/queries/objectStorage'; | |||
import { useProfile } from 'src/queries/profile'; | |||
import { useRegionsQuery } from 'src/queries/regions/regions'; | |||
import { isFeatureEnabled } from 'src/utilities/accountCapabilities'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this, isFeatureEnabled
has been deprecated in favor of isFeatureEnabledV2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Out of scope of this PR, though.
Description 📝
API is now returning pricing data through the
/object-storage/types
endpoint.In this PR, prices can be dynamically displayed for base region pricing and DC-specific region pricing, using the prices returned in the new endpoint, for Object Storage.
Note
Outbound transfer overages will be done in a follow-up PR, since pricing for network transfer overages is the same across Cloud Manager and not currently being returned by the API. They are creating a new endpoint for this.
Changes 🔄
getDCSpecificPriceByType
to optionally accept interval (hourly or monthly) and decimal precision params and updated util unit test accordingly.Target release date 🗓️
5/28/24
Preview 📷
Screen.Recording.2024-05-17.at.12.48.28.AM.mov
How to test 🧪
Prerequisites
(How to setup test environment)
yarn up
.Verification steps
(How to verify changes)
us-east
)./types
. Confirm the "additional storage overage" pricing is consistent with the overage pricing returned by the API endpoint AND that price is consistent with prod.br-gru
) and Jakarta (id-cgk
).object-storage/types
endpoint.As an Author I have considered 🤔
Check all that apply