Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ba2404fd
Commit
ba2404fd
authored
Feb 08, 2018
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix describe when allocatable CPU/Memory is 0
parent
3cf94ef1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
describe.go
pkg/printers/internalversion/describe.go
+12
-4
No files found.
pkg/printers/internalversion/describe.go
View file @
ba2404fd
...
...
@@ -2917,10 +2917,18 @@ func describeNodeResource(nodeNonTerminatedPodsList *api.PodList, node *api.Node
w
.
Write
(
LEVEL_1
,
"------------
\t
----------
\t
---------------
\t
-------------
\n
"
)
reqs
,
limits
:=
getPodsTotalRequestsAndLimits
(
nodeNonTerminatedPodsList
)
cpuReqs
,
cpuLimits
,
memoryReqs
,
memoryLimits
:=
reqs
[
api
.
ResourceCPU
],
limits
[
api
.
ResourceCPU
],
reqs
[
api
.
ResourceMemory
],
limits
[
api
.
ResourceMemory
]
fractionCpuReqs
:=
float64
(
cpuReqs
.
MilliValue
())
/
float64
(
allocatable
.
Cpu
()
.
MilliValue
())
*
100
fractionCpuLimits
:=
float64
(
cpuLimits
.
MilliValue
())
/
float64
(
allocatable
.
Cpu
()
.
MilliValue
())
*
100
fractionMemoryReqs
:=
float64
(
memoryReqs
.
Value
())
/
float64
(
allocatable
.
Memory
()
.
Value
())
*
100
fractionMemoryLimits
:=
float64
(
memoryLimits
.
Value
())
/
float64
(
allocatable
.
Memory
()
.
Value
())
*
100
fractionCpuReqs
:=
float64
(
0
)
fractionCpuLimits
:=
float64
(
0
)
if
allocatable
.
Cpu
()
.
MilliValue
()
!=
0
{
fractionCpuReqs
=
float64
(
cpuReqs
.
MilliValue
())
/
float64
(
allocatable
.
Cpu
()
.
MilliValue
())
*
100
fractionCpuLimits
=
float64
(
cpuLimits
.
MilliValue
())
/
float64
(
allocatable
.
Cpu
()
.
MilliValue
())
*
100
}
fractionMemoryReqs
:=
float64
(
0
)
fractionMemoryLimits
:=
float64
(
0
)
if
allocatable
.
Memory
()
.
Value
()
!=
0
{
fractionMemoryReqs
=
float64
(
memoryReqs
.
Value
())
/
float64
(
allocatable
.
Memory
()
.
Value
())
*
100
fractionMemoryLimits
=
float64
(
memoryLimits
.
Value
())
/
float64
(
allocatable
.
Memory
()
.
Value
())
*
100
}
w
.
Write
(
LEVEL_1
,
"%s (%d%%)
\t
%s (%d%%)
\t
%s (%d%%)
\t
%s (%d%%)
\n
"
,
cpuReqs
.
String
(),
int64
(
fractionCpuReqs
),
cpuLimits
.
String
(),
int64
(
fractionCpuLimits
),
memoryReqs
.
String
(),
int64
(
fractionMemoryReqs
),
memoryLimits
.
String
(),
int64
(
fractionMemoryLimits
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment