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
e42eab59
Commit
e42eab59
authored
Mar 02, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments about deployment revision update
parent
940e0a9b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+17
-10
No files found.
pkg/controller/deployment/deployment_controller.go
View file @
e42eab59
...
@@ -751,32 +751,39 @@ func (dc *DeploymentController) getNewReplicaSet(deployment *extensions.Deployme
...
@@ -751,32 +751,39 @@ func (dc *DeploymentController) getNewReplicaSet(deployment *extensions.Deployme
// setNewReplicaSetAnnotations sets new replica set's annotations appropriately by updating its revision and
// setNewReplicaSetAnnotations sets new replica set's annotations appropriately by updating its revision and
// copying required deployment annotations to it; it returns true if replica set's annotation is changed.
// copying required deployment annotations to it; it returns true if replica set's annotation is changed.
func
setNewReplicaSetAnnotations
(
deployment
*
extensions
.
Deployment
,
rs
*
extensions
.
ReplicaSet
,
newRevision
string
)
bool
{
func
setNewReplicaSetAnnotations
(
deployment
*
extensions
.
Deployment
,
newRS
*
extensions
.
ReplicaSet
,
newRevision
string
)
bool
{
// First, copy deployment's annotations
// First, copy deployment's annotations
annotationChanged
:=
copyDeploymentAnnotationsToReplicaSet
(
deployment
,
rs
)
annotationChanged
:=
copyDeploymentAnnotationsToReplicaSet
(
deployment
,
newRS
)
// Then, update replica set's revision annotation
// Then, update replica set's revision annotation
if
rs
.
Annotations
==
nil
{
if
newRS
.
Annotations
==
nil
{
rs
.
Annotations
=
make
(
map
[
string
]
string
)
newRS
.
Annotations
=
make
(
map
[
string
]
string
)
}
}
if
rs
.
Annotations
[
deploymentutil
.
RevisionAnnotation
]
<
newRevision
{
// The newRS's revision should be the greatest among all RSes. Usually, its revision number is newRevision (the max revision number
rs
.
Annotations
[
deploymentutil
.
RevisionAnnotation
]
=
newRevision
// of all old RSes + 1). However, it's possible that some of the old RSes are deleted after the newRS revision being updated, and
// newRevision becomes smaller than newRS's revision. We should only update newRS revision when it's smaller than newRevision.
if
newRS
.
Annotations
[
deploymentutil
.
RevisionAnnotation
]
<
newRevision
{
newRS
.
Annotations
[
deploymentutil
.
RevisionAnnotation
]
=
newRevision
annotationChanged
=
true
annotationChanged
=
true
glog
.
V
(
4
)
.
Infof
(
"updating replica set %q's revision to %s - %+v
\n
"
,
rs
.
Name
,
newRevision
,
rs
)
glog
.
V
(
4
)
.
Infof
(
"updating replica set %q's revision to %s - %+v
\n
"
,
newRS
.
Name
,
newRevision
,
newRS
)
}
}
return
annotationChanged
return
annotationChanged
}
}
// copyDeploymentAnnotationsToReplicaSet copies deployment's annotations to replica set's annotations,
// copyDeploymentAnnotationsToReplicaSet copies deployment's annotations to replica set's annotations,
// and returns true if replica set's annotation is changed
// and returns true if replica set's annotation is changed.
// Note that apply and revision annotations are not copied.
func
copyDeploymentAnnotationsToReplicaSet
(
deployment
*
extensions
.
Deployment
,
rs
*
extensions
.
ReplicaSet
)
bool
{
func
copyDeploymentAnnotationsToReplicaSet
(
deployment
*
extensions
.
Deployment
,
rs
*
extensions
.
ReplicaSet
)
bool
{
rsAnnotationsChanged
:=
false
rsAnnotationsChanged
:=
false
if
rs
.
Annotations
==
nil
{
if
rs
.
Annotations
==
nil
{
rs
.
Annotations
=
make
(
map
[
string
]
string
)
rs
.
Annotations
=
make
(
map
[
string
]
string
)
}
}
for
k
,
v
:=
range
deployment
.
Annotations
{
for
k
,
v
:=
range
deployment
.
Annotations
{
// Skip apply annotations and revision annotations
// TODO: How to decide which annotations should / should not be copied?
// TODO: How to decide which annotations should / should not be copied?
// See https://github.com/kubernetes/kubernetes/pull/20035#issuecomment-179558615
// See https://github.com/kubernetes/kubernetes/pull/20035#issuecomment-179558615
// Skip apply annotations and revision annotations.
// newRS revision is updated automatically in getNewReplicaSet, and the deployment's revision number is then updated
// by copying its newRS revision number. We should not copy deployment's revision to its newRS, since the update of
// deployment revision number may fail (revision becomes stale) and the revision number in newRS is more reliable.
if
k
==
kubectl
.
LastAppliedConfigAnnotation
||
k
==
deploymentutil
.
RevisionAnnotation
||
rs
.
Annotations
[
k
]
==
v
{
if
k
==
kubectl
.
LastAppliedConfigAnnotation
||
k
==
deploymentutil
.
RevisionAnnotation
||
rs
.
Annotations
[
k
]
==
v
{
continue
continue
}
}
...
...
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