Skip to content

Commit

Permalink
Fixed some problems of obproxy management module (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Jun 20, 2024
1 parent cc5fc67 commit 68bed4f
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 35 deletions.
1 change: 1 addition & 0 deletions charts/oceanbase-dashboard/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rules:
- secrets
- namespaces
- configmaps
- services
- pods/exec
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups:
Expand Down
4 changes: 2 additions & 2 deletions internal/assets/metric_zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ OBCLUSTER_OVERVIEW:
unit: "\u03BCs"
name: "\u7B49\u5F85\u4E8B\u4EF6\u8017\u65F6"
OBPROXY:
- name: OBProxy service monitoring
description: Obproxy service monitoring
- name: OBProxy 服务监控
description: OBProxy 服务监控
metricGroups:
- name: TPS
description: TPS
Expand Down
10 changes: 8 additions & 2 deletions internal/dashboard/business/obproxy/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func buildOBProxyOverview(deploy *appsv1.Deployment) *obproxy.OBProxyOverview {
Status: getDeploymentStatus(deploy),
CreationTime: deploy.CreationTimestamp.Unix(),
ServiceIP: deploy.Annotations[AnnotationServiceIP],
ServiceType: deploy.Annotations[AnnotationServiceType],
}
return overview
}
Expand Down Expand Up @@ -87,7 +88,7 @@ func buildOBProxy(ctx context.Context, deploy *appsv1.Deployment) (*obproxy.OBPr
},
Resource: common.ResourceSpec{
Cpu: deploy.Spec.Template.Spec.Containers[0].Resources.Limits.Cpu().Value(),
MemoryGB: deploy.Spec.Template.Spec.Containers[0].Resources.Limits.Memory().ScaledValue(resource.Giga),
MemoryGB: deploy.Spec.Template.Spec.Containers[0].Resources.Limits.Memory().Value() / (1 << 30),
},
Parameters: []common.KVPair{},
Pods: []response.K8sPodInfo{},
Expand All @@ -97,6 +98,7 @@ func buildOBProxy(ctx context.Context, deploy *appsv1.Deployment) (*obproxy.OBPr
Name: port.Name,
Port: port.Port,
TargetPort: port.TargetPort.IntVal,
NodePort: port.NodePort,
})
}
for k, v := range cm.Data {
Expand All @@ -107,12 +109,16 @@ func buildOBProxy(ctx context.Context, deploy *appsv1.Deployment) (*obproxy.OBPr
}
// TODO: Move pods fetching to another function?
for _, pod := range pods.Items {
podStatus := string(pod.Status.Phase)
if pod.DeletionTimestamp != nil {
podStatus = "Terminating"
}
podInfo := response.K8sPodInfo{
Name: pod.Name,
Namespace: pod.Namespace,
NodeName: pod.Spec.NodeName,
PodIP: pod.Status.PodIP,
Status: string(pod.Status.Phase),
Status: podStatus,
Message: pod.Status.Message,
Reason: pod.Status.Reason,
StartTime: pod.Status.StartTime.Format(time.DateTime),
Expand Down
46 changes: 22 additions & 24 deletions internal/dashboard/generated/bindata/bindata.go

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions internal/dashboard/generated/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5739,6 +5739,7 @@ const docTemplate = `{
"resource",
"service",
"serviceIp",
"serviceType",
"status"
],
"properties": {
Expand Down Expand Up @@ -5787,6 +5788,9 @@ const docTemplate = `{
"serviceIp": {
"type": "string"
},
"serviceType": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
Expand All @@ -5807,6 +5811,7 @@ const docTemplate = `{
"proxyClusterName",
"replicas",
"serviceIp",
"serviceType",
"status"
],
"properties": {
Expand Down Expand Up @@ -5834,6 +5839,9 @@ const docTemplate = `{
"serviceIp": {
"type": "string"
},
"serviceType": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -7074,6 +7082,13 @@ const docTemplate = `{
},
"response.K8sService": {
"type": "object",
"required": [
"clusterIP",
"name",
"namespace",
"ports",
"type"
],
"properties": {
"clusterIP": {
"type": "string"
Expand All @@ -7100,10 +7115,17 @@ const docTemplate = `{
},
"response.K8sServicePort": {
"type": "object",
"required": [
"port",
"targetPort"
],
"properties": {
"name": {
"type": "string"
},
"nodePort": {
"type": "integer"
},
"port": {
"type": "integer"
},
Expand Down
22 changes: 22 additions & 0 deletions internal/dashboard/generated/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5732,6 +5732,7 @@
"resource",
"service",
"serviceIp",
"serviceType",
"status"
],
"properties": {
Expand Down Expand Up @@ -5780,6 +5781,9 @@
"serviceIp": {
"type": "string"
},
"serviceType": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
Expand All @@ -5800,6 +5804,7 @@
"proxyClusterName",
"replicas",
"serviceIp",
"serviceType",
"status"
],
"properties": {
Expand Down Expand Up @@ -5827,6 +5832,9 @@
"serviceIp": {
"type": "string"
},
"serviceType": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -7067,6 +7075,13 @@
},
"response.K8sService": {
"type": "object",
"required": [
"clusterIP",
"name",
"namespace",
"ports",
"type"
],
"properties": {
"clusterIP": {
"type": "string"
Expand All @@ -7093,10 +7108,17 @@
},
"response.K8sServicePort": {
"type": "object",
"required": [
"port",
"targetPort"
],
"properties": {
"name": {
"type": "string"
},
"nodePort": {
"type": "integer"
},
"port": {
"type": "integer"
},
Expand Down
17 changes: 17 additions & 0 deletions internal/dashboard/generated/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ definitions:
$ref: '#/definitions/response.K8sService'
serviceIp:
type: string
serviceType:
type: string
status:
enum:
- Running
Expand All @@ -503,6 +505,7 @@ definitions:
- resource
- service
- serviceIp
- serviceType
- status
type: object
obproxy.OBProxyOverview:
Expand All @@ -523,6 +526,8 @@ definitions:
type: integer
serviceIp:
type: string
serviceType:
type: string
status:
enum:
- Running
Expand All @@ -537,6 +542,7 @@ definitions:
- proxyClusterName
- replicas
- serviceIp
- serviceType
- status
type: object
obproxy.PatchOBProxyParam:
Expand Down Expand Up @@ -1422,15 +1428,26 @@ definitions:
type: array
type:
type: string
required:
- clusterIP
- name
- namespace
- ports
- type
type: object
response.K8sServicePort:
properties:
name:
type: string
nodePort:
type: integer
port:
type: integer
targetPort:
type: integer
required:
- port
- targetPort
type: object
response.Metric:
properties:
Expand Down
1 change: 1 addition & 0 deletions internal/dashboard/model/obproxy/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type OBProxyOverview struct {
ProxyClusterName string `json:"proxyClusterName" binding:"required"`
Image string `json:"image" binding:"required"`
Replicas int32 `json:"replicas" binding:"required"`
ServiceType string `json:"serviceType" binding:"required"`
ServiceIP string `json:"serviceIp" binding:"required"`
CreationTime int64 `json:"creationTime" binding:"required"`
Status string `json:"status" binding:"required" enums:"Running,Pending"`
Expand Down
15 changes: 8 additions & 7 deletions internal/dashboard/model/response/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,17 @@ type ContainerInfo struct {
}

type K8sService struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Type string `json:"type"`
ClusterIP string `json:"clusterIP"`
Name string `json:"name" binding:"required"`
Namespace string `json:"namespace" binding:"required"`
Type string `json:"type" binding:"required"`
ClusterIP string `json:"clusterIP" binding:"required"`
ExternalIP string `json:"externalIP"`
Ports []K8sServicePort `json:"ports"`
Ports []K8sServicePort `json:"ports" binding:"required"`
}

type K8sServicePort struct {
Name string `json:"name,omitempty"`
Port int32 `json:"port"`
TargetPort int32 `json:"targetPort"`
Port int32 `json:"port" binding:"required"`
TargetPort int32 `json:"targetPort" binding:"required"`
NodePort int32 `json:"nodePort,omitempty"`
}

0 comments on commit 68bed4f

Please sign in to comment.