Skip to content

Commit

Permalink
Supplement fields of cluster and tenant from annotations (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored and chris-sun-star committed Jan 16, 2025
1 parent ac83f34 commit 551d5a3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
13 changes: 13 additions & 0 deletions internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func buildOBClusterOverview(ctx context.Context, obcluster *v1alpha1.OBCluster)
clusterMode := modelcommon.ClusterModeNormal
annotations := obcluster.GetAnnotations()
deletionProtection := false
pvcIndependent := false
if annotations != nil {
if mode, ok := annotations[oceanbaseconst.AnnotationsMode]; ok {
switch mode {
Expand All @@ -88,6 +89,7 @@ func buildOBClusterOverview(ctx context.Context, obcluster *v1alpha1.OBCluster)
}
}
deletionProtection = annotations[oceanbaseconst.AnnotationsIgnoreDeletion] == "true"
pvcIndependent = annotations[oceanbaseconst.AnnotationsIndependentPVCLifecycle] == "true"
}
return &response.OBClusterOverview{
OBClusterMeta: response.OBClusterMeta{
Expand All @@ -99,6 +101,7 @@ func buildOBClusterOverview(ctx context.Context, obcluster *v1alpha1.OBCluster)
Mode: clusterMode,
SupportStaticIP: obcluster.SupportStaticIP(),
DeletionProtection: deletionProtection,
PvcIndependent: pvcIndependent,
},
Status: getStatisticStatus(obcluster),
StatusDetail: obcluster.Status.Status,
Expand Down Expand Up @@ -169,6 +172,16 @@ func buildOBClusterResponse(ctx context.Context, obcluster *v1alpha1.OBCluster)
},
}
}
if obcluster.Annotations != nil {
annotations := make([]modelcommon.KVPair, 0)
for k, v := range obcluster.Annotations {
annotations = append(annotations, modelcommon.KVPair{
Key: k,
Value: v,
})
}
respCluster.OBClusterExtra.Annotations = annotations
}

return respCluster, nil
}
Expand Down
11 changes: 11 additions & 0 deletions internal/dashboard/business/oceanbase/obtenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/oceanbase/ob-operator/internal/clients/schema"
oceanbaseconst "github.com/oceanbase/ob-operator/internal/const/oceanbase"
"github.com/oceanbase/ob-operator/internal/const/status/tenantstatus"
"github.com/oceanbase/ob-operator/internal/dashboard/model/common"
"github.com/oceanbase/ob-operator/internal/dashboard/model/param"
"github.com/oceanbase/ob-operator/internal/dashboard/model/response"
oberr "github.com/oceanbase/ob-operator/pkg/errors"
Expand Down Expand Up @@ -193,6 +194,16 @@ func buildDetailFromApiType(t *v1alpha1.OBTenant) *response.OBTenantDetail {
rt.RestoreSource.Until = *t.Spec.Source.Restore.Until.Timestamp
}
}
if t.Annotations != nil {
annotations := make([]common.KVPair, 0, len(t.Annotations))
for k, v := range t.Annotations {
annotations = append(annotations, common.KVPair{
Key: k,
Value: v,
})
}
rt.Annotations = annotations
}

return rt
}
Expand Down
2 changes: 2 additions & 0 deletions internal/dashboard/model/response/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type OBClusterMeta struct {

SupportStaticIP bool `json:"supportStaticIP" binding:"required"`
DeletionProtection bool `json:"deletionProtection" binding:"required"`
PvcIndependent bool `json:"pvcIndependent" binding:"required"`
}

type OBClusterOverview struct {
Expand Down Expand Up @@ -100,6 +101,7 @@ type OBClusterExtra struct {
Parameters []ParameterSpec `json:"parameters" binding:"required"`
Monitor *MonitorSpec `json:"monitor"`
BackupVolume *NFSVolumeSpec `json:"backupVolume"`
Annotations []common.KVPair `json:"annotations"`
}

type MonitorSpec struct {
Expand Down
7 changes: 5 additions & 2 deletions internal/dashboard/model/response/obtenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ See the Mulan PSL v2 for more details.

package response

import "github.com/oceanbase/ob-operator/internal/dashboard/model/common"

// @Description Brief information about OBTenant
type OBTenantOverview struct {
UID string `json:"uid" binding:"required"` // Unique identifier of the resource
Expand All @@ -37,8 +39,9 @@ type OBTenantDetail struct {
StandbyROCredential string `json:"standbyROCredential"`
Version string `json:"version"`

PrimaryTenant string `json:"primaryTenant"`
RestoreSource *RestoreSource `json:"restoreSource,omitempty"`
PrimaryTenant string `json:"primaryTenant"`
RestoreSource *RestoreSource `json:"restoreSource,omitempty"`
Annotations []common.KVPair `json:"annotations"`
}

type OBTenantReplica struct {
Expand Down

0 comments on commit 551d5a3

Please sign in to comment.