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
7bbf7b04
Commit
7bbf7b04
authored
Feb 10, 2017
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
controller: poll replica sets from the cache
parent
ce998a9f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
sync.go
pkg/controller/deployment/sync.go
+6
-2
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+7
-6
No files found.
pkg/controller/deployment/sync.go
View file @
7bbf7b04
...
...
@@ -180,7 +180,9 @@ func (dc *DeploymentController) addHashKeyToRSAndPods(rs *extensions.ReplicaSet)
}
// Make sure rs pod template is updated so that it won't create pods without the new label (orphaned pods).
if
updatedRS
.
Generation
>
updatedRS
.
Status
.
ObservedGeneration
{
if
err
=
deploymentutil
.
WaitForReplicaSetUpdated
(
dc
.
client
,
updatedRS
.
Generation
,
updatedRS
.
Namespace
,
updatedRS
.
Name
);
err
!=
nil
{
// TODO: Revisit if we really need to wait here as opposed to returning and
// potentially unblocking this worker (can wait up to 1min before timing out).
if
err
=
deploymentutil
.
WaitForReplicaSetUpdated
(
dc
.
rsLister
,
updatedRS
.
Generation
,
updatedRS
.
Namespace
,
updatedRS
.
Name
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error waiting for replica set %s/%s to be observed by controller: %v"
,
updatedRS
.
Namespace
,
updatedRS
.
Name
,
err
)
}
glog
.
V
(
4
)
.
Infof
(
"Observed the update of replica set %s/%s's pod template with hash %s."
,
rs
.
Namespace
,
rs
.
Name
,
hash
)
...
...
@@ -213,7 +215,9 @@ func (dc *DeploymentController) addHashKeyToRSAndPods(rs *extensions.ReplicaSet)
// WaitForReplicaSetUpdated, the replicaset controller should have dropped
// FullyLabeledReplicas to 0 already, we only need to wait it to increase
// back to the number of replicas in the spec.
if
err
:=
deploymentutil
.
WaitForPodsHashPopulated
(
dc
.
client
,
updatedRS
.
Generation
,
updatedRS
.
Namespace
,
updatedRS
.
Name
);
err
!=
nil
{
// TODO: Revisit if we really need to wait here as opposed to returning and
// potentially unblocking this worker (can wait up to 1min before timing out).
if
err
:=
deploymentutil
.
WaitForPodsHashPopulated
(
dc
.
rsLister
,
updatedRS
.
Generation
,
updatedRS
.
Namespace
,
updatedRS
.
Name
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Replica set %s/%s: error waiting for replicaset controller to observe pods being labeled with template hash: %v"
,
updatedRS
.
Namespace
,
updatedRS
.
Name
,
err
)
}
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
7bbf7b04
...
...
@@ -41,6 +41,7 @@ import (
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
corelisters
"k8s.io/kubernetes/pkg/client/listers/core/v1"
extensionslisters
"k8s.io/kubernetes/pkg/client/listers/extensions/v1beta1"
"k8s.io/kubernetes/pkg/controller"
labelsutil
"k8s.io/kubernetes/pkg/util/labels"
)
...
...
@@ -661,9 +662,9 @@ func FindOldReplicaSets(deployment *extensions.Deployment, rsList []*extensions.
}
// WaitForReplicaSetUpdated polls the replica set until it is updated.
func
WaitForReplicaSetUpdated
(
c
clientset
.
Interface
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
Poll
(
10
*
time
.
Millis
econd
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
Extensions
()
.
ReplicaSets
(
namespace
)
.
Get
(
name
,
metav1
.
GetOptions
{}
)
func
WaitForReplicaSetUpdated
(
c
extensionslisters
.
ReplicaSetLister
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
Poll
Immediate
(
1
*
time
.
S
econd
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
ReplicaSets
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
err
}
...
...
@@ -672,9 +673,9 @@ func WaitForReplicaSetUpdated(c clientset.Interface, desiredGeneration int64, na
}
// WaitForPodsHashPopulated polls the replica set until updated and fully labeled.
func
WaitForPodsHashPopulated
(
c
clientset
.
Interface
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
Poll
(
1
*
time
.
Second
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
Extensions
()
.
ReplicaSets
(
namespace
)
.
Get
(
name
,
metav1
.
GetOptions
{}
)
func
WaitForPodsHashPopulated
(
c
extensionslisters
.
ReplicaSetLister
,
desiredGeneration
int64
,
namespace
,
name
string
)
error
{
return
wait
.
Poll
Immediate
(
1
*
time
.
Second
,
1
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
rs
,
err
:=
c
.
ReplicaSets
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
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