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
310a7d2e
Commit
310a7d2e
authored
May 31, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding logs in deployment for debugging
parent
294e49f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
controller_utils.go
pkg/controller/controller_utils.go
+1
-1
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+9
-5
No files found.
pkg/controller/controller_utils.go
View file @
310a7d2e
...
@@ -175,7 +175,7 @@ func (exp *ControlleeExpectations) isExpired() bool {
...
@@ -175,7 +175,7 @@ func (exp *ControlleeExpectations) isExpired() bool {
// SetExpectations registers new expectations for the given controller. Forgets existing expectations.
// SetExpectations registers new expectations for the given controller. Forgets existing expectations.
func
(
r
*
ControllerExpectations
)
SetExpectations
(
controllerKey
string
,
add
,
del
int
)
error
{
func
(
r
*
ControllerExpectations
)
SetExpectations
(
controllerKey
string
,
add
,
del
int
)
error
{
exp
:=
&
ControlleeExpectations
{
add
:
int64
(
add
),
del
:
int64
(
del
),
key
:
controllerKey
,
timestamp
:
util
.
RealClock
{}
.
Now
()}
exp
:=
&
ControlleeExpectations
{
add
:
int64
(
add
),
del
:
int64
(
del
),
key
:
controllerKey
,
timestamp
:
util
.
RealClock
{}
.
Now
()}
glog
.
V
(
4
)
.
Infof
(
"Setting expectations %
+
v"
,
exp
)
glog
.
V
(
4
)
.
Infof
(
"Setting expectations %
#
v"
,
exp
)
return
r
.
Add
(
exp
)
return
r
.
Add
(
exp
)
}
}
...
...
pkg/controller/deployment/deployment_controller.go
View file @
310a7d2e
...
@@ -331,7 +331,7 @@ func (dc *DeploymentController) updatePod(old, cur interface{}) {
...
@@ -331,7 +331,7 @@ func (dc *DeploymentController) updatePod(old, cur interface{}) {
}
}
curPod
:=
cur
.
(
*
api
.
Pod
)
curPod
:=
cur
.
(
*
api
.
Pod
)
oldPod
:=
old
.
(
*
api
.
Pod
)
oldPod
:=
old
.
(
*
api
.
Pod
)
glog
.
V
(
4
)
.
Infof
(
"Pod %s updated %
+v -> %+
v."
,
curPod
.
Name
,
oldPod
,
curPod
)
glog
.
V
(
4
)
.
Infof
(
"Pod %s updated %
#v -> %#
v."
,
curPod
.
Name
,
oldPod
,
curPod
)
if
d
:=
dc
.
getDeploymentForPod
(
curPod
);
d
!=
nil
{
if
d
:=
dc
.
getDeploymentForPod
(
curPod
);
d
!=
nil
{
dc
.
enqueueDeployment
(
d
)
dc
.
enqueueDeployment
(
d
)
}
}
...
@@ -1059,7 +1059,7 @@ func (dc *DeploymentController) reconcileOldReplicaSets(allRSs []*extensions.Rep
...
@@ -1059,7 +1059,7 @@ func (dc *DeploymentController) reconcileOldReplicaSets(allRSs []*extensions.Rep
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
nil
return
false
,
nil
}
}
glog
.
V
(
4
)
.
Infof
(
"Scaled down old RSes
by %d"
,
scaledDownCount
)
glog
.
V
(
4
)
.
Infof
(
"Scaled down old RSes
of deployment %s by %d"
,
deployment
.
Name
,
scaledDownCount
)
totalScaledDown
:=
cleanupCount
+
scaledDownCount
totalScaledDown
:=
cleanupCount
+
scaledDownCount
return
totalScaledDown
>
0
,
nil
return
totalScaledDown
>
0
,
nil
...
@@ -1116,19 +1116,20 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [
...
@@ -1116,19 +1116,20 @@ func (dc *DeploymentController) scaleDownOldReplicaSetsForRollingUpdate(allRSs [
minAvailable
:=
deployment
.
Spec
.
Replicas
-
maxUnavailable
minAvailable
:=
deployment
.
Spec
.
Replicas
-
maxUnavailable
minReadySeconds
:=
deployment
.
Spec
.
MinReadySeconds
minReadySeconds
:=
deployment
.
Spec
.
MinReadySeconds
// Find the number of ready pods.
// Find the number of ready pods.
ready
PodCount
,
err
:=
deploymentutil
.
GetAvailablePodsForReplicaSets
(
dc
.
client
,
allRSs
,
minReadySeconds
)
available
PodCount
,
err
:=
deploymentutil
.
GetAvailablePodsForReplicaSets
(
dc
.
client
,
allRSs
,
minReadySeconds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"could not find available pods: %v"
,
err
)
return
0
,
fmt
.
Errorf
(
"could not find available pods: %v"
,
err
)
}
}
if
ready
PodCount
<=
minAvailable
{
if
available
PodCount
<=
minAvailable
{
// Cannot scale down.
// Cannot scale down.
return
0
,
nil
return
0
,
nil
}
}
glog
.
V
(
4
)
.
Infof
(
"Found %d available pods in deployment %s, scaling down old RSes"
,
availablePodCount
,
deployment
.
Name
)
sort
.
Sort
(
controller
.
ReplicaSetsByCreationTimestamp
(
oldRSs
))
sort
.
Sort
(
controller
.
ReplicaSetsByCreationTimestamp
(
oldRSs
))
totalScaledDown
:=
int32
(
0
)
totalScaledDown
:=
int32
(
0
)
totalScaleDownCount
:=
ready
PodCount
-
minAvailable
totalScaleDownCount
:=
available
PodCount
-
minAvailable
for
_
,
targetRS
:=
range
oldRSs
{
for
_
,
targetRS
:=
range
oldRSs
{
if
totalScaledDown
>=
totalScaleDownCount
{
if
totalScaledDown
>=
totalScaleDownCount
{
// No further scaling required.
// No further scaling required.
...
@@ -1221,6 +1222,9 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
...
@@ -1221,6 +1222,9 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
UnavailableReplicas
:
unavailableReplicas
,
UnavailableReplicas
:
unavailableReplicas
,
}
}
_
,
err
=
dc
.
client
.
Extensions
()
.
Deployments
(
deployment
.
ObjectMeta
.
Namespace
)
.
UpdateStatus
(
&
newDeployment
)
_
,
err
=
dc
.
client
.
Extensions
()
.
Deployments
(
deployment
.
ObjectMeta
.
Namespace
)
.
UpdateStatus
(
&
newDeployment
)
if
err
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"Updated deployment %s status: %+v"
,
deployment
.
Name
,
newDeployment
.
Status
)
}
return
err
return
err
}
}
...
...
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