diff --git a/.changeset/orange-beans-explain.md b/.changeset/orange-beans-explain.md new file mode 100644 index 0000000000..308d3a531e --- /dev/null +++ b/.changeset/orange-beans-explain.md @@ -0,0 +1,9 @@ +--- +"@scow/portal-server": patch +"@scow/portal-web": patch +"@scow/config": patch +"@scow/lib-server": patch +"@scow/lib-web": patch +--- + +修复门户系统集群登录节点只配置地址时路由渲染失败的问题,在集群配置接口返回中加入 scowd 配置信息 diff --git a/apps/mis-server/src/services/misConfig.ts b/apps/mis-server/src/services/misConfig.ts index c9bb764602..f0be6550f8 100644 --- a/apps/mis-server/src/services/misConfig.ts +++ b/apps/mis-server/src/services/misConfig.ts @@ -18,9 +18,6 @@ import { ClusterRuntimeInfo_LastActivationOperation, import { getActivatedClusters, getClustersRuntimeInfo } from "src/bl/clustersUtils"; import { Cluster, ClusterActivationStatus } from "src/entities/Cluster"; -/** - * @deprecated Use the new API function GetAvailablePartitionsForCluster From configServiceServer instead. - */ export const misConfigServiceServer = plugin((server) => { server.addService(ConfigServiceService, { diff --git a/apps/portal-server/tests/file/utils.ts b/apps/portal-server/tests/file/utils.ts index b01485f51a..6c86fd9a17 100644 --- a/apps/portal-server/tests/file/utils.ts +++ b/apps/portal-server/tests/file/utils.ts @@ -11,8 +11,8 @@ */ import { ServiceError } from "@grpc/grpc-js"; +import { LoginNode } from "@scow/config/build/cluster"; import { I18nStringType } from "@scow/config/build/i18n"; -import { LoginNodesType } from "@scow/config/build/type"; import { sftpWriteFile, sshRawConnect, sshRmrf } from "@scow/lib-ssh"; import { ClusterConfigSchemaProto_LoginNodesProtoType } from "@scow/protos/build/common/config"; import { I18nStringProtoType } from "@scow/protos/build/common/i18n"; @@ -190,16 +190,21 @@ export const getI18nTypeFormat = (i18nProtoType: I18nStringProtoType | undefined // protobuf中定义的grpc返回值的loginNodes类型映射到前端loginNode export const getLoginNodesTypeFormat = ( - protoType: ClusterConfigSchemaProto_LoginNodesProtoType | undefined): LoginNodesType => { + protoType: ClusterConfigSchemaProto_LoginNodesProtoType | undefined): LoginNode[] => { if (!protoType?.value) return []; if (protoType.value.$case === "loginNodeAddresses") { - return protoType.value.loginNodeAddresses.loginNodeAddressesValue; + return protoType.value.loginNodeAddresses.loginNodeAddressesValue.map((x) => ({ + name: x, + address: x, + scowdPort: undefined, + })); } else { const loginNodeConfigs = protoType.value.loginNodeConfigs; return loginNodeConfigs.loginNodeConfigsValue.map((x) => ({ name: getI18nTypeFormat(x.name), address: x.address, + scowdPort: x.scowd?.port, })); } diff --git a/apps/portal-web/config.js b/apps/portal-web/config.js index d1376b436f..9af7313b33 100644 --- a/apps/portal-web/config.js +++ b/apps/portal-web/config.js @@ -108,8 +108,6 @@ const buildRuntimeConfig = async (phase, basePath) => { const configPath = mockEnv ? join(__dirname, "config") : undefined; - // Object.keys(clusters).map((id) => clusters[id].loginNodes = clusters[id].loginNodes.map(getLoginNode)); - const uiConfig = getUiConfig(configPath, console); const portalConfig = getPortalConfig(configPath, console); const commonConfig = getCommonConfig(configPath, console); @@ -126,7 +124,7 @@ const buildRuntimeConfig = async (phase, basePath) => { DEFAULT_PRIMARY_COLOR, MOCK_USER_ID: config.MOCK_USER_ID, UI_CONFIG: uiConfig, - // 当前SCOW未使用? + // 当前SCOW未使用 // LOGIN_NODES: parseKeyValue(config.LOGIN_NODES), SERVER_URL: config.SERVER_URL, SUBMIT_JOB_WORKING_DIR: portalConfig.submitJobDefaultPwd, diff --git a/apps/portal-web/src/layouts/routes.tsx b/apps/portal-web/src/layouts/routes.tsx index 419c08f8b0..8de2595154 100644 --- a/apps/portal-web/src/layouts/routes.tsx +++ b/apps/portal-web/src/layouts/routes.tsx @@ -33,7 +33,7 @@ export const userRoutes: ( user: User | undefined, currentClusters: Cluster[], defaultCluster: Cluster | undefined, - LoginNodes: Record, + loginNodes: Record, enableLoginDesktop: boolean, crossClusterFileTransferEnabled: boolean, setDefaultCluster: (cluster: Cluster | undefined) => void, diff --git a/apps/portal-web/src/pages/api/getClusterConfigFiles.ts b/apps/portal-web/src/pages/api/getClusterConfigFiles.ts index a3b9381fb1..47a92b2460 100644 --- a/apps/portal-web/src/pages/api/getClusterConfigFiles.ts +++ b/apps/portal-web/src/pages/api/getClusterConfigFiles.ts @@ -60,6 +60,7 @@ export default route(getClusterConfigFilesSchema, if (!info) { return; } const modifiedClusters: Record = await getClusterConfigFiles(); + return { 200: { clusterConfigs: modifiedClusters }, }; diff --git a/libs/config/src/cluster.ts b/libs/config/src/cluster.ts index f7972e38f5..8b1c36f28c 100644 --- a/libs/config/src/cluster.ts +++ b/libs/config/src/cluster.ts @@ -25,7 +25,7 @@ export enum k8sRuntime { const LoginNodeConfigSchema = Type.Object({ name: createI18nStringSchema({ description: "登录节点展示名" }), - address: Type.String({ description: "集群的登录节点地址" }), + address: Type.String({ description: "集群的登录节点地址" }), scowd: Type.Optional(Type.Object({ port: Type.Number({ description: "scowd 端口号" }), }, { description: "scowd 相关配置" })), @@ -33,7 +33,7 @@ const LoginNodeConfigSchema = Type.Object({ export type LoginNodeConfigSchema = Static; -interface LoginNode { +export interface LoginNode { name: I18nStringType; address: string; scowdPort?: number; diff --git a/libs/config/src/type.ts b/libs/config/src/type.ts index 9a03eae03d..33eb932a36 100644 --- a/libs/config/src/type.ts +++ b/libs/config/src/type.ts @@ -32,11 +32,3 @@ export const ClusterRuntimeInfoSchema = Type.Object({ }); export type ClusterRuntimeInfo = Static; - - -export type LoginNodesType = string[] | - { - name: I18nStringType, - address: string, - }[]; - diff --git a/libs/server/src/typeConversion.ts b/libs/server/src/typeConversion.ts index 79381ea86d..9287cdfb84 100644 --- a/libs/server/src/typeConversion.ts +++ b/libs/server/src/typeConversion.ts @@ -10,11 +10,9 @@ * See the Mulan PSL v2 for more details. */ -import { ClusterConfigSchema } from "@scow/config/build/cluster"; +import { ClusterConfigSchema, LoginNodeConfigSchema } from "@scow/config/build/cluster"; import { I18nStringType } from "@scow/config/build/i18n"; -import { LoginNodesType } from "@scow/config/build/type"; import { ClusterConfigSchemaProto, clusterConfigSchemaProto_K8sRuntimeFromJSON, - ClusterConfigSchemaProto_LoginNodeConfigSchemaProto, ClusterConfigSchemaProto_LoginNodesProtoType } from "@scow/protos/build/common/config"; import { I18nStringProtoType } from "@scow/protos/build/common/i18n"; @@ -44,7 +42,7 @@ export const getI18nSeverTypeFormat = (i18nConfig: I18nStringType): I18nStringPr } }; -export const getLoginNodesSeverTypeFormat = (loginNodes: LoginNodesType): +export const getLoginNodesSeverTypeFormat = (loginNodes: string[] | LoginNodeConfigSchema[]): ClusterConfigSchemaProto_LoginNodesProtoType | undefined => { if (!loginNodes) return undefined; @@ -57,7 +55,8 @@ ClusterConfigSchemaProto_LoginNodesProtoType | undefined => { loginNodeConfigs: { loginNodeConfigsValue: loginNodes.map((node) => ({ name: getI18nSeverTypeFormat(node.name)!, address: node.address, - })) as ClusterConfigSchemaProto_LoginNodeConfigSchemaProto[] }, + scowd: node.scowd, + })) }, } }; } }; diff --git a/libs/web/src/utils/typeConversion.ts b/libs/web/src/utils/typeConversion.ts index 98c5145347..5747673615 100644 --- a/libs/web/src/utils/typeConversion.ts +++ b/libs/web/src/utils/typeConversion.ts @@ -10,9 +10,8 @@ * See the Mulan PSL v2 for more details. */ -import { ClusterConfigSchema } from "@scow/config/build/cluster"; +import { ClusterConfigSchema, LoginNodeConfigSchema } from "@scow/config/build/cluster"; import { I18nStringType } from "@scow/config/build/i18n"; -import { LoginNodesType } from "@scow/config/build/type"; import { ClusterConfigSchemaProto, clusterConfigSchemaProto_K8sRuntimeToJSON, ClusterConfigSchemaProto_LoginNodesProtoType } from "@scow/protos/build/common/config"; import { I18nStringProtoType } from "@scow/protos/build/common/i18n"; @@ -40,17 +39,24 @@ export const getI18nTypeFormat = (i18nProtoType: I18nStringProtoType | undefined // protobuf中定义的grpc返回值的loginNodes类型映射到前端loginNode export const getLoginNodesTypeFormat = ( - protoType: ClusterConfigSchemaProto_LoginNodesProtoType | undefined): LoginNodesType => { + protoType: ClusterConfigSchemaProto_LoginNodesProtoType | undefined): LoginNodeConfigSchema[] => { if (!protoType?.value) return []; if (protoType.value.$case === "loginNodeAddresses") { - return protoType.value.loginNodeAddresses.loginNodeAddressesValue; + return protoType.value.loginNodeAddresses.loginNodeAddressesValue.map((item) => ({ + name: item, + address: item, + scowd: undefined, + })); } else { const loginNodeConfigs = protoType.value.loginNodeConfigs; + return loginNodeConfigs.loginNodeConfigsValue.map((x) => ({ name: getI18nTypeFormat(x.name), address: x.address, + scowd: x.scowd, })); + } }; @@ -65,8 +71,7 @@ export const getClusterConfigsTypeFormat = ( const newCluster = { ...rest, displayName: getI18nTypeFormat(cluster.displayName), - loginNodes: getLoginNodesTypeFormat( - cluster.loginNodes), + loginNodes: getLoginNodesTypeFormat(cluster.loginNodes), k8s: cluster.k8s ? { k8sRuntime: clusterConfigSchemaProto_K8sRuntimeToJSON(cluster.k8s.runtime).toLowerCase(), kubeconfig: cluster.k8s.kubeconfig,