Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
9eba26b7
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看板
未验证
提交
9eba26b7
编写于
8月 14, 2020
作者:
Z
zryfish
提交者:
GitHub
8月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix node resources requests not returned bug (#2877)
Signed-off-by:
N
Jeff
<
jeffzhang@yunify.com
>
上级
2aa120f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
6 deletion
+40
-6
pkg/models/resources/v1alpha3/node/nodes.go
pkg/models/resources/v1alpha3/node/nodes.go
+40
-6
未找到文件。
pkg/models/resources/v1alpha3/node/nodes.go
浏览文件 @
9eba26b7
...
...
@@ -27,6 +27,7 @@ import (
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3"
"sort"
)
// Those annotations were added to node only for display purposes
...
...
@@ -69,14 +70,44 @@ func (c nodesGetter) Get(_, name string) (runtime.Object, error) {
return
node
,
nil
}
func
(
c
nodesGetter
)
List
(
_
string
,
q
uery
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
{
nodes
,
err
:=
c
.
informers
.
Core
()
.
V1
()
.
Nodes
()
.
Lister
()
.
List
(
q
uery
.
Selector
())
func
(
c
nodesGetter
)
List
(
_
string
,
q
*
query
.
Query
)
(
*
api
.
ListResult
,
error
)
{
nodes
,
err
:=
c
.
informers
.
Core
()
.
V1
()
.
Nodes
()
.
Lister
()
.
List
(
q
.
Selector
())
if
err
!=
nil
{
return
nil
,
err
}
var
filtered
[]
*
v1
.
Node
for
_
,
object
:=
range
nodes
{
selected
:=
true
for
field
,
value
:=
range
q
.
Filters
{
if
!
c
.
filter
(
object
,
query
.
Filter
{
Field
:
field
,
Value
:
value
})
{
selected
=
false
break
}
}
if
selected
{
filtered
=
append
(
filtered
,
object
)
}
}
// sort by sortBy field
sort
.
Slice
(
filtered
,
func
(
i
,
j
int
)
bool
{
if
!
q
.
Ascending
{
return
c
.
compare
(
filtered
[
i
],
filtered
[
j
],
q
.
SortBy
)
}
return
!
c
.
compare
(
filtered
[
i
],
filtered
[
j
],
q
.
SortBy
)
})
total
:=
len
(
filtered
)
if
q
.
Pagination
==
nil
{
q
.
Pagination
=
query
.
NoPagination
}
start
,
end
:=
q
.
Pagination
.
GetValidPagination
(
total
)
selectedNodes
:=
filtered
[
start
:
end
]
// ignore the error, skip annotating process if error happened
pods
,
_
:=
c
.
informers
.
Core
()
.
V1
()
.
Pods
()
.
Lister
()
.
Pods
(
""
)
.
List
(
query
.
Selector
())
pods
,
_
:=
c
.
informers
.
Core
()
.
V1
()
.
Pods
()
.
Lister
()
.
Pods
(
""
)
.
List
(
labels
.
Everything
())
var
nonTerminatedPodsList
[]
*
v1
.
Pod
for
_
,
pod
:=
range
pods
{
if
pod
.
Status
.
Phase
!=
v1
.
PodSucceeded
&&
pod
.
Status
.
Phase
!=
v1
.
PodFailed
{
...
...
@@ -84,13 +115,16 @@ func (c nodesGetter) List(_ string, query *query.Query) (*api.ListResult, error)
}
}
var
result
[]
runtime
.
Object
for
_
,
node
:=
range
n
odes
{
var
result
[]
interface
{}
for
_
,
node
:=
range
selectedN
odes
{
c
.
annotateNode
(
node
,
nonTerminatedPodsList
)
result
=
append
(
result
,
node
)
}
return
v1alpha3
.
DefaultList
(
result
,
query
,
c
.
compare
,
c
.
filter
),
nil
return
&
api
.
ListResult
{
TotalItems
:
total
,
Items
:
result
,
},
nil
}
func
(
c
nodesGetter
)
compare
(
left
runtime
.
Object
,
right
runtime
.
Object
,
field
query
.
Field
)
bool
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录