Skip to content

Commit

Permalink
Merge remote-tracking branch upstream/master into feat_obproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 committed Jun 14, 2024
2 parents 9aa8b6d + a21de41 commit 3aecde3
Show file tree
Hide file tree
Showing 43 changed files with 3,939 additions and 518 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags
bin

# lib & package
.vendor/
vendor/
.glide/

# Test binary
Expand Down
39 changes: 35 additions & 4 deletions internal/dashboard/business/obproxy/obproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"context"
"fmt"

"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
kubeerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -146,10 +147,6 @@ func PatchOBProxy(ctx context.Context, ns, name string, param *obproxy.PatchOBPr
return nil, err
}
if changed {
_, err := updateConfigMap(ctx, ns, name, param)
if err != nil {
return nil, err
}
parametersUpdated = true
}
}
Expand All @@ -175,6 +172,12 @@ func PatchOBProxy(ctx context.Context, ns, name string, param *obproxy.PatchOBPr
}
}
}
if parametersUpdated {
_, err := updateConfigMap(ctx, ns, name, param)
if err != nil {
return nil, err
}
}
if updated || parametersUpdated {
deployment, err := client.GetClient().ClientSet.AppsV1().Deployments(ns).Update(ctx, deploy, metav1.UpdateOptions{})
if err != nil {
Expand Down Expand Up @@ -215,3 +218,31 @@ func DeleteOBProxy(ctx context.Context, ns, name string) (*obproxy.OBProxy, erro
}
return deleted, nil
}

func ListOBProxyParameters(ctx context.Context, ns string, name string) ([]obproxy.ConfigItem, error) {
items := make([]obproxy.ConfigItem, 0)
deploy, err := client.GetClient().ClientSet.AppsV1().Deployments(ns).Get(ctx, name, metav1.GetOptions{})
if err != nil {
if kubeerrors.IsNotFound(err) {
return nil, httpErr.NewNotFound("OBProxy not found")
}
return nil, httpErr.NewInternal("Failed to get obproxy, err msg: " + err.Error())
}
odp, err := buildOBProxy(ctx, deploy)
if err != nil {
return nil, err
}
for _, pod := range odp.Pods {
conn, err := utils.GetOBConnectionByHost(ctx, odp.Namespace, pod.PodIP, "root", "proxysys", odp.ProxySysSecret, 2883)
if err != nil {
logrus.Infof("Failed to get oceanbase connection by host %s", pod.PodIP)
continue
}
err = conn.QueryList(ctx, &items, "SHOW PROXYCONFIG;")
if err != nil {
return nil, httpErr.NewInternal("Failed to list obproxy config, err msg: " + err.Error())
}
return items, nil
}
return items, nil
}
12 changes: 7 additions & 5 deletions internal/dashboard/generated/bindata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions internal/dashboard/generated/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3210,6 +3210,79 @@ const docTemplate = `{
}
}
},
"/api/v1/obproxies/{namespace}/{name}/parameters": {
"get": {
"description": "List OBProxy Parameters by namespace and name",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"OBProxy"
],
"summary": "List OBProxy Parameters",
"operationId": "ListOBProxyParameters",
"parameters": [
{
"type": "string",
"description": "namespace of obproxy deployment",
"name": "namespace",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of obproxy deployment",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/obproxy.ConfigItem"
}
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/obtenants": {
"get": {
"security": [
Expand Down Expand Up @@ -5479,6 +5552,26 @@ const docTemplate = `{
}
}
},
"obproxy.ConfigItem": {
"type": "object",
"properties": {
"info": {
"type": "string"
},
"name": {
"type": "string"
},
"needReboot": {
"type": "boolean"
},
"value": {
"type": "string"
},
"visibleLevel": {
"type": "string"
}
}
},
"obproxy.CreateOBProxyParam": {
"type": "object",
"required": [
Expand Down
93 changes: 93 additions & 0 deletions internal/dashboard/generated/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3203,6 +3203,79 @@
}
}
},
"/api/v1/obproxies/{namespace}/{name}/parameters": {
"get": {
"description": "List OBProxy Parameters by namespace and name",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"OBProxy"
],
"summary": "List OBProxy Parameters",
"operationId": "ListOBProxyParameters",
"parameters": [
{
"type": "string",
"description": "namespace of obproxy deployment",
"name": "namespace",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of obproxy deployment",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.APIResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/obproxy.ConfigItem"
}
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.APIResponse"
}
}
}
}
},
"/api/v1/obtenants": {
"get": {
"security": [
Expand Down Expand Up @@ -5472,6 +5545,26 @@
}
}
},
"obproxy.ConfigItem": {
"type": "object",
"properties": {
"info": {
"type": "string"
},
"name": {
"type": "string"
},
"needReboot": {
"type": "boolean"
},
"value": {
"type": "string"
},
"visibleLevel": {
"type": "string"
}
}
},
"obproxy.CreateOBProxyParam": {
"type": "object",
"required": [
Expand Down
59 changes: 59 additions & 0 deletions internal/dashboard/generated/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,19 @@ definitions:
storageSize:
type: integer
type: object
obproxy.ConfigItem:
properties:
info:
type: string
name:
type: string
needReboot:
type: boolean
value:
type: string
visibleLevel:
type: string
type: object
obproxy.CreateOBProxyParam:
properties:
image:
Expand Down Expand Up @@ -4312,6 +4325,52 @@ paths:
summary: Patch OBProxy
tags:
- OBProxy
/api/v1/obproxies/{namespace}/{name}/parameters:
get:
consumes:
- application/json
description: List OBProxy Parameters by namespace and name
operationId: ListOBProxyParameters
parameters:
- description: namespace of obproxy deployment
in: path
name: namespace
required: true
type: string
- description: name of obproxy deployment
in: path
name: name
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.APIResponse'
- properties:
data:
items:
$ref: '#/definitions/obproxy.ConfigItem'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.APIResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.APIResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.APIResponse'
summary: List OBProxy Parameters
tags:
- OBProxy
/api/v1/obtenants:
get:
consumes:
Expand Down
4 changes: 2 additions & 2 deletions internal/dashboard/handler/alarm_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ package handler

import (
"github.com/gin-gonic/gin"
"github.com/mcuadros/go-defaults"

"github.com/oceanbase/ob-operator/internal/dashboard/business/alarm"
"github.com/oceanbase/ob-operator/internal/dashboard/model/alarm/alert"
"github.com/oceanbase/ob-operator/internal/dashboard/model/alarm/receiver"
"github.com/oceanbase/ob-operator/internal/dashboard/model/alarm/route"
"github.com/oceanbase/ob-operator/internal/dashboard/model/alarm/rule"
"github.com/oceanbase/ob-operator/internal/dashboard/model/alarm/silence"
httpErr "github.com/oceanbase/ob-operator/pkg/errors"

"github.com/mcuadros/go-defaults"
)

// @ID ListAlerts
Expand Down
Loading

0 comments on commit 3aecde3

Please sign in to comment.