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
08270239
Commit
08270239
authored
Feb 24, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test flake
parent
020ab881
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
deployment.go
pkg/util/deployment/deployment.go
+5
-5
util.go
test/e2e/util.go
+3
-3
No files found.
pkg/util/deployment/deployment.go
View file @
08270239
...
@@ -183,8 +183,8 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
...
@@ -183,8 +183,8 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
return
return
}
}
// 1. Add hash template label to the rs. This ensures that any newly created pods will have the new label.
// 1. Add hash template label to the rs. This ensures that any newly created pods will have the new label.
if
len
(
rs
.
Spec
.
Template
.
Labels
[
extensions
.
DefaultDeploymentUniqueLabelKey
])
==
0
{
if
len
(
updatedRS
.
Spec
.
Template
.
Labels
[
extensions
.
DefaultDeploymentUniqueLabelKey
])
==
0
{
updatedRS
,
err
=
updateRSWithRetries
(
c
.
Extensions
()
.
ReplicaSets
(
namespace
),
&
rs
,
func
(
updated
*
extensions
.
ReplicaSet
)
{
updatedRS
,
err
=
updateRSWithRetries
(
c
.
Extensions
()
.
ReplicaSets
(
namespace
),
updatedRS
,
func
(
updated
*
extensions
.
ReplicaSet
)
{
updated
.
Spec
.
Template
.
Labels
=
labelsutil
.
AddLabel
(
updated
.
Spec
.
Template
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
updated
.
Spec
.
Template
.
Labels
=
labelsutil
.
AddLabel
(
updated
.
Spec
.
Template
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -192,14 +192,14 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
...
@@ -192,14 +192,14 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
}
}
// Make sure rs pod template is updated so that it won't create pods without the new label (orphaned pods).
// 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
updatedRS
.
Generation
>
updatedRS
.
Status
.
ObservedGeneration
{
if
err
=
waitForReplicaSetUpdated
(
c
,
updatedRS
.
Generation
,
namespace
,
rs
.
Name
);
err
!=
nil
{
if
err
=
waitForReplicaSetUpdated
(
c
,
updatedRS
.
Generation
,
namespace
,
updatedRS
.
Name
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error waiting for rs %s generation %d observed by controller: %v"
,
updatedRS
.
Name
,
updatedRS
.
Generation
,
err
)
return
nil
,
fmt
.
Errorf
(
"error waiting for rs %s generation %d observed by controller: %v"
,
updatedRS
.
Name
,
updatedRS
.
Generation
,
err
)
}
}
}
}
}
}
// 2. Update all pods managed by the rs to have the new hash label, so they will be correctly adopted.
// 2. Update all pods managed by the rs to have the new hash label, so they will be correctly adopted.
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
rs
.
Spec
.
Selector
)
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
updatedRS
.
Spec
.
Selector
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -214,7 +214,7 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
...
@@ -214,7 +214,7 @@ func addHashKeyToRSAndPods(deployment extensions.Deployment, c clientset.Interfa
// 3. Update rs label and selector to include the new hash label
// 3. Update rs label and selector to include the new hash label
// Copy the old selector, so that we can scrub out any orphaned pods
// Copy the old selector, so that we can scrub out any orphaned pods
if
updatedRS
,
err
=
updateRSWithRetries
(
c
.
Extensions
()
.
ReplicaSets
(
namespace
),
&
rs
,
func
(
updated
*
extensions
.
ReplicaSet
)
{
if
updatedRS
,
err
=
updateRSWithRetries
(
c
.
Extensions
()
.
ReplicaSets
(
namespace
),
updatedRS
,
func
(
updated
*
extensions
.
ReplicaSet
)
{
updated
.
Labels
=
labelsutil
.
AddLabel
(
updated
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
updated
.
Labels
=
labelsutil
.
AddLabel
(
updated
.
Labels
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
updated
.
Spec
.
Selector
=
labelsutil
.
AddLabelToSelector
(
updated
.
Spec
.
Selector
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
updated
.
Spec
.
Selector
=
labelsutil
.
AddLabelToSelector
(
updated
.
Spec
.
Selector
,
extensions
.
DefaultDeploymentUniqueLabelKey
,
hash
)
});
err
!=
nil
{
});
err
!=
nil
{
...
...
test/e2e/util.go
View file @
08270239
...
@@ -2227,11 +2227,11 @@ func waitForDeploymentOldRSsNum(c *clientset.Clientset, ns, deploymentName strin
...
@@ -2227,11 +2227,11 @@ func waitForDeploymentOldRSsNum(c *clientset.Clientset, ns, deploymentName strin
}
}
func
logReplicaSetsOfDeployment
(
deployment
*
extensions
.
Deployment
,
allOldRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
)
{
func
logReplicaSetsOfDeployment
(
deployment
*
extensions
.
Deployment
,
allOldRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
)
{
Logf
(
"Deployment
= %+v"
,
deployment
)
Logf
(
"Deployment
: %+v. Selector = %+v"
,
deployment
,
deployment
.
Spec
.
Selector
)
for
i
:=
range
allOldRSs
{
for
i
:=
range
allOldRSs
{
Logf
(
"All old ReplicaSets (%d/%d) of deployment %s: %+v
"
,
i
+
1
,
len
(
allOldRSs
),
deployment
.
Name
,
allOldRSs
[
i
]
)
Logf
(
"All old ReplicaSets (%d/%d) of deployment %s: %+v
. Selector = %+v"
,
i
+
1
,
len
(
allOldRSs
),
deployment
.
Name
,
allOldRSs
[
i
],
allOldRSs
[
i
]
.
Spec
.
Selector
)
}
}
Logf
(
"New ReplicaSet of deployment %s: %+v
"
,
deployment
.
Name
,
newRS
)
Logf
(
"New ReplicaSet of deployment %s: %+v
. Selector = %+v"
,
deployment
.
Name
,
newRS
,
newRS
.
Spec
.
Selector
)
}
}
func
waitForObservedDeployment
(
c
*
clientset
.
Clientset
,
ns
,
deploymentName
string
,
desiredGeneration
int64
)
error
{
func
waitForObservedDeployment
(
c
*
clientset
.
Clientset
,
ns
,
deploymentName
string
,
desiredGeneration
int64
)
error
{
...
...
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