Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
c5f787b3
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
c5f787b3
编写于
6月 04, 2019
作者:
R
runzexia
提交者:
GitHub
6月 04, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into master
上级
2f02aa55
22dca0ad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
28 deletion
+12
-28
pkg/controller/add_clusterrolebinding.go
pkg/controller/add_clusterrolebinding.go
+3
-1
pkg/simple/client/elasticsearch/esclient.go
pkg/simple/client/elasticsearch/esclient.go
+9
-27
未找到文件。
pkg/controller/add_clusterrolebinding.go
浏览文件 @
c5f787b3
...
...
@@ -18,7 +18,9 @@
package
controller
import
"kubesphere.io/kubesphere/pkg/controller/clusterrolebinding"
func
init
()
{
// AddToManagerFuncs is a list of functions to create controllers and add them to a manager.
//
AddToManagerFuncs = append(AddToManagerFuncs, clusterrolebinding.Add)
AddToManagerFuncs
=
append
(
AddToManagerFuncs
,
clusterrolebinding
.
Add
)
}
pkg/simple/client/elasticsearch/esclient.go
浏览文件 @
c5f787b3
...
...
@@ -137,12 +137,9 @@ type ContainerHighLightField struct {
type
EmptyField
struct
{
}
// The aggs object holds two aggregations to be computed by Elasticsearch
// ContainterAgg is a cardinality aggregation to calculate the count of distinct containers
// StartTimeAgg is a top hits aggregation to retrieve the first record
// StatisticsAggs, the struct for `aggs` of type Request, holds a cardinality aggregation for distinct container counting
type
StatisticsAggs
struct
{
ContainerAgg
ContainerAgg
`json:"containers"`
StartTimeAgg
StartTimeAgg
`json:"starttime"`
}
type
ContainerAgg
struct
{
...
...
@@ -153,15 +150,6 @@ type AggField struct {
Field
string
`json:"field"`
}
type
StartTimeAgg
struct
{
TopHits
TopHits
`json:"top_hits"`
}
type
TopHits
struct
{
Sort
[]
Sort
`json:"sort"`
Size
int
`json:"size"`
}
type
HistogramAggs
struct
{
HistogramAgg
HistogramAgg
`json:"histogram"`
}
...
...
@@ -255,8 +243,7 @@ func createQueryRequest(param QueryParameters) (int, []byte, error) {
if
param
.
Operation
==
"statistics"
{
operation
=
OperationStatistics
containerAgg
:=
AggField
{
"kubernetes.docker_id.keyword"
}
startTimeAgg
:=
TopHits
{[]
Sort
{{
Order
{
"asc"
}}},
1
}
statisticAggs
:=
StatisticsAggs
{
ContainerAgg
{
containerAgg
},
StartTimeAgg
{
startTimeAgg
}}
statisticAggs
:=
StatisticsAggs
{
ContainerAgg
{
containerAgg
}}
request
.
Aggs
=
statisticAggs
request
.
Size
=
0
}
else
if
param
.
Operation
==
"histogram"
{
...
...
@@ -361,20 +348,15 @@ type ReadResult struct {
Records
[]
LogRecord
`json:"records,omitempty"`
}
//
The aggregations object represents the return from an aggregation (see StatisticsAggs type)
//
StatisticsResponseAggregations, the struct for `aggregations` of type Reponse, holds return results from the aggregation StatisticsAggs
type
StatisticsResponseAggregations
struct
{
ContainerCount
ContainerCount
`json:"containers"`
StartTime
StartTimeTopHit
`json:"starttime"`
ContainerCount
ContainerCount
`json:"containers"`
}
type
ContainerCount
struct
{
Value
int64
`json:"value"`
}
type
StartTimeTopHit
struct
{
Hits
Hits
`json:"hits"`
}
type
HistogramAggregations
struct
{
HistogramAggregation
HistogramAggregation
`json:"histogram"`
}
...
...
@@ -396,7 +378,6 @@ type HistogramRecord struct {
type
StatisticsResult
struct
{
Containers
int64
`json:"containers"`
Logs
int64
`json:"logs"`
StartTime
int64
`json:"starttime"`
}
type
HistogramResult
struct
{
...
...
@@ -460,13 +441,14 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [
if
response
.
Status
!=
0
{
//Elastic error, eg, es_rejected_execute_exception
queryResult
.
Status
=
response
.
Status
glog
.
Errorln
(
"The query failed with no response"
)
return
&
queryResult
}
if
response
.
Shards
.
Successful
!=
response
.
Shards
.
Total
{
//Elastic some shards error
queryResult
.
Status
=
http
.
StatusInternalServerError
return
&
queryResult
glog
.
Warningf
(
"Not all shards succeed, successful shards: %d, skipped shards: %d, failed shards: %d"
,
response
.
Shards
.
Successful
,
response
.
Shards
.
Skipped
,
response
.
Shards
.
Failed
)
}
switch
operation
{
...
...
@@ -496,8 +478,7 @@ func parseQueryResult(operation int, param QueryParameters, body []byte, query [
queryResult
.
Status
=
http
.
StatusInternalServerError
return
&
queryResult
}
queryResult
.
Statistics
=
&
StatisticsResult
{
Containers
:
statisticsResponse
.
ContainerCount
.
Value
,
Logs
:
statisticsResponse
.
StartTime
.
Hits
.
Total
,
StartTime
:
statisticsResponse
.
StartTime
.
Hits
.
Hits
[
0
]
.
Sort
[
0
]}
queryResult
.
Statistics
=
&
StatisticsResult
{
Containers
:
statisticsResponse
.
ContainerCount
.
Value
,
Logs
:
response
.
Hits
.
Total
}
case
OperationHistogram
:
var
histogramResult
HistogramResult
...
...
@@ -583,6 +564,7 @@ func Query(param QueryParameters) *QueryResult {
}
url
:=
fmt
.
Sprintf
(
"http://%s:%s/%s*/_search"
,
es
.
Host
,
es
.
Port
,
es
.
Index
)
request
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
bytes
.
NewBuffer
(
query
))
if
err
!=
nil
{
glog
.
Errorln
(
err
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录