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

Added runtime class name selector #2626

Merged
merged 2 commits into from
Feb 2, 2023
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
Expand Up @@ -170,6 +170,12 @@ const Configure = ({ classes }: IConfigureProps) => {
(state: AppState) =>
state.createTenant.fields.configure.tenantSecurityContext
);
const customRuntime = useSelector(
(state: AppState) => state.createTenant.fields.configure.customRuntime
);
const runtimeClassName = useSelector(
(state: AppState) => state.createTenant.fields.configure.runtimeClassName
);

const [validationErrors, setValidationErrors] = useState<any>({});

Expand Down Expand Up @@ -561,6 +567,47 @@ const Configure = ({ classes }: IConfigureProps) => {
</fieldset>
</Grid>
)}
<Grid item xs={12} className={classes.configSectionItem}>
<FormSwitchWrapper
value="customRuntime"
id="tenant_custom_runtime"
name="tenant_custom_runtime"
checked={customRuntime}
onChange={(e) => {
const targetD = e.target;
const checked = targetD.checked;

updateField("customRuntime", checked);
}}
label={"Custom Runtime Configurations"}
/>
</Grid>
{customRuntime && (
<Grid item xs={12} className={classes.tenantCustomizationFields}>
<fieldset className={classes.fieldGroup}>
<legend className={classes.descriptionText}>
Custom Runtime Configurations
</legend>
<Grid item xs={12} className={`${classes.configSectionItem}`}>
<div className={classes.containerItem}>
<InputBoxWrapper
id="tenant_runtime_runtimeClassName"
name="tenant_runtime_runtimeClassName"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("runtimeClassName", e.target.value);
cleanValidation("tenant_runtime_runtimeClassName");
}}
label="Runtime Class Name"
value={runtimeClassName}
error={
validationErrors["tenant_runtime_runtimeClassName"] || ""
}
/>
</div>
</Grid>
</fieldset>
</Grid>
)}
<Divider />

<div className={classes.headerElement}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const NameTenantMain = ({ classes, formToRender }: INameTenantMainScreen) => {
return (
<Fragment>
<Grid container>
<Grid item sx={{ width: "calc(100% - 300px)" }}>
<Grid item sx={{ width: "calc(100% - 320px)" }}>
<Paper className={classes.paperWrapper} sx={{ minHeight: 550 }}>
<Grid container>
<Grid item xs={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ const initialState: ICreateTenant = {
exposeMinIO: true,
exposeConsole: true,
tenantCustom: false,
customRuntime: false,
runtimeClassName: "",
envVars: [{ key: "", value: "" }],
logSearchEnabled: false,
prometheusEnabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export const createTenantAsync = createAsyncThunk(
const minioDomains = fields.configure.minioDomains;
const consoleDomain = fields.configure.consoleDomain;
const environmentVariables = fields.configure.envVars;
const customRuntime = fields.configure.customRuntime;
const runtimeClassName = fields.configure.runtimeClassName;

let tolerations = state.createTenant.tolerations;
let namespace = state.createTenant.fields.nameTenant.namespace;
Expand Down Expand Up @@ -171,6 +173,14 @@ export const createTenantAsync = createAsyncThunk(

const erasureCode = ecParity.split(":")[1];

let runtimeClass = {};

if (customRuntime) {
runtimeClass = {
runtimeClassName,
};
}

let dataSend: ITenantCreator = {
name: tenantName,
namespace: namespace,
Expand All @@ -195,8 +205,9 @@ export const createTenantAsync = createAsyncThunk(
storage_class_name: selectedStorageClass,
},
securityContext: tenantCustom ? tenantSecurityContext : null,
...affinityObject,
tolerations: tolerationValues,
...affinityObject,
...runtimeClass,
},
],
erasureCodingParity: parseInt(erasureCode, 10),
Expand Down
1 change: 1 addition & 0 deletions portal-ui/src/screens/Console/Tenants/ListTenants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface IPool {
affinity?: IAffinityModel;
tolerations?: ITolerationModel[];
securityContext?: ISecurityContext | null;
runtimeClassName: string;
}

export interface IPodListElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ const PoolConfiguration = ({ classes }: IConfigureProps) => {
const securityContext = useSelector(
(state: AppState) => state.addPool.configuration.securityContext
);
const customRuntime = useSelector(
(state: AppState) => state.addPool.configuration.customRuntime
);
const runtimeClassName = useSelector(
(state: AppState) => state.addPool.configuration.runtimeClassName
);

const [validationErrors, setValidationErrors] = useState<any>({});

Expand Down Expand Up @@ -276,6 +282,52 @@ const PoolConfiguration = ({ classes }: IConfigureProps) => {
</fieldset>
</Grid>
)}
<Grid
item
xs={12}
className={classes.configSectionItem}
sx={{ marginTop: "10px" }}
>
<FormSwitchWrapper
value="customRuntime"
id="tenant_custom_runtime"
name="tenant_custom_runtime"
checked={customRuntime}
onChange={(e) => {
const targetD = e.target;
const checked = targetD.checked;

updateField("customRuntime", checked);
}}
label={"Custom Runtime Configurations"}
/>
</Grid>
{customRuntime && (
<Grid item xs={12} className={classes.tenantCustomizationFields}>
<fieldset className={classes.fieldGroup}>
<legend className={classes.descriptionText}>
Custom Runtime Configurations
</legend>
<Grid item xs={12} className={`${classes.configSectionItem}`}>
<div className={classes.containerItem}>
<InputBoxWrapper
id="tenant_runtime_runtimeClassName"
name="tenant_runtime_runtimeClassName"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("runtimeClassName", e.target.value);
cleanValidation("tenant_runtime_runtimeClassName");
}}
label="Runtime Class Name"
value={runtimeClassName}
error={
validationErrors["tenant_runtime_runtimeClassName"] || ""
}
/>
</div>
</Grid>
</fieldset>
</Grid>
)}
</Paper>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const initialState: IAddPool = {
fsGroupChangePolicy: "Always",
runAsNonRoot: true,
},
customRuntime: false,
runtimeClassName: "",
},
nodeSelectorPairs: [{ key: "", value: "" }],
tolerations: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const addPoolAsync = createAsyncThunk(
const securityContextEnabled =
state.addPool.configuration.securityContextEnabled;
const securityContext = state.addPool.configuration.securityContext;
const customRuntime = state.addPool.configuration.customRuntime;
const runtimeClassName = state.addPool.configuration.runtimeClassName;

if (tenant === null) {
return;
}
Expand Down Expand Up @@ -72,6 +75,14 @@ export const addPoolAsync = createAsyncThunk(
(toleration) => toleration.key.trim() !== ""
);

let runtimeClass = {};

if (customRuntime) {
runtimeClass = {
runtimeClassName,
};
}

const data: IAddPoolRequest = {
name: poolName,
servers: numberOfNodes,
Expand All @@ -84,6 +95,7 @@ export const addPoolAsync = createAsyncThunk(
tolerations: tolerationValues,
securityContext: securityContextEnabled ? securityContext : null,
...affinityObject,
...runtimeClass,
};
const poolsURL = `/namespaces/${tenant?.namespace || ""}/tenants/${
tenant?.name || ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ const PoolDetails = () => {
);
};

console.log(poolInformation);

return (
<Fragment>
<Grid item xs={12} sx={{ ...stylingLayout }}>
Expand Down Expand Up @@ -108,6 +110,10 @@ const PoolDetails = () => {
value={poolInformation.volumes_per_server}
/>
<LabelValuePair label={"Capacity"} value={poolInformation.capacity} />
<LabelValuePair
label={"Runtime Class Name"}
value={poolInformation.runtimeClassName}
/>
</Box>
<HeaderSection title={"Resources"} />
<Box sx={{ ...twoColCssGridLayoutConfig }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ const PoolConfiguration = ({ classes }: IConfigureProps) => {
const securityContext = useSelector(
(state: AppState) => state.editPool.fields.configuration.securityContext
);
const customRuntime = useSelector(
(state: AppState) => state.editPool.fields.configuration.customRuntime
);
const runtimeClassName = useSelector(
(state: AppState) => state.editPool.fields.configuration.runtimeClassName
);

const [validationErrors, setValidationErrors] = useState<any>({});

Expand Down Expand Up @@ -275,6 +281,52 @@ const PoolConfiguration = ({ classes }: IConfigureProps) => {
</fieldset>
</Grid>
)}
<Grid
item
xs={12}
className={classes.configSectionItem}
sx={{ marginTop: "10px" }}
>
<FormSwitchWrapper
value="customRuntime"
id="tenant_custom_runtime"
name="tenant_custom_runtime"
checked={customRuntime}
onChange={(e) => {
const targetD = e.target;
const checked = targetD.checked;

updateField("customRuntime", checked);
}}
label={"Custom Runtime Configurations"}
/>
</Grid>
{customRuntime && (
<Grid item xs={12} className={classes.tenantCustomizationFields}>
<fieldset className={classes.fieldGroup}>
<legend className={classes.descriptionText}>
Custom Runtime Configurations
</legend>
<Grid item xs={12} className={`${classes.configSectionItem}`}>
<div className={classes.containerItem}>
<InputBoxWrapper
id="tenant_runtime_runtimeClassName"
name="tenant_runtime_runtimeClassName"
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField("runtimeClassName", e.target.value);
cleanValidation("tenant_runtime_runtimeClassName");
}}
label="Runtime Class Name"
value={runtimeClassName}
error={
validationErrors["tenant_runtime_runtimeClassName"] || ""
}
/>
</div>
</Grid>
</fieldset>
</Grid>
)}
</Paper>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const initialState: IEditPool = {
fsGroupChangePolicy: "Always",
runAsNonRoot: true,
},
customRuntime: false,
runtimeClassName: "",
},
nodeSelectorPairs: [{ key: "", value: "" }],
tolerations: [
Expand Down Expand Up @@ -156,6 +158,8 @@ export const editPoolSlice = createSlice({
action.payload.securityContext?.fsGroupChangePolicy || "Always",
runAsNonRoot: !!action.payload.securityContext?.runAsNonRoot,
},
customRuntime: !!action.payload.runtimeClassName,
runtimeClassName: action.payload.runtimeClassName,
},
affinity: {
podAffinity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const editPoolAsync = createAsyncThunk(
const securityContextEnabled =
state.editPool.fields.configuration.securityContextEnabled;
const securityContext = state.editPool.fields.configuration.securityContext;
const customRuntime = state.editPool.fields.configuration.customRuntime;
const runtimeClassName =
state.editPool.fields.configuration.runtimeClassName;

if (!tenant) {
return;
}
Expand Down Expand Up @@ -98,6 +102,14 @@ export const editPoolAsync = createAsyncThunk(
return request;
});

let runtimeClass = {};

if (customRuntime) {
runtimeClass = {
runtimeClassName,
};
}

const data: IEditPoolRequest = {
pools: [
...cleanPools,
Expand All @@ -113,6 +125,7 @@ export const editPoolAsync = createAsyncThunk(
tolerations: tolerationValues,
securityContext: securityContextEnabled ? securityContext : null,
...affinityObject,
...runtimeClass,
},
],
};
Expand Down
4 changes: 4 additions & 0 deletions portal-ui/src/screens/Console/Tenants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export interface IConfigureFields {
exposeConsole: boolean;
prometheusEnabled: boolean;
tenantCustom: boolean;
customRuntime: boolean;
runtimeClassName: string;
envVars: LabelKeyPair[];
logSearchEnabled: boolean;
logSearchVolumeSize: string;
Expand Down Expand Up @@ -324,6 +326,8 @@ export interface IAddPoolSetup {
export interface IPoolConfiguration {
securityContextEnabled: boolean;
securityContext: ISecurityContext;
customRuntime: boolean;
runtimeClassName: string;
}

export interface ITenantIdentityProviderResponse {
Expand Down