Skip to content

Commit

Permalink
[Bug][scaleph-ui-react] fix doris deploy error (#665)
Browse files Browse the repository at this point in the history
* fix: doris operator labels error

* fix: remove doris admin user required rule

* fix: remove doris admin user required rule

* fix: remove doris adminuser when deploy

* fix: remove doris adminuser when deploy

* feature: add tooltip for doris instance steps

* feature: add tooltip for doris instance steps

---------

Co-authored-by: wangqi <[email protected]>
  • Loading branch information
kalencaya and wangqi authored Dec 16, 2023
1 parent ed42c17 commit a6466e5
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@ public enum ResourceLabels {
public static final String DORIS_GROUP = "doris.selectdb.com";
public static final String DORIS_VERSION = "v1";
public static final String DORIS_API_VERSION = DORIS_GROUP + "/" + DORIS_VERSION;
public static final String DORIS_APP_NAME = "app.kubernetes.io/name";
public static final String DORIS_APP_NAME_VALUE = "doriscluster";
public static final String DORIS_APP_INSTANCE = "app.kubernetes.io/instance";
public static final String DORIS_APP_PART_OF = "app.kubernetes.io/part-of";
public static final String DORIS_APP_PART_OF_VALUE = "doris-operator";

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.fabric8.kubernetes.client.utils.Serialization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -47,6 +48,7 @@

import static cn.sliew.milky.common.check.Ensures.checkState;

@Slf4j
@Service
public class WsDorisOperatorInstanceServiceImpl implements WsDorisOperatorInstanceService {

Expand Down Expand Up @@ -156,6 +158,10 @@ public int deleteBatch(List<Long> ids) {
public void deploy(Long id) {
WsDorisOperatorInstanceDTO instanceDTO = selectOne(id);
DorisCluster dorisCluster = asYaml(instanceDTO);
if (dorisCluster.getSpec().getAdminUser() != null) {
log.error("{} can't specify doris admin when deploy, remove it automatically", instanceDTO.getName());
dorisCluster.getSpec().setAdminUser(null);
}
String yaml = Serialization.asYaml(dorisCluster);
dorisOperatorService.deploy(instanceDTO.getClusterCredentialId(), yaml);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class WsDorisOperatorInstanceAddParam {
@Schema(description = "namespace")
private String namespace;

@NotNull
@Schema(description = "admin user")
private AdminUser admin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class WsDorisOperatorInstanceUpdateParam {
@Schema(description = "namespace")
private String namespace;

@NotNull
@Schema(description = "admin user")
private AdminUser admin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class WsDorisOperatorTemplateAddParam {
@Schema(description = "name")
private String name;

@NotNull
@Schema(description = "admin user")
private AdminUser admin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class WsDorisOperatorTemplateUpdateParam {
@Schema(description = "name")
private String name;

@NotNull
@Schema(description = "admin user")
private AdminUser admin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public DorisCluster convertTo(WsDorisOperatorInstanceDTO source) {
String name = StringUtils.hasText(source.getInstanceId()) ? source.getInstanceId() : source.getName();
builder.withName(name);
builder.withNamespace(source.getNamespace());
builder.withLabels(Map.of(ResourceLabels.SCALEPH_LABEL_NAME, source.getName()));
builder.addToLabels(ResourceLabels.SCALEPH_LABEL_NAME, source.getName());
builder.addToLabels(ResourceLabels.DORIS_APP_NAME, ResourceLabels.DORIS_APP_NAME_VALUE);
builder.addToLabels(ResourceLabels.DORIS_APP_INSTANCE, name);
builder.addToLabels(ResourceLabels.DORIS_APP_PART_OF, ResourceLabels.DORIS_APP_PART_OF_VALUE);
cluster.setMetadata(builder.build());
DorisClusterSpec spec = new DorisClusterSpec();
spec.setFeSpec(source.getFeSpec());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public DorisTemplate convertTo(WsDorisOperatorTemplateDTO source) {
ObjectMetaBuilder builder = new ObjectMetaBuilder(true);
String name = StringUtils.hasText(source.getTemplateId()) ? source.getTemplateId() : source.getName();
builder.withName(name);
builder.withLabels(Map.of(ResourceLabels.SCALEPH_LABEL_NAME, source.getName()));
builder.addToLabels(ResourceLabels.SCALEPH_LABEL_NAME, source.getName());
builder.addToLabels(ResourceLabels.DORIS_APP_NAME, ResourceLabels.DORIS_APP_NAME_VALUE);
builder.addToLabels(ResourceLabels.DORIS_APP_INSTANCE, name);
builder.addToLabels(ResourceLabels.DORIS_APP_PART_OF, ResourceLabels.DORIS_APP_PART_OF_VALUE);
template.setMetadata(builder.build());
DorisClusterSpec spec = new DorisClusterSpec();
spec.setFeSpec(source.getFeSpec());
Expand Down
4 changes: 2 additions & 2 deletions scaleph-ui-react/src/locales/zh-CN/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,6 @@ export default {
'pages.project.di.step.starrocks.scanMemLimit': '扫描内存限制(字节)',
'pages.project.di.step.starrocks.requestTabletSize': '请求Tablet大小',


// maxcompute
'pages.project.di.step.maxcompute.project': '项目',
'pages.project.di.step.maxcompute.tableName': '数据表',
Expand Down Expand Up @@ -932,7 +931,6 @@ export default {

'pages.project.doris.template': 'Template',
'pages.project.doris.template.name': '名称',
'pages.project.doris.template.define': '模板定义',
'pages.project.doris.template.steps.base': '基础信息',
'pages.project.doris.template.steps.component': '集群组件',
'pages.project.doris.template.steps.component.admin': 'Admin用户',
Expand All @@ -955,10 +953,12 @@ export default {
'pages.project.doris.instance': 'Instance',
'pages.project.doris.instance.name': '名称',
'pages.project.doris.instance.namespace': '命名空间',
'pages.project.doris.instance.namespace.tooltip': '填写 Kubernetes Namespace',
'pages.project.doris.instance.deployed': '是否部署?',
'pages.project.doris.instance.steps': '创建实例',
'pages.project.doris.instance.steps.base': '基础信息',
'pages.project.doris.instance.steps.base.cluster': 'Cluster',
'pages.project.doris.instance.steps.base.cluster.tooltip': '选择部署的 Kubernetes',
'pages.project.doris.instance.steps.base.template': 'Template',
'pages.project.doris.instance.steps.component': '集群组件',
'pages.project.doris.instance.steps.yaml': 'YAML',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ClusterCredentialService} from "@/services/resource/clusterCredential.se
import {WsDorisOperatorTemplate} from "@/services/project/typings";
import {WsDorisOperatorTemplateService} from "@/services/project/WsDorisOperatorTemplateService";
import {WORKSPACE_CONF} from "@/constants/constant";
import {InfoCircleOutlined} from "@ant-design/icons";

const DorisInstanceBase: React.FC = () => {
const intl = useIntl();
Expand All @@ -23,6 +24,10 @@ const DorisInstanceBase: React.FC = () => {
name="clusterCredentialId"
label={intl.formatMessage({id: 'pages.project.doris.instance.steps.base.cluster'})}
rules={[{required: true}]}
tooltip={{
title: intl.formatMessage({id: 'pages.project.doris.instance.steps.base.cluster.tooltip'}),
icon: <InfoCircleOutlined/>,
}}
allowClear={false}
request={((params, props) => {
const param: ClusterCredentialListParam = {
Expand All @@ -39,6 +44,10 @@ const DorisInstanceBase: React.FC = () => {
name={"namespace"}
label={intl.formatMessage({id: 'pages.project.doris.instance.namespace'})}
rules={[{required: true}]}
tooltip={{
title: intl.formatMessage({id: 'pages.project.doris.instance.namespace.tooltip'}),
icon: <InfoCircleOutlined/>,
}}
initialValue={"doris"}
/>
<ProFormSelect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useEffect} from "react";
import {ProCard} from "@ant-design/pro-components";
import DorisFeComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisFeComponent";
import DorisAdminUser from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisAdminUser";
import DorisBeComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisBeComponent";
import DorisCnComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisCnComponent";
import {connect} from "umi";
Expand All @@ -19,7 +18,6 @@ const DorisInstanceComponent: React.FC = (props: any) => {

return (
<ProCard>
<DorisAdminUser/>
<DorisFeComponent/>
<DorisBeComponent/>
<DorisCnComponent/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const DorisInstanceWeb: React.FC = () => {
</Tooltip>
)}
{access.canAccess(PRIVILEGE_CODE.datadevJobEdit) && (
<Tooltip title={intl.formatMessage({id: 'pages.project.doris.template.define'})}>
<Tooltip title={intl.formatMessage({id: 'pages.project.doris.instance.detail'})}>
<Button
shape="default"
type="link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ const DorisAdminUser: React.FC = () => {
name="admin.name"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.admin.name'})}
colProps={{span: 10, offset: 1}}
rules={[{required: true}]}
initialValue={"admin"}
/>
<ProFormText
name="admin.password"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.admin.password'})}
colProps={{span: 10, offset: 1}}
rules={[{required: true}]}
initialValue={"Admin123"}
/>
</ProFormGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {useIntl} from "umi";
import {ProCard, ProFormDigit, ProFormGroup, ProFormList, ProFormText} from "@ant-design/pro-components";
import {ProCard, ProFormDigit, ProFormGroup, ProFormText} from "@ant-design/pro-components";

const DorisFeComponent: React.FC = () => {
const intl = useIntl();

return (<ProCard
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.be'})}
headerBordered
collapsible={true}
defaultCollapsed>
collapsible={true}>
<ProFormGroup>
<ProFormDigit
name="be.replicas"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const DorisFeComponent: React.FC = () => {
name="cn.replicas"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.replicas'})}
colProps={{span: 10, offset: 1}}
initialValue={3}
fieldProps={{
min: 1
}}
Expand All @@ -23,13 +22,11 @@ const DorisFeComponent: React.FC = () => {
name="cn.image"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.image'})}
colProps={{span: 10, offset: 1}}
initialValue={"selectdb/doris.be-ubuntu:2.0.2"}
/>
<ProFormDigit
name="cn.requests.cpu"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.cpu'})}
colProps={{span: 10, offset: 1}}
initialValue={8}
fieldProps={{
min: 1
}}
Expand All @@ -38,13 +35,11 @@ const DorisFeComponent: React.FC = () => {
name="cn.requests.memory"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.requests.memory'})}
colProps={{span: 10, offset: 1}}
initialValue={"16Gi"}
/>
<ProFormDigit
name="cn.limits.cpu"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.cpu'})}
colProps={{span: 10, offset: 1}}
initialValue={16}
fieldProps={{
min: 1
}}
Expand All @@ -53,7 +48,6 @@ const DorisFeComponent: React.FC = () => {
name="cn.limits.memory"
label={intl.formatMessage({id: 'pages.project.doris.template.steps.component.base.limits.memory'})}
colProps={{span: 10, offset: 1}}
initialValue={"32Gi"}
/>
</ProFormGroup>
</ProCard>);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {useIntl} from "umi";
import {ProCard, ProFormDigit, ProFormGroup, ProFormList, ProFormText} from "@ant-design/pro-components";
import {ProCard, ProFormDigit, ProFormGroup, ProFormText} from "@ant-design/pro-components";

const DorisFeComponent: React.FC = () => {
const intl = useIntl();

return (<ProCard
title={intl.formatMessage({id: 'pages.project.doris.template.steps.component.fe'})}
headerBordered
collapsible={true}
defaultCollapsed>
collapsible={true}>
<ProFormGroup>
<ProFormDigit
name="fe.replicas"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from "react";
import {ProCard} from "@ant-design/pro-components";
import DorisFeComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisFeComponent";
import DorisAdminUser from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisAdminUser";
import DorisBeComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisBeComponent";
import DorisCnComponent from "@/pages/Project/Workspace/Doris/OperatorTemplate/Steps/Component/DorisCnComponent";

const DorisTemplateComponent: React.FC = () => {
return (
<ProCard>
<DorisAdminUser/>
<DorisFeComponent/>
<DorisBeComponent/>
<DorisCnComponent/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const DorisTemplateWeb: React.FC = () => {
</Tooltip>
)}
{access.canAccess(PRIVILEGE_CODE.datadevJobEdit) && (
<Tooltip title={intl.formatMessage({id: 'pages.project.doris.template.define'})}>
<Tooltip title={intl.formatMessage({id: 'pages.project.doris.template.detail'})}>
<Button
shape="default"
type="link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ export const WsDorisOperatorTemplateService = {
},

formatData: (data: WsDorisOperatorTemplate, value: Record<string, any>) => {
const admin: Record<string, any> = {
name: value['admin.name'],
password: value['admin.password'],
if (value['admin.name'] || value['admin.password']) {
const admin: Record<string, any> = {
name: value['admin.name'],
password: value['admin.password'],
}
data.admin = admin
}
data.admin = admin

const feSpec: Record<string, any> = {
replicas: value['fe.replicas'],
Expand Down
Loading

0 comments on commit a6466e5

Please sign in to comment.