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
a8ba2890
Commit
a8ba2890
authored
May 22, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25617 from smarterclayton/manage_deploy_logs
Automatic merge from submit-queue Rolling updater should allow progress to be logged / detected
parents
88766e8a
5d40f94f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
rolling_updater.go
pkg/kubectl/rolling_updater.go
+39
-0
No files found.
pkg/kubectl/rolling_updater.go
View file @
a8ba2890
...
@@ -83,6 +83,10 @@ type RollingUpdaterConfig struct {
...
@@ -83,6 +83,10 @@ type RollingUpdaterConfig struct {
// further, ensuring that total number of pods running at any time during
// further, ensuring that total number of pods running at any time during
// the update is atmost 130% of desired pods.
// the update is atmost 130% of desired pods.
MaxSurge
intstr
.
IntOrString
MaxSurge
intstr
.
IntOrString
// OnProgress is invoked if set during each scale cycle, to allow the caller to perform additional logic or
// abort the scale. If an error is returned the cleanup method will not be invoked. The percentage value
// is a synthetic "progress" calculation that represents the approximate percentage completion.
OnProgress
func
(
oldRc
,
newRc
*
api
.
ReplicationController
,
percentage
int
)
error
}
}
// RollingUpdaterCleanupPolicy is a cleanup action to take after the
// RollingUpdaterCleanupPolicy is a cleanup action to take after the
...
@@ -217,6 +221,26 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
...
@@ -217,6 +221,26 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
fmt
.
Fprintf
(
out
,
"Scaling up %s from %d to %d, scaling down %s from %d to 0 (keep %d pods available, don't exceed %d pods)
\n
"
,
fmt
.
Fprintf
(
out
,
"Scaling up %s from %d to %d, scaling down %s from %d to 0 (keep %d pods available, don't exceed %d pods)
\n
"
,
newRc
.
Name
,
newRc
.
Spec
.
Replicas
,
desired
,
oldRc
.
Name
,
oldRc
.
Spec
.
Replicas
,
minAvailable
,
desired
+
maxSurge
)
newRc
.
Name
,
newRc
.
Spec
.
Replicas
,
desired
,
oldRc
.
Name
,
oldRc
.
Spec
.
Replicas
,
minAvailable
,
desired
+
maxSurge
)
// give a caller incremental notification and allow them to exit early
goal
:=
desired
-
newRc
.
Spec
.
Replicas
if
goal
<
0
{
goal
=
-
goal
}
progress
:=
func
(
complete
bool
)
error
{
if
config
.
OnProgress
==
nil
{
return
nil
}
progress
:=
desired
-
newRc
.
Spec
.
Replicas
if
progress
<
0
{
progress
=
-
progress
}
percentage
:=
100
if
!
complete
&&
goal
>
0
{
percentage
=
int
((
goal
-
progress
)
*
100
/
goal
)
}
return
config
.
OnProgress
(
oldRc
,
newRc
,
percentage
)
}
// Scale newRc and oldRc until newRc has the desired number of replicas and
// Scale newRc and oldRc until newRc has the desired number of replicas and
// oldRc has 0 replicas.
// oldRc has 0 replicas.
progressDeadline
:=
time
.
Now
()
.
UnixNano
()
+
config
.
Timeout
.
Nanoseconds
()
progressDeadline
:=
time
.
Now
()
.
UnixNano
()
+
config
.
Timeout
.
Nanoseconds
()
...
@@ -232,6 +256,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
...
@@ -232,6 +256,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
}
}
newRc
=
scaledRc
newRc
=
scaledRc
// notify the caller if necessary
if
err
:=
progress
(
false
);
err
!=
nil
{
return
err
}
// Wait between scaling operations for things to settle.
// Wait between scaling operations for things to settle.
time
.
Sleep
(
config
.
UpdatePeriod
)
time
.
Sleep
(
config
.
UpdatePeriod
)
...
@@ -242,6 +271,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
...
@@ -242,6 +271,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
}
}
oldRc
=
scaledRc
oldRc
=
scaledRc
// notify the caller if necessary
if
err
:=
progress
(
false
);
err
!=
nil
{
return
err
}
// If we are making progress, continue to advance the progress deadline.
// If we are making progress, continue to advance the progress deadline.
// Otherwise, time out with an error.
// Otherwise, time out with an error.
progressMade
:=
(
newRc
.
Spec
.
Replicas
!=
newReplicas
)
||
(
oldRc
.
Spec
.
Replicas
!=
oldReplicas
)
progressMade
:=
(
newRc
.
Spec
.
Replicas
!=
newReplicas
)
||
(
oldRc
.
Spec
.
Replicas
!=
oldReplicas
)
...
@@ -252,6 +286,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
...
@@ -252,6 +286,11 @@ func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error {
}
}
}
}
// notify the caller if necessary
if
err
:=
progress
(
true
);
err
!=
nil
{
return
err
}
// Housekeeping and cleanup policy execution.
// Housekeeping and cleanup policy execution.
return
r
.
cleanup
(
oldRc
,
newRc
,
config
)
return
r
.
cleanup
(
oldRc
,
newRc
,
config
)
}
}
...
...
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