Skip to content

Commit 83df2b2

Browse files
authored
fix: kubernetes部署configmap调整 & 修复 boltdb 存储在的 clients 查询问题 (#368)
* fix: kubernetes部署configmap调整 * fix: 修复api_mock编辑脚本 * refactor: 修复store中的api_mock问题 * fix: 修复boltdb存储clients无法查询问题 * fix: 修复github-action * fix: 修复鉴权问题 * fix: 移除错误的权限判断逻辑 * refactor: 调整方法名称 * refactor: 调整prometheus的默认端口 * fix: 修复cache中遗漏client配置 * fix: 单机版本client查询修复
1 parent dce2672 commit 83df2b2

File tree

17 files changed

+158
-45
lines changed

17 files changed

+158
-45
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ jobs:
2727
with:
2828
go-version: 1.16.5
2929

30+
- name: Get version
31+
id: get_version
32+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
33+
3034
- name: Build
3135
id: build
3236
env:
3337
GOOS: ${{ matrix.goos }}
3438
GOARCH: ${{ matrix.goarch }}
39+
VERSION: ${{ steps.get_version.outputs.VERSION }}
3540
run: |
36-
bash build.sh
41+
bash build.sh ${VERSION}
3742
PACKAGE_NAME=$(ls | grep polaris-server-release*.zip | sed -n '1p')
3843
echo ::set-output name=name::${PACKAGE_NAME}
3944

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ workdir=$(dirname $(realpath $0))
1616
version=$(cat version 2>/dev/null)
1717
bin_name="polaris-server"
1818

19+
if [ $# == 1 ]; then
20+
version=$1
21+
fi
22+
1923
if [ "${GOOS}" == "windows" ]; then
2024
bin_name="polaris-server.exe"
2125
fi

cache/strategy.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,26 @@ func (sc *strategyCache) getStrategyDetails(uid string, gid string) []*model.Str
487487
func (sc *strategyCache) IsResourceLinkStrategy(resType api.ResourceType, resId string) bool {
488488
switch resType {
489489
case api.ResourceType_Namespaces:
490-
_, ok := sc.namespace2Strategy.Load(resId)
491-
return ok
490+
val, ok := sc.namespace2Strategy.Load(resId)
491+
return ok && hasLinkRule(val.(*sync.Map))
492492
case api.ResourceType_Services:
493-
_, ok := sc.service2Strategy.Load(resId)
494-
return ok
493+
val, ok := sc.service2Strategy.Load(resId)
494+
return ok && hasLinkRule(val.(*sync.Map))
495495
case api.ResourceType_ConfigGroups:
496-
_, ok := sc.configGroup2Strategy.Load(resId)
497-
return ok
496+
val, ok := sc.configGroup2Strategy.Load(resId)
497+
return ok && hasLinkRule(val.(*sync.Map))
498498
default:
499499
return true
500500
}
501501
}
502+
503+
func hasLinkRule(val *sync.Map) bool {
504+
count := 0
505+
506+
val.Range(func(key, value interface{}) bool {
507+
count++
508+
return true
509+
})
510+
511+
return count != 0
512+
}

common/model/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func (c *Client) Proto() *api.Client {
4545
return c.proto
4646
}
4747

48+
func (c *Client) SetValid(v bool) {
49+
c.valid = v
50+
}
51+
4852
func (c *Client) Valid() bool {
4953
return c.valid
5054
}

deploy/helm/README-zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ $ helm uninstall `${release_name}`
9494
|polaris.storage.service.httpPort | polaris service 暴露,polaris-server 监听的 http 端口|
9595
|polaris.storage.service.grpcPort | polaris service 暴露,polaris-server 监听的 grpc 端口|
9696
|polaris.storage.service.webPort | polaris service 暴露,polaris-server 监听的 web 端口|
97+
|polaris.auth.consoleOpen | polaris 打开控制台接口鉴权,默认开启|
98+
|polaris.auth.clientOpen | polaris 打开客户端接口鉴权,默认关闭|
9799
|monitor.port | 客户端上报监控信息的端口|
98100
|installation.namespace | 部署polaris组件所在的namespace|
99101

deploy/helm/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@ The currently supported configurations are as follows:
9595
|polaris.storage.service.httpPort | polaris service expose, polaris-server listening http port number|
9696
|polaris.storage.service.grpcPort | polaris service expose, polaris-server listening grpc port number|
9797
|polaris.storage.service.webPort | polaris service expose, polaris-server listening web port number|
98+
|polaris.auth.consoleOpen | polaris open the console interface auth, open the default|
99+
|polaris.auth.clientOpen | polaris open the client interface auth, close the default|
98100
|monitor.port | The port through which the client reports monitoring information|
99101
|installation.namespace | namespace for polaris installation|

deploy/helm/templates/polaris-server-config.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ data:
152152
openConnLimit: false
153153
maxConnPerHost: 128
154154
maxConnLimit: 10240
155+
- name: prometheusserver
156+
option:
157+
listenIP: "0.0.0.0"
158+
listenPort: {{ .Values.service.prometheusPort }}
159+
connLimit:
160+
openConnLimit: false
161+
maxConnPerHost: 128
162+
maxConnLimit: 10240
155163
# - name: l5pbserver
156164
# option:
157165
# listenIP: 0.0.0.0
@@ -162,8 +170,10 @@ data:
162170
name: defaultAuth
163171
option:
164172
salt: polarismesh@2021
165-
consoleOpen: true
166-
clientOpen: false
173+
consoleOpen: {{ .Values.polaris.auth.consoleOpen }}
174+
clientOpen: {{ .Values.polaris.auth.clientOpen }}
175+
namespace:
176+
autoCreate: true
167177
naming:
168178
auth:
169179
open: false
@@ -234,6 +244,7 @@ data:
234244
- name: users
235245
- name: strategyRule
236246
- name: namespace
247+
- name: client
237248
# - name: l5 # 加载l5数据
238249
# 存储配置
239250
store:

deploy/helm/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ polaris:
2323
cpu: "500m"
2424
memory: "1000Mi"
2525
replicaCount: 1
26+
auth:
27+
consoleOpen: true
28+
clientOpen: false
2629
storage:
2730
db:
2831
address: localhost:3306
@@ -41,6 +44,7 @@ service:
4144
webPort: 8080
4245
xdsv3Port: 15010
4346
configGrpcPort: 8093
47+
prometheusPort: 9000
4448

4549
monitor:
4650
port: 9091

deploy/standalone/k8s/01-polaris-server-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ data:
157157
openConnLimit: false
158158
maxConnPerHost: 128
159159
maxConnLimit: 10240
160+
- name: prometheusserver
161+
option:
162+
listenIP: "0.0.0.0"
163+
listenPort: 9000
164+
connLimit:
165+
openConnLimit: false
166+
maxConnPerHost: 128
167+
maxConnLimit: 10240
160168
# - name: l5pbserver
161169
# option:
162170
# listenIP: 0.0.0.0
@@ -169,6 +177,8 @@ data:
169177
salt: polarismesh@2021
170178
consoleOpen: true
171179
clientOpen: false
180+
namespace:
181+
autoCreate: true
172182
naming:
173183
auth:
174184
open: false
@@ -236,6 +246,7 @@ data:
236246
- name: users
237247
- name: strategyRule
238248
- name: namespace
249+
- name: client
239250
# - name: l5 # 加载l5数据
240251
# 存储配置
241252
store:

namespace/namespace_authability.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ func (svr *serverAuthAbility) GetNamespaces(ctx context.Context, query map[strin
164164
api.ResourceType_Namespaces, ns.Id.GetValue())
165165
}
166166
ns.Editable = utils.NewBoolValue(editable)
167-
// 如果当前登录账户为该资源的主账户,则允许直接进行操作
168-
if ns.Owners.GetValue() == utils.ParseUserID(ctx) {
169-
ns.Editable = utils.NewBoolValue(true)
170-
}
171167
}
172168
}
173169

0 commit comments

Comments
 (0)