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
1ece902d
Commit
1ece902d
authored
Sep 02, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the race check after an overlapping deployment is deleted
parent
2a7d0df3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
deployment.go
test/e2e/deployment.go
+34
-3
No files found.
test/e2e/deployment.go
View file @
1ece902d
...
@@ -18,6 +18,7 @@ package e2e
...
@@ -18,6 +18,7 @@ package e2e
import
(
import
(
"fmt"
"fmt"
"strings"
"time"
"time"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -181,7 +182,15 @@ func checkDeploymentRevision(c *clientset.Clientset, ns, deploymentName, revisio
...
@@ -181,7 +182,15 @@ func checkDeploymentRevision(c *clientset.Clientset, ns, deploymentName, revisio
return
deployment
,
newRS
return
deployment
,
newRS
}
}
func
stopDeploymentOverlap
(
c
*
clientset
.
Clientset
,
oldC
client
.
Interface
,
ns
,
deploymentName
,
overlapWith
string
)
{
stopDeploymentMaybeOverlap
(
c
,
oldC
,
ns
,
deploymentName
,
overlapWith
)
}
func
stopDeployment
(
c
*
clientset
.
Clientset
,
oldC
client
.
Interface
,
ns
,
deploymentName
string
)
{
func
stopDeployment
(
c
*
clientset
.
Clientset
,
oldC
client
.
Interface
,
ns
,
deploymentName
string
)
{
stopDeploymentMaybeOverlap
(
c
,
oldC
,
ns
,
deploymentName
,
""
)
}
func
stopDeploymentMaybeOverlap
(
c
*
clientset
.
Clientset
,
oldC
client
.
Interface
,
ns
,
deploymentName
,
overlapWith
string
)
{
deployment
,
err
:=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Get
(
deploymentName
)
deployment
,
err
:=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Get
(
deploymentName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -202,7 +211,18 @@ func stopDeployment(c *clientset.Clientset, oldC client.Interface, ns, deploymen
...
@@ -202,7 +211,18 @@ func stopDeployment(c *clientset.Clientset, oldC client.Interface, ns, deploymen
options
:=
api
.
ListOptions
{
LabelSelector
:
selector
}
options
:=
api
.
ListOptions
{
LabelSelector
:
selector
}
rss
,
err
:=
c
.
Extensions
()
.
ReplicaSets
(
ns
)
.
List
(
options
)
rss
,
err
:=
c
.
Extensions
()
.
ReplicaSets
(
ns
)
.
List
(
options
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
rss
.
Items
)
.
Should
(
HaveLen
(
0
))
// RSes may be created by overlapping deployments right after this deployment is deleted, ignore them
if
len
(
overlapWith
)
==
0
{
Expect
(
rss
.
Items
)
.
Should
(
HaveLen
(
0
))
}
else
{
noOverlapRSes
:=
[]
extensions
.
ReplicaSet
{}
for
_
,
rs
:=
range
rss
.
Items
{
if
!
strings
.
HasPrefix
(
rs
.
Name
,
overlapWith
)
{
noOverlapRSes
=
append
(
noOverlapRSes
,
rs
)
}
}
Expect
(
noOverlapRSes
)
.
Should
(
HaveLen
(
0
))
}
framework
.
Logf
(
"Ensuring deployment %s's Pods were deleted"
,
deploymentName
)
framework
.
Logf
(
"Ensuring deployment %s's Pods were deleted"
,
deploymentName
)
var
pods
*
api
.
PodList
var
pods
*
api
.
PodList
if
err
:=
wait
.
PollImmediate
(
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
PollImmediate
(
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
...
@@ -210,8 +230,19 @@ func stopDeployment(c *clientset.Clientset, oldC client.Interface, ns, deploymen
...
@@ -210,8 +230,19 @@ func stopDeployment(c *clientset.Clientset, oldC client.Interface, ns, deploymen
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
if
len
(
pods
.
Items
)
==
0
{
// Pods may be created by overlapping deployments right after this deployment is deleted, ignore them
if
len
(
overlapWith
)
==
0
&&
len
(
pods
.
Items
)
==
0
{
return
true
,
nil
return
true
,
nil
}
else
if
len
(
overlapWith
)
!=
0
{
noOverlapPods
:=
[]
api
.
Pod
{}
for
_
,
pod
:=
range
pods
.
Items
{
if
!
strings
.
HasPrefix
(
pod
.
Name
,
overlapWith
)
{
noOverlapPods
=
append
(
noOverlapPods
,
pod
)
}
}
if
len
(
noOverlapPods
)
==
0
{
return
true
,
nil
}
}
}
return
false
,
nil
return
false
,
nil
});
err
!=
nil
{
});
err
!=
nil
{
...
@@ -1224,7 +1255,7 @@ func testOverlappingDeployment(f *framework.Framework) {
...
@@ -1224,7 +1255,7 @@ func testOverlappingDeployment(f *framework.Framework) {
Expect
(
rsList
.
Items
[
0
]
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
)
.
To
(
Equal
(
deploy
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
))
Expect
(
rsList
.
Items
[
0
]
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
)
.
To
(
Equal
(
deploy
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
))
By
(
"Deleting the first deployment"
)
By
(
"Deleting the first deployment"
)
stopDeployment
(
c
,
f
.
Client
,
ns
,
deploy
.
Name
)
stopDeployment
Overlap
(
c
,
f
.
Client
,
ns
,
deploy
.
Name
,
deployOverlapping
.
Name
)
// Wait for overlapping annotation cleared
// Wait for overlapping annotation cleared
By
(
"Waiting for the second deployment to clear overlapping annotation"
)
By
(
"Waiting for the second deployment to clear overlapping annotation"
)
...
...
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