Skip to content

Commit

Permalink
Pass valid securityContext to tenant patch when multiple pools are pr…
Browse files Browse the repository at this point in the history
…esent. This is necessary to enable editing of pools when multiple are present.
  • Loading branch information
allanrogerr committed Jan 24, 2024
1 parent ed454ec commit 6b21879
Showing 1 changed file with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import { getDefaultAffinity, getNodeSelector } from "../../../utils";
import { resetEditPoolForm } from "../editPoolSlice";
import { getTenantAsync } from "../../../../thunks/tenantDetailsAsync";
import { api } from "../../../../../../../api";
import {
Pool,
PoolUpdateRequest,
SecurityContext,
} from "../../../../../../../api/operatorApi";
import { Pool, PoolUpdateRequest } from "../../../../../../../api/operatorApi";

export const editPoolAsync = createAsyncThunk(
"editPool/editPoolAsync",
Expand Down Expand Up @@ -82,28 +78,31 @@ export const editPoolAsync = createAsyncThunk(
const tolerationValues = tolerations.filter(
(toleration) => toleration.key.trim() !== "",
);

const cleanPools = tenant?.pools
?.filter((pool) => pool.name !== selectedPool)
.map((pool) => {
let securityContextOption: SecurityContext | null = null;

if (pool.securityContext) {
if (securityContextEnabled && pool.securityContext) {
if (
!!pool.securityContext.runAsUser ||
!!pool.securityContext.runAsGroup ||
!!pool.securityContext.fsGroup
pool.securityContext.runAsUser ||
pool.securityContext.runAsGroup ||
pool.securityContext.fsGroup
) {
securityContextOption = { ...pool.securityContext };
return pool;
}
}

const request = pool;
if (securityContextOption) {
request.securityContext = securityContextOption!;
}

return request;
return {
name: pool.name,
servers: pool.servers,
volumes_per_server: pool.volumes_per_server,
volume_configuration: pool.volume_configuration,
resources: pool.resources,
node_selector: pool.node_selector,
affinity: pool.affinity,
runtimeClassName: pool.runtimeClassName,
tolerations: pool.tolerations,
securityContext: undefined,
};
}) as Pool[];

let runtimeClass = {};
Expand Down

0 comments on commit 6b21879

Please sign in to comment.