@@ -20,6 +20,7 @@ import (
2020
2121 "github.com/google/uuid"
2222 "github.com/pkg/errors"
23+ "github.com/sirupsen/logrus"
2324 logger "github.com/sirupsen/logrus"
2425 corev1 "k8s.io/api/core/v1"
2526 apiresource "k8s.io/apimachinery/pkg/api/resource"
@@ -34,8 +35,10 @@ import (
3435 "github.com/oceanbase/ob-operator/internal/dashboard/business/common"
3536 "github.com/oceanbase/ob-operator/internal/dashboard/business/constant"
3637 modelcommon "github.com/oceanbase/ob-operator/internal/dashboard/model/common"
38+ clustermodel "github.com/oceanbase/ob-operator/internal/dashboard/model/obcluster"
3739 "github.com/oceanbase/ob-operator/internal/dashboard/model/param"
3840 "github.com/oceanbase/ob-operator/internal/dashboard/model/response"
41+ "github.com/oceanbase/ob-operator/internal/dashboard/utils"
3942 oberr "github.com/oceanbase/ob-operator/pkg/errors"
4043)
4144
@@ -877,3 +880,30 @@ func DeleteOBServers(ctx context.Context, nn *param.K8sObjectIdentity, param *pa
877880
878881 return buildOBClusterResponse (ctx , obcluster )
879882}
883+
884+ func ListOBClusterParameters (ctx context.Context , nn * param.K8sObjectIdentity ) ([]clustermodel.ParameterItem , error ) {
885+ obcluster , err := clients .GetOBCluster (ctx , nn .Namespace , nn .Name )
886+ if err != nil {
887+ return nil , errors .Wrapf (err , "Get obcluster %s %s" , nn .Namespace , nn .Name )
888+ }
889+ observerList := v1alpha1.OBServerList {}
890+ err = clients .ServerClient .List (ctx , nn .Namespace , & observerList , metav1.ListOptions {
891+ LabelSelector : fmt .Sprintf ("%s=%s" , oceanbaseconst .LabelRefOBCluster , nn .Name ),
892+ })
893+ if err != nil {
894+ logrus .WithError (err ).Error ("Failed to list observers" )
895+ return nil , errors .Wrap (err , "List observers" )
896+ }
897+ conn , err := utils .GetOBConnection (ctx , obcluster , "root" , "sys" , obcluster .Spec .UserSecrets .Root )
898+ if err != nil {
899+ logrus .Info ("Failed to get OceanBase database connection" )
900+ return nil , errors .Wrap (err , "Get OceanBase database connection" )
901+ }
902+ parameterItems := make ([]clustermodel.ParameterItem , 0 )
903+ err = conn .QueryList (ctx , & parameterItems , "SHOW PARAMETERS" )
904+ if err != nil {
905+ logrus .WithError (err ).Error ("Failed to query parameters" )
906+ return nil , errors .Wrap (err , "Query parameters" )
907+ }
908+ return parameterItems , nil
909+ }
0 commit comments