Skip to content

Commit f61071e

Browse files
authored
feat: fix console bugs and makes console functions effective (#1378)
* fix: console interfaces;feat: implements governor using zk and nacos * fix: instance subscriber * fix: unit-test * fix: rules search * resolve conflicts * fix: backend bugs * fix: rule handler and service refactor * fix: config error andd field mapping * fix: rename msg to message * fix: wrap prometheus error * fix ci
1 parent ff429c0 commit f61071e

File tree

92 files changed

+2971
-1974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2971
-1974
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ bin/
4545
build/
4646
vendor/
4747

48-
# dubbo cp cache
49-
app/dubbo-cp/cache
48+

api/mesh/v1alpha1/condition_route.pb.go

Lines changed: 97 additions & 304 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/mesh/v1alpha1/condition_route.proto

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ message ConditionRoute {
1212
option (dubbo.mesh.resource).package = "mesh";
1313
option (dubbo.mesh.resource).is_experimental = false;
1414

15-
message v3 {
1615
string configVersion = 1;
1716
int32 priority = 2;
1817
bool enabled = 3;
@@ -21,22 +20,6 @@ message ConditionRoute {
2120
string key = 6;
2221
string scope = 7;
2322
repeated string conditions = 8;
24-
}
25-
26-
message v3x1 {
27-
string configVersion = 1;
28-
string scope = 2; // must be chosen from `service` and `application`
29-
string key = 3; // specifies which service or application the rule body acts on
30-
bool force = 4;
31-
bool runtime = 5;
32-
bool enabled = 6;
33-
repeated ConditionRule conditions = 8;
34-
}
35-
36-
oneof conditions {
37-
v3 conditionsV3 = 1;
38-
v3x1 conditionsV3x1 = 2;
39-
}
4023
}
4124

4225
message ConditionRule {

api/mesh/v1alpha1/condition_route_helper.go

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -20,115 +20,9 @@ package v1alpha1
2020
import (
2121
"strings"
2222

23-
"github.com/pkg/errors"
24-
"sigs.k8s.io/yaml"
25-
2623
"github.com/apache/dubbo-admin/pkg/common/constants"
27-
"github.com/apache/dubbo-admin/pkg/common/util/proto"
2824
)
2925

30-
func (x *ConditionRoute) GetVersion() string {
31-
if x.ToConditionRouteV3() != nil {
32-
return constants.ConfiguratorVersionV3
33-
} else {
34-
return constants.ConfiguratorVersionV3x1
35-
}
36-
}
37-
38-
func (x *ConditionRoute) ToYAML() ([]byte, error) {
39-
if msg := x.ToConditionRouteV3x1(); msg != nil {
40-
return proto.ToYAML(msg)
41-
} else if msg := x.ToConditionRouteV3(); msg != nil {
42-
return proto.ToYAML(msg)
43-
}
44-
return nil, errors.New(`ConditionRoute validation failed`)
45-
}
46-
47-
func ConditionRouteDecodeFromYAML(content []byte) (*ConditionRoute, error) {
48-
_map := map[string]interface{}{}
49-
err := yaml.Unmarshal(content, &_map)
50-
if err != nil {
51-
return nil, err
52-
}
53-
54-
version, ok := _map[constants.ConfigVersionKey].(string)
55-
if !ok {
56-
return nil, errors.New("invalid condition route format")
57-
}
58-
if version == constants.ConfiguratorVersionV3 {
59-
v3 := new(ConditionRouteV3)
60-
if err = proto.FromYAML(content, v3); err != nil {
61-
return nil, err
62-
}
63-
return v3.ToConditionRoute(), nil
64-
} else if version == constants.ConfiguratorVersionV3x1 {
65-
v3x1 := new(ConditionRouteV3X1)
66-
if err = proto.FromYAML(content, v3x1); err != nil {
67-
return nil, err
68-
}
69-
return v3x1.ToConditionRoute(), nil
70-
} else {
71-
return nil, errors.New("invalid condition route format")
72-
}
73-
}
74-
75-
func (x *ConditionRouteV3) ToConditionRoute() *ConditionRoute {
76-
return &ConditionRoute{Conditions: &ConditionRoute_ConditionsV3{ConditionsV3: x}}
77-
}
78-
79-
func (x *ConditionRouteV3X1) ToConditionRoute() *ConditionRoute {
80-
return &ConditionRoute{Conditions: &ConditionRoute_ConditionsV3X1{ConditionsV3X1: x}}
81-
}
82-
83-
func (x *ConditionRoute) ToConditionRouteV3() *ConditionRouteV3 {
84-
if v, ok := x.Conditions.(*ConditionRoute_ConditionsV3); ok {
85-
return v.ConditionsV3
86-
}
87-
return nil
88-
}
89-
90-
func (x *ConditionRoute) ToConditionRouteV3x1() *ConditionRouteV3X1 {
91-
if v, ok := x.Conditions.(*ConditionRoute_ConditionsV3X1); ok {
92-
return v.ConditionsV3X1
93-
}
94-
return nil
95-
}
96-
97-
func (x *ConditionRouteV3X1) RangeConditions(f func(r *ConditionRule) (isStop bool)) {
98-
if f == nil {
99-
return
100-
}
101-
for _, condition := range x.Conditions {
102-
if condition != nil && f(condition) {
103-
break
104-
}
105-
}
106-
}
107-
108-
func (x *ConditionRouteV3) RangeConditions(f func(condition string) (isStop bool)) {
109-
if f == nil {
110-
return
111-
}
112-
for _, condition := range x.Conditions {
113-
if f(condition) {
114-
break
115-
}
116-
}
117-
}
118-
119-
func (x *ConditionRouteV3X1) RangeConditionsToRemove(f func(r *ConditionRule) (isRemove bool)) {
120-
if f == nil {
121-
return
122-
}
123-
res := make([]*ConditionRule, 0, len(x.Conditions)/2+1)
124-
for _, condition := range x.Conditions {
125-
if condition != nil && !f(condition) {
126-
res = append(res, condition)
127-
}
128-
}
129-
x.Conditions = res
130-
}
131-
13226
func (x *ConditionRule) IsMatchMethod() (string, bool) {
13327
conditions := strings.Split(x.From.Match, "&")
13428
for _, condition := range conditions {

api/mesh/v1alpha1/instance.pb.go

Lines changed: 32 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/mesh/v1alpha1/instance.proto

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ message Instance {
6363

6464
string node = 58;
6565

66-
repeated Probe probes = 59;
66+
string sourceEngine = 59;
6767

68-
repeated Condition conditions = 60;
68+
repeated Probe probes = 99;
6969

70-
reserved 61 to 100;
70+
repeated Condition conditions = 100;
71+
72+
reserved 60 to 98;
7173
}

app/dubbo-admin/dubbo-admin.yaml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,66 @@
1515

1616
mode: zone
1717
console:
18-
observability:
19-
grafana: xx
20-
prometheus: xx
21-
jaeger: xx
22-
dashboards:
23-
metric:
24-
application: xx
25-
instance: xx
26-
service: xx
27-
trace:
28-
application: xx
29-
instance: xx
30-
service: xx
31-
log:
32-
application: xx
33-
instance: xx
34-
service: xx
18+
grafana:
19+
prometheus:
20+
jaeger:
21+
dashboards:
22+
metric:
23+
application:
24+
instance:
25+
service:
26+
trace:
27+
application:
28+
instance:
29+
service:
30+
log:
31+
application:
32+
instance:
33+
service:
3534
auth:
3635
user: admin
3736
password: dubbo@2025
3837
expirationTime: 3600
3938
store:
4039
# type: memory
4140
type: mysql
42-
address: root:123456@tcp(127.0.0.1:3306)/dubbo-admin?charset=utf8mb4&parseTime=True&loc=Asia%2FShanghai
41+
address: root:123456@tcp(127.0.0.1:23306)/dubbo-admin?charset=utf8mb4&parseTime=True&loc=Asia%2FShanghai
4342
discovery:
44-
# - type: nacos2
45-
# name: localhost-nacos
46-
# id: localhost-nacos
47-
# address:
48-
# registry: nacos://127.0.0.1:28848?username=nacos&password=nacos
49-
# configCenter: nacos://127.0.0.1:28848?username=nacos&password=nacos
50-
# metadataReport: nacos://127.0.0.1:28848?username=nacos&password=nacos
51-
# properties:
52-
# # [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all configs in nacos.
53-
# # Default period is 30s
54-
# configWatchPeriod: 20
55-
# # [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all services in nacos.
56-
# # Default period is 30s
57-
# serviceWatchPeriod: 20
58-
- type: zookeeper
59-
name: zk3.6
60-
id: zk3.6
43+
- type: nacos2
44+
name: localhost-nacos
45+
id: localhost-nacos
6146
address:
62-
registry: zookeeper://127.0.0.1:2181
63-
configCenter: zookeeper://127.0.0.1:2181
64-
metadataReport: zookeeper://127.0.0.1:2181
47+
registry: nacos://101.34.253.152:30848?username=nacos&password=nacos
48+
configCenter: nacos://101.34.253.152:30848?username=nacos&password=nacos
49+
metadataReport: nacos://101.34.253.152:30848?username=nacos&password=nacos
50+
properties:
51+
# [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all configs in nacos.
52+
# Default period is 30s
53+
configWatchPeriod: 20
54+
# [Nacos2] Adjust the interval(time unit is `s`) to adjust the frequency of list-all services in nacos.
55+
# Default period is 30s
56+
serviceWatchPeriod: 20
57+
# - type: zookeeper
58+
# name: 本地zookeeper
59+
# id: zk3.6
60+
# address:
61+
# registry: zookeeper://127.0.0.1:2181
62+
# configCenter: zookeeper://127.0.0.1:2181
63+
# metadataReport: zookeeper://127.0.0.1:2181
6564

6665
# mock discovery is only for development
6766
# - type: mock
6867
# id: mock
6968
# name: mockRegistry
7069
engine:
71-
name: mock
72-
type: mock
73-
# name: k8s1.28.6
74-
# type: kubernetes
70+
# id: mock
71+
# name: mock
72+
# type: mock
73+
id: default
74+
name: k8s1.28.6
75+
type: kubernetes
7576
properties:
76-
# [Kubernetes] Path to kubernetes config file, if not set, will use in cluster config
77+
# [Kubernetes] Path to kubernetes config file, if not set, will use in cluster config
7778
kubeConfigPath: /root/.kube/config
7879
# [Kubernetes] Watch pods with specified labels, if not set, will watch all pods
7980
# podWatchSelector: org.apache.dubbo/dubbo-apps=true
@@ -126,4 +127,3 @@ engine:
126127
# mainContainerChooseStrategy:
127128
# type: ByIndex
128129
# index: 0
129-
controlPlane:

pkg/common/bizerror/error.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Error interface {
2929
type ErrorCode string
3030

3131
const (
32+
InternalError ErrorCode = "InternalError"
3233
UnknownError ErrorCode = "UnknownError"
3334
InvalidArgument ErrorCode = "InvalidArgument"
3435
StoreError ErrorCode = "StoreError"
@@ -40,6 +41,10 @@ const (
4041
NacosError ErrorCode = "NacosError"
4142
ZKError ErrorCode = "ZKError"
4243
EventError ErrorCode = "EventError"
44+
GovernorError ErrorCode = "GovernorError"
45+
JsonError ErrorCode = "JsonError"
46+
YamlError ErrorCode = "YamlError"
47+
NotFoundError ErrorCode = "NotFoundError"
4348
)
4449

4550
type bizError struct {

0 commit comments

Comments
 (0)