Skip to content

Commit

Permalink
fix(obcluster): list obcluster parameters group by name (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Dec 20, 2024
1 parent 48e51fc commit 274d2d2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ func ListOBClusterParameters(ctx context.Context, nn *param.K8sObjectIdentity) (
logger.Info("Failed to get OceanBase database connection")
return nil, errors.Wrap(err, "Get OceanBase database connection")
}
parameters, err := conn.ListParametersWithTenantID(ctx, 1)
parameters, err := conn.ListClusterParameters(ctx)
if err != nil {
logger.WithError(err).Error("Failed to query parameters")
return nil, errors.Wrap(err, "Query parameters")
Expand Down
1 change: 1 addition & 0 deletions internal/dashboard/business/oceanbase/obtenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func buildOverviewFromApiType(t *v1alpha1.OBTenant) *response.OBTenantOverview {
rt.Charset = t.Spec.Charset
rt.Locality = t.Status.TenantRecordInfo.Locality
rt.PrimaryZone = t.Status.TenantRecordInfo.PrimaryZone
rt.DeletionProtection = t.Annotations[oceanbaseconst.AnnotationsIgnoreDeletion] == "true"

for i := range t.Status.Pools {
pool := t.Status.Pools[i]
Expand Down
3 changes: 0 additions & 3 deletions internal/dashboard/handler/obtenant_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ func PatchTenant(c *gin.Context) (*response.OBTenantDetail, error) {
if err != nil {
return nil, httpErr.NewBadRequest(err.Error())
}
if patch.UnitNumber == nil && patch.UnitConfig == nil {
return nil, httpErr.NewBadRequest("unitNumber or unitConfig is required")
}
logger.Infof("Patch obtenant with param: %+v", patch)
tenant, err := oceanbase.PatchTenant(c, types.NamespacedName{
Namespace: nn.Namespace,
Expand Down
2 changes: 2 additions & 0 deletions internal/dashboard/model/response/obtenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type OBTenantOverview struct {
Locality string `json:"locality" binding:"required"` // Locality of the tenant units
Charset string `json:"charset" binding:"required"` // Charset of the tenant
PrimaryZone string `json:"primaryZone" binding:"required"` // Primary zone of the tenant

DeletionProtection bool `json:"deletionProtection" binding:"required"` // Whether the tenant is protected from deletion
}

type OBTenantDetail struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/oceanbase-sdk/const/sql/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const (
const (
ListParametersWithTenantID = "select name, value, data_type, info, section, default_value, isdefault, edit_level, scope from GV$OB_PARAMETERS where tenant_id = ?"
SelectCompatibleOfTenants = "select name, value, tenant_id from GV$OB_PARAMETERS where name = 'compatible'"
ListParametersGroupByName = "select name, value, data_type, info, section, default_value, isdefault, edit_level, scope, svr_ip, zone, svr_port, IFNULL(tenant_id, 0) as tenant_id from GV$OB_PARAMETERS group by name"
)
9 changes: 9 additions & 0 deletions pkg/oceanbase-sdk/operation/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@ func (m *OceanbaseOperationManager) GetVersion(ctx context.Context) (*model.OBVe
}
return version, nil
}

func (m *OceanbaseOperationManager) ListClusterParameters(ctx context.Context) ([]*model.Parameter, error) {
params := make([]*model.Parameter, 0)
err := m.QueryList(ctx, &params, sql.ListParametersGroupByName)
if err != nil {
return nil, errors.Wrap(err, "List cluster parameters")
}
return params, nil
}

0 comments on commit 274d2d2

Please sign in to comment.