Skip to content

Commit

Permalink
chore: remove useless API (kubesphere#4311) (#5208)
Browse files Browse the repository at this point in the history
* chore: remove api /configs/gpu/kinds from server



* chore: remove api /clusterconfigurations?name=ks-installer from server



---------

Signed-off-by: donniean <[email protected]>
  • Loading branch information
donniean authored Sep 25, 2024
1 parent e2604d7 commit 10a92bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 61 deletions.
18 changes: 6 additions & 12 deletions server/controllers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const {
getK8sRuntime,
getOAuthInfo,
getClusterRole,
getSupportGpuList,
getInstallerSpec,
getTheme,
} = require('../services/session');

Expand Down Expand Up @@ -182,26 +180,24 @@ const renderView = async ctx => {
const clusterRole = await getClusterRole(ctx);
const ksConfig = await getKSConfig(ctx);

const [user, runtime, supportGpuType, installer, installedExtensions] = await Promise.all([
const [user, runtime, installedExtensions] = await Promise.all([
getCurrentUser(ctx, clusterRole, ksConfig.multicluster),
getK8sRuntime(ctx),
getSupportGpuList(ctx),
getInstallerSpec(ctx),
getInstalledExtensions(ctx),
]);

await renderIndex(ctx, {
ksConfig: {
...ksConfig,
metrics_server: get(installer, 'metrics_server.enabled', false),
metrics_server: false,
},
user,
runtime,
clusterRole,
installedExtensions,
config: {
...clientConfig,
supportGpuType: [...supportGpuType, ...clientConfig.supportGpuType],
supportGpuType: [...clientConfig.supportGpuType],
},
});
} catch (err) {
Expand All @@ -214,24 +210,22 @@ const renderV3View = async ctx => {
const clusterRole = await getClusterRole(ctx);
const ksConfig = await getKSConfig(ctx);

const [user, runtime, supportGpuType, installer] = await Promise.all([
const [user, runtime] = await Promise.all([
getCurrentUser(ctx, clusterRole, ksConfig.multicluster),
getK8sRuntime(ctx),
getSupportGpuList(ctx),
getInstallerSpec(ctx),
]);

await renderV3Index(ctx, {
ksConfig: {
...ksConfig,
metrics_server: get(installer, 'metrics_server.enabled', false),
metrics_server: false,
},
user,
runtime,
clusterRole,
config: {
...clientConfig,
supportGpuType: [...supportGpuType, ...clientConfig.supportGpuType],
supportGpuType: [...clientConfig.supportGpuType],
},
});
} catch (err) {
Expand Down
49 changes: 0 additions & 49 deletions server/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,32 +404,6 @@ const getClusterRole = async ctx => {
return role;
};

const getSupportGpuList = async ctx => {
const token = ctx.cookies.get('token');
let gpuKinds = [];
if (!token) {
return [];
}
try {
const list = await sendGatewayRequest({
method: 'GET',
url: '/kapis/config.kubesphere.io/v1alpha2/configs/gpu/kinds',
token,
});
if (Array.isArray(list)) {
const defaultGpu = list.filter(item => item.default).map(item => item.resourceName);

const otherGpus = list.filter(item => !item.default).map(item => item.resourceName);

gpuKinds = [...defaultGpu, ...otherGpus];
}
} catch (error) {
console.error(error);
}

return gpuKinds;
};

const getOAuthInfo = async () => {
let resp = [];
try {
Expand Down Expand Up @@ -511,27 +485,6 @@ const createUser = (params, token) => {
});
};

const getInstallerSpec = async ctx => {
const token = ctx.cookies.get('token');
if (!token) {
return {};
}

try {
const result = await sendGatewayRequest({
method: 'GET',
url: `/apis/installer.kubesphere.io/v1alpha1/clusterconfigurations?name=ks-installer`,
token,
});

return result.items[0].spec;
} catch (error) {
console.error(error);
}

return {};
};

const getTheme = async () => {
try {
const theme = await sendGatewayRequest({
Expand Down Expand Up @@ -566,7 +519,5 @@ module.exports = {
getK8sRuntime,
createUser,
getClusterRole,
getSupportGpuList,
getInstallerSpec,
getTheme,
};

0 comments on commit 10a92bf

Please sign in to comment.