Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ bin/
build/
vendor/

# dubbo cp cache
app/dubbo-cp/cache

401 changes: 97 additions & 304 deletions api/mesh/v1alpha1/condition_route.pb.go

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions api/mesh/v1alpha1/condition_route.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ message ConditionRoute {
option (dubbo.mesh.resource).package = "mesh";
option (dubbo.mesh.resource).is_experimental = false;

message v3 {
string configVersion = 1;
int32 priority = 2;
bool enabled = 3;
Expand All @@ -21,22 +20,6 @@ message ConditionRoute {
string key = 6;
string scope = 7;
repeated string conditions = 8;
}

message v3x1 {
string configVersion = 1;
string scope = 2; // must be chosen from `service` and `application`
string key = 3; // specifies which service or application the rule body acts on
bool force = 4;
bool runtime = 5;
bool enabled = 6;
repeated ConditionRule conditions = 8;
}

oneof conditions {
v3 conditionsV3 = 1;
v3x1 conditionsV3x1 = 2;
}
}

message ConditionRule {
Expand Down
106 changes: 0 additions & 106 deletions api/mesh/v1alpha1/condition_route_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,115 +20,9 @@ package v1alpha1
import (
"strings"

"github.com/pkg/errors"
"sigs.k8s.io/yaml"

"github.com/apache/dubbo-admin/pkg/common/constants"
"github.com/apache/dubbo-admin/pkg/common/util/proto"
)

func (x *ConditionRoute) GetVersion() string {
if x.ToConditionRouteV3() != nil {
return constants.ConfiguratorVersionV3
} else {
return constants.ConfiguratorVersionV3x1
}
}

func (x *ConditionRoute) ToYAML() ([]byte, error) {
if msg := x.ToConditionRouteV3x1(); msg != nil {
return proto.ToYAML(msg)
} else if msg := x.ToConditionRouteV3(); msg != nil {
return proto.ToYAML(msg)
}
return nil, errors.New(`ConditionRoute validation failed`)
}

func ConditionRouteDecodeFromYAML(content []byte) (*ConditionRoute, error) {
_map := map[string]interface{}{}
err := yaml.Unmarshal(content, &_map)
if err != nil {
return nil, err
}

version, ok := _map[constants.ConfigVersionKey].(string)
if !ok {
return nil, errors.New("invalid condition route format")
}
if version == constants.ConfiguratorVersionV3 {
v3 := new(ConditionRouteV3)
if err = proto.FromYAML(content, v3); err != nil {
return nil, err
}
return v3.ToConditionRoute(), nil
} else if version == constants.ConfiguratorVersionV3x1 {
v3x1 := new(ConditionRouteV3X1)
if err = proto.FromYAML(content, v3x1); err != nil {
return nil, err
}
return v3x1.ToConditionRoute(), nil
} else {
return nil, errors.New("invalid condition route format")
}
}

func (x *ConditionRouteV3) ToConditionRoute() *ConditionRoute {
return &ConditionRoute{Conditions: &ConditionRoute_ConditionsV3{ConditionsV3: x}}
}

func (x *ConditionRouteV3X1) ToConditionRoute() *ConditionRoute {
return &ConditionRoute{Conditions: &ConditionRoute_ConditionsV3X1{ConditionsV3X1: x}}
}

func (x *ConditionRoute) ToConditionRouteV3() *ConditionRouteV3 {
if v, ok := x.Conditions.(*ConditionRoute_ConditionsV3); ok {
return v.ConditionsV3
}
return nil
}

func (x *ConditionRoute) ToConditionRouteV3x1() *ConditionRouteV3X1 {
if v, ok := x.Conditions.(*ConditionRoute_ConditionsV3X1); ok {
return v.ConditionsV3X1
}
return nil
}

func (x *ConditionRouteV3X1) RangeConditions(f func(r *ConditionRule) (isStop bool)) {
if f == nil {
return
}
for _, condition := range x.Conditions {
if condition != nil && f(condition) {
break
}
}
}

func (x *ConditionRouteV3) RangeConditions(f func(condition string) (isStop bool)) {
if f == nil {
return
}
for _, condition := range x.Conditions {
if f(condition) {
break
}
}
}

func (x *ConditionRouteV3X1) RangeConditionsToRemove(f func(r *ConditionRule) (isRemove bool)) {
if f == nil {
return
}
res := make([]*ConditionRule, 0, len(x.Conditions)/2+1)
for _, condition := range x.Conditions {
if condition != nil && !f(condition) {
res = append(res, condition)
}
}
x.Conditions = res
}

func (x *ConditionRule) IsMatchMethod() (string, bool) {
conditions := strings.Split(x.From.Match, "&")
for _, condition := range conditions {
Expand Down
54 changes: 32 additions & 22 deletions api/mesh/v1alpha1/instance.pb.go

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

8 changes: 5 additions & 3 deletions api/mesh/v1alpha1/instance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ message Instance {

string node = 58;

repeated Probe probes = 59;
string sourceEngine = 59;

repeated Condition conditions = 60;
repeated Probe probes = 99;

reserved 61 to 100;
repeated Condition conditions = 100;

reserved 60 to 98;
}
88 changes: 44 additions & 44 deletions app/dubbo-admin/dubbo-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,66 @@

mode: zone
console:
observability:
grafana: xx
prometheus: xx
jaeger: xx
dashboards:
metric:
application: xx
instance: xx
service: xx
trace:
application: xx
instance: xx
service: xx
log:
application: xx
instance: xx
service: xx
grafana:
prometheus:
jaeger:
dashboards:
metric:
application:
instance:
service:
trace:
application:
instance:
service:
log:
application:
instance:
service:
auth:
user: admin
password: dubbo@2025
expirationTime: 3600
store:
# type: memory
type: mysql
address: root:123456@tcp(127.0.0.1:3306)/dubbo-admin?charset=utf8mb4&parseTime=True&loc=Asia%2FShanghai
address: root:123456@tcp(127.0.0.1:23306)/dubbo-admin?charset=utf8mb4&parseTime=True&loc=Asia%2FShanghai
discovery:
# - type: nacos2
# name: localhost-nacos
# id: localhost-nacos
# address:
# registry: nacos://127.0.0.1:28848?username=nacos&password=nacos
# configCenter: nacos://127.0.0.1:28848?username=nacos&password=nacos
# metadataReport: nacos://127.0.0.1:28848?username=nacos&password=nacos
# properties:
# # [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all configs in nacos.
# # Default period is 30s
# configWatchPeriod: 20
# # [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all services in nacos.
# # Default period is 30s
# serviceWatchPeriod: 20
- type: zookeeper
name: zk3.6
id: zk3.6
- type: nacos2
name: localhost-nacos
id: localhost-nacos
address:
registry: zookeeper://127.0.0.1:2181
configCenter: zookeeper://127.0.0.1:2181
metadataReport: zookeeper://127.0.0.1:2181
registry: nacos://101.34.253.152:30848?username=nacos&password=nacos
configCenter: nacos://101.34.253.152:30848?username=nacos&password=nacos
metadataReport: nacos://101.34.253.152:30848?username=nacos&password=nacos
properties:
# [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all configs in nacos.
# Default period is 30s
configWatchPeriod: 20
# [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all services in nacos.
# Default period is 30s
serviceWatchPeriod: 20
# - type: zookeeper
# name: 本地zookeeper
# id: zk3.6
# address:
# registry: zookeeper://127.0.0.1:2181
# configCenter: zookeeper://127.0.0.1:2181
# metadataReport: zookeeper://127.0.0.1:2181

# mock discovery is only for development
# - type: mock
# id: mock
# name: mockRegistry
engine:
name: mock
type: mock
# name: k8s1.28.6
# type: kubernetes
# id: mock
# name: mock
# type: mock
id: default
name: k8s1.28.6
type: kubernetes
properties:
# [Kubernetes] Path to kubernetes config file, if not set, will use in cluster config
# [Kubernetes] Path to kubernetes config file, if not set, will use in cluster config
kubeConfigPath: /root/.kube/config
# [Kubernetes] Watch pods with specified labels, if not set, will watch all pods
# podWatchSelector: org.apache.dubbo/dubbo-apps=true
Expand Down Expand Up @@ -126,4 +127,3 @@ engine:
# mainContainerChooseStrategy:
# type: ByIndex
# index: 0
controlPlane:
5 changes: 5 additions & 0 deletions pkg/common/bizerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Error interface {
type ErrorCode string

const (
InternalError ErrorCode = "InternalError"
UnknownError ErrorCode = "UnknownError"
InvalidArgument ErrorCode = "InvalidArgument"
StoreError ErrorCode = "StoreError"
Expand All @@ -40,6 +41,10 @@ const (
NacosError ErrorCode = "NacosError"
ZKError ErrorCode = "ZKError"
EventError ErrorCode = "EventError"
GovernorError ErrorCode = "GovernorError"
JsonError ErrorCode = "JsonError"
YamlError ErrorCode = "YamlError"
NotFoundError ErrorCode = "NotFoundError"
)

type bizError struct {
Expand Down
Loading
Loading