Skip to content
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

upcoming: [M3-8613] - Restrict Image Upload to regions with Object Storage #11038

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Restrict Image Upload to regions with Object Storage ([#11038](https://github.com/linode/manager/pull/11038))
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const assertProcessing = (label: string, id: string) => {
* @param label - Label to apply to uploaded image.
*/
const uploadImage = (label: string) => {
const region = chooseRegion();
const region = chooseRegion({ capabilities: ['Object Storage'] });
const upload = 'machine-images/test-image.gz';
cy.visitWithLogin('/images/create/upload');
getClick('[id="label"][data-testid="textfield-input"]').type(label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const RegionSelect = <
disabledRegions: disabledRegionsFromProps,
errorText,
helperText,
ignoreAccountAvailability,
label,
onChange,
placeholder,
Expand All @@ -67,7 +68,7 @@ export const RegionSelect = <
const {
data: accountAvailability,
isLoading: accountAvailabilityLoading,
} = useAllAccountAvailabilitiesQuery();
} = useAllAccountAvailabilitiesQuery(!ignoreAccountAvailability);

const regionOptions = getRegionOptions({
currentCapability,
Expand All @@ -86,6 +87,7 @@ export const RegionSelect = <
acc[region.id] = disabledRegionsFromProps[region.id];
}
if (
!ignoreAccountAvailability &&
isRegionOptionUnavailable({
accountAvailabilityData: accountAvailability,
currentCapability,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ export interface RegionSelectProps<
* The specified capability to filter the regions on. Any region that does not have the `currentCapability` will not appear in the RegionSelect dropdown.
* Only use `undefined` for situations where there is no relevant capability for the RegionSelect - this will not filter any of the regions passed in.
* Otherwise, a capability should always be passed in.
*
* See `ImageUpload.tsx` for an example of a RegionSelect with an undefined `currentCapability` - there is no capability associated with Images yet.
*/
currentCapability: Capabilities | undefined;
/**
* A key/value object for disabling regions by their ID.
*/
disabledRegions?: Record<string, DisableRegionOption>;
helperText?: string;
/**
* Ignores account availability information when rendering region options
* @default false
*/
ignoreAccountAvailability?: boolean;
Copy link
Member Author

@bnussman-akamai bnussman-akamai Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are simply using "Object Storage" as the capability.
We only want to show regions with "Object Storage" because Images Gen2 uses Object Storage under the hood.

We want to make sure we don't want to take the customer's Object Storage availability into account because it isn't representative of their ability to upload images.

label?: string;
regionFilter?: RegionFilterValue;
regions: Region[];
Expand Down
1 change: 1 addition & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface Flags {
databases: boolean;
dbaasV2: BetaFeatureFlag;
disableLargestGbPlans: boolean;
disallowImageUploadToNonObjRegions: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using a dedicated flag for this because I've been having a hard time getting an exact timeline for when this needs to be live.

It aligns with the API's feature flag

gecko2: GeckoFeatureFlag;
gpuv2: gpuV2;
imageServiceGen2: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,21 @@ export const ImageUpload = () => {
<Controller
render={({ field, fieldState }) => (
<RegionSelect
currentCapability={
flags.disallowImageUploadToNonObjRegions
? 'Object Storage'
: undefined
}
disabled={
isImageCreateRestricted || form.formState.isSubmitting
}
textFieldProps={{
inputRef: field.ref,
onBlur: field.onBlur,
}}
currentCapability={undefined}
disableClearable
errorText={fieldState.error?.message}
ignoreAccountAvailability
label="Region"
onChange={(e, region) => field.onChange(region.id)}
regionFilter="core" // Images service will not be supported for Gecko Beta
Expand Down