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
96c84303
Commit
96c84303
authored
Aug 02, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix kubectl rolling-update when GC is enabled
parent
c19a65c0
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
87 additions
and
31 deletions
+87
-31
replication_controllers.go
pkg/client/unversioned/replication_controllers.go
+3
-3
replication_controllers_test.go
pkg/client/unversioned/replication_controllers_test.go
+1
-1
fake_replication_controllers.go
...nt/unversioned/testclient/fake_replication_controllers.go
+1
-1
rolling_updater.go
pkg/kubectl/rolling_updater.go
+21
-6
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+55
-14
stop.go
pkg/kubectl/stop.go
+1
-1
density.go
test/e2e/density.go
+1
-1
resource_quota.go
test/e2e/resource_quota.go
+1
-1
service.go
test/e2e/service.go
+1
-1
serviceloadbalancers.go
test/e2e/serviceloadbalancers.go
+1
-1
master_utils.go
test/integration/framework/master_utils.go
+1
-1
No files found.
pkg/client/unversioned/replication_controllers.go
View file @
96c84303
...
@@ -33,7 +33,7 @@ type ReplicationControllerInterface interface {
...
@@ -33,7 +33,7 @@ type ReplicationControllerInterface interface {
Create
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
Create
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
Update
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
Update
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateStatus
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateStatus
(
ctrl
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
Delete
(
name
string
)
error
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
}
}
...
@@ -84,8 +84,8 @@ func (c *replicationControllers) UpdateStatus(controller *api.ReplicationControl
...
@@ -84,8 +84,8 @@ func (c *replicationControllers) UpdateStatus(controller *api.ReplicationControl
}
}
// Delete deletes an existing replication controller.
// Delete deletes an existing replication controller.
func
(
c
*
replicationControllers
)
Delete
(
name
string
)
error
{
func
(
c
*
replicationControllers
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
return
c
.
r
.
Delete
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"replicationControllers"
)
.
Name
(
name
)
.
Do
()
.
Error
()
return
c
.
r
.
Delete
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"replicationControllers"
)
.
Name
(
name
)
.
Body
(
options
)
.
Do
()
.
Error
()
}
}
// Watch returns a watch.Interface that watches the requested controllers.
// Watch returns a watch.Interface that watches the requested controllers.
...
...
pkg/client/unversioned/replication_controllers_test.go
View file @
96c84303
...
@@ -165,7 +165,7 @@ func TestDeleteController(t *testing.T) {
...
@@ -165,7 +165,7 @@ func TestDeleteController(t *testing.T) {
Request
:
simple
.
Request
{
Method
:
"DELETE"
,
Path
:
testapi
.
Default
.
ResourcePath
(
getRCResourceName
(),
ns
,
"foo"
),
Query
:
simple
.
BuildQueryValues
(
nil
)},
Request
:
simple
.
Request
{
Method
:
"DELETE"
,
Path
:
testapi
.
Default
.
ResourcePath
(
getRCResourceName
(),
ns
,
"foo"
),
Query
:
simple
.
BuildQueryValues
(
nil
)},
Response
:
simple
.
Response
{
StatusCode
:
200
},
Response
:
simple
.
Response
{
StatusCode
:
200
},
}
}
err
:=
c
.
Setup
(
t
)
.
ReplicationControllers
(
ns
)
.
Delete
(
"foo"
)
err
:=
c
.
Setup
(
t
)
.
ReplicationControllers
(
ns
)
.
Delete
(
"foo"
,
nil
)
defer
c
.
Close
()
defer
c
.
Close
()
c
.
Validate
(
t
,
nil
,
err
)
c
.
Validate
(
t
,
nil
,
err
)
}
}
...
...
pkg/client/unversioned/testclient/fake_replication_controllers.go
View file @
96c84303
...
@@ -72,7 +72,7 @@ func (c *FakeReplicationControllers) UpdateStatus(controller *api.ReplicationCon
...
@@ -72,7 +72,7 @@ func (c *FakeReplicationControllers) UpdateStatus(controller *api.ReplicationCon
return
obj
.
(
*
api
.
ReplicationController
),
err
return
obj
.
(
*
api
.
ReplicationController
),
err
}
}
func
(
c
*
FakeReplicationControllers
)
Delete
(
name
string
)
error
{
func
(
c
*
FakeReplicationControllers
)
Delete
(
name
string
,
options
*
api
.
DeleteOptions
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"replicationcontrollers"
,
c
.
Namespace
,
name
),
&
api
.
ReplicationController
{})
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"replicationcontrollers"
,
c
.
Namespace
,
name
),
&
api
.
ReplicationController
{})
return
err
return
err
}
}
...
...
pkg/kubectl/rolling_updater.go
View file @
96c84303
...
@@ -513,11 +513,11 @@ func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *api.ReplicationControl
...
@@ -513,11 +513,11 @@ func (r *RollingUpdater) cleanupWithClients(oldRc, newRc *api.ReplicationControl
case
DeleteRollingUpdateCleanupPolicy
:
case
DeleteRollingUpdateCleanupPolicy
:
// delete old rc
// delete old rc
fmt
.
Fprintf
(
config
.
Out
,
"Update succeeded. Deleting %s
\n
"
,
oldRc
.
Name
)
fmt
.
Fprintf
(
config
.
Out
,
"Update succeeded. Deleting %s
\n
"
,
oldRc
.
Name
)
return
r
.
c
.
ReplicationControllers
(
r
.
ns
)
.
Delete
(
oldRc
.
Name
)
return
r
.
c
.
ReplicationControllers
(
r
.
ns
)
.
Delete
(
oldRc
.
Name
,
nil
)
case
RenameRollingUpdateCleanupPolicy
:
case
RenameRollingUpdateCleanupPolicy
:
// delete old rc
// delete old rc
fmt
.
Fprintf
(
config
.
Out
,
"Update succeeded. Deleting old controller: %s
\n
"
,
oldRc
.
Name
)
fmt
.
Fprintf
(
config
.
Out
,
"Update succeeded. Deleting old controller: %s
\n
"
,
oldRc
.
Name
)
if
err
:=
r
.
c
.
ReplicationControllers
(
r
.
ns
)
.
Delete
(
oldRc
.
Name
);
err
!=
nil
{
if
err
:=
r
.
c
.
ReplicationControllers
(
r
.
ns
)
.
Delete
(
oldRc
.
Name
,
nil
);
err
!=
nil
{
return
err
return
err
}
}
fmt
.
Fprintf
(
config
.
Out
,
"Renaming %s to %s
\n
"
,
newRc
.
Name
,
oldRc
.
Name
)
fmt
.
Fprintf
(
config
.
Out
,
"Renaming %s to %s
\n
"
,
newRc
.
Name
,
oldRc
.
Name
)
...
@@ -533,13 +533,28 @@ func Rename(c client.ReplicationControllersNamespacer, rc *api.ReplicationContro
...
@@ -533,13 +533,28 @@ func Rename(c client.ReplicationControllersNamespacer, rc *api.ReplicationContro
oldName
:=
rc
.
Name
oldName
:=
rc
.
Name
rc
.
Name
=
newName
rc
.
Name
=
newName
rc
.
ResourceVersion
=
""
rc
.
ResourceVersion
=
""
// First delete the oldName RC and orphan its pods.
_
,
err
:=
c
.
ReplicationControllers
(
rc
.
Namespace
)
.
Create
(
rc
)
trueVar
:=
true
err
:=
c
.
ReplicationControllers
(
rc
.
Namespace
)
.
Delete
(
oldName
,
&
api
.
DeleteOptions
{
OrphanDependents
:
&
trueVar
})
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
return
err
}
err
=
wait
.
Poll
(
5
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
_
,
err
:=
c
.
ReplicationControllers
(
rc
.
Namespace
)
.
Get
(
oldName
)
if
err
==
nil
{
return
false
,
nil
}
else
if
errors
.
IsNotFound
(
err
)
{
return
true
,
nil
}
else
{
return
false
,
err
}
})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
c
.
ReplicationControllers
(
rc
.
Namespace
)
.
Delete
(
oldName
)
// Then create the same RC with the new name.
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
_
,
err
=
c
.
ReplicationControllers
(
rc
.
Namespace
)
.
Create
(
rc
)
if
err
!=
nil
{
return
err
return
err
}
}
return
nil
return
nil
...
...
pkg/kubectl/rolling_updater_test.go
View file @
96c84303
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
apitesting
"k8s.io/kubernetes/pkg/api/testing"
apitesting
"k8s.io/kubernetes/pkg/api/testing"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
...
@@ -1143,20 +1144,27 @@ func TestRollingUpdater_cleanupWithClients(t *testing.T) {
...
@@ -1143,20 +1144,27 @@ func TestRollingUpdater_cleanupWithClients(t *testing.T) {
"delete"
,
"delete"
,
},
},
},
},
{
//{
name
:
"rename"
,
// This cases is separated to a standalone
policy
:
RenameRollingUpdateCleanupPolicy
,
// TestRollingUpdater_cleanupWithClients_Rename. We have to do this
responses
:
[]
runtime
.
Object
{
rcExisting
},
// because the unversioned fake client is unable to delete objects.
expected
:
[]
string
{
// TODO: uncomment this case when the unversioned fake client uses
"get"
,
// pkg/client/testing/core.
"update"
,
// {
"get"
,
// name: "rename",
"get"
,
// policy: RenameRollingUpdateCleanupPolicy,
"delete"
,
// responses: []runtime.Object{rcExisting},
"create"
,
// expected: []string{
"delete"
,
// "get",
},
// "update",
},
// "get",
// "get",
// "delete",
// "create",
// "delete",
// },
// },
//},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
@@ -1189,6 +1197,39 @@ func TestRollingUpdater_cleanupWithClients(t *testing.T) {
...
@@ -1189,6 +1197,39 @@ func TestRollingUpdater_cleanupWithClients(t *testing.T) {
}
}
}
}
// TestRollingUpdater_cleanupWithClients_Rename tests the rename cleanup policy. It's separated to
// a standalone test because the unversioned fake client is unable to delete
// objects.
// TODO: move this test back to TestRollingUpdater_cleanupWithClients
// when the fake client uses pkg/client/testing/core in the future.
func
TestRollingUpdater_cleanupWithClients_Rename
(
t
*
testing
.
T
)
{
rc
:=
oldRc
(
2
,
2
)
rcExisting
:=
newRc
(
1
,
3
)
expectedActions
:=
[]
string
{
"delete"
,
"get"
,
"create"
}
fake
:=
&
testclient
.
Fake
{}
fake
.
AddReactor
(
"*"
,
"*"
,
func
(
action
testclient
.
Action
)
(
handled
bool
,
ret
runtime
.
Object
,
err
error
)
{
switch
action
.
(
type
)
{
case
testclient
.
CreateAction
:
return
true
,
nil
,
nil
case
testclient
.
GetAction
:
return
true
,
nil
,
errors
.
NewNotFound
(
unversioned
.
GroupResource
{},
""
)
case
testclient
.
DeleteAction
:
return
true
,
nil
,
nil
}
return
false
,
nil
,
nil
})
err
:=
Rename
(
fake
,
rcExisting
,
rc
.
Name
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
for
j
,
action
:=
range
fake
.
Actions
()
{
if
e
,
a
:=
expectedActions
[
j
],
action
.
GetVerb
();
e
!=
a
{
t
.
Errorf
(
"unexpected action: expected %s, got %s"
,
e
,
a
)
}
}
}
func
TestFindSourceController
(
t
*
testing
.
T
)
{
func
TestFindSourceController
(
t
*
testing
.
T
)
{
ctrl1
:=
api
.
ReplicationController
{
ctrl1
:=
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
pkg/kubectl/stop.go
View file @
96c84303
...
@@ -202,7 +202,7 @@ func (reaper *ReplicationControllerReaper) Stop(namespace, name string, timeout
...
@@ -202,7 +202,7 @@ func (reaper *ReplicationControllerReaper) Stop(namespace, name string, timeout
return
err
return
err
}
}
}
}
return
rc
.
Delete
(
name
)
return
rc
.
Delete
(
name
,
nil
)
}
}
// TODO(madhusudancs): Implement it when controllerRef is implemented - https://github.com/kubernetes/kubernetes/issues/2210
// TODO(madhusudancs): Implement it when controllerRef is implemented - https://github.com/kubernetes/kubernetes/issues/2210
...
...
test/e2e/density.go
View file @
96c84303
...
@@ -628,7 +628,7 @@ var _ = framework.KubeDescribe("Density", func() {
...
@@ -628,7 +628,7 @@ var _ = framework.KubeDescribe("Density", func() {
By
(
"Removing additional replication controllers if any"
)
By
(
"Removing additional replication controllers if any"
)
for
i
:=
1
;
i
<=
nodeCount
;
i
++
{
for
i
:=
1
;
i
<=
nodeCount
;
i
++
{
name
:=
additionalPodsPrefix
+
"-"
+
strconv
.
Itoa
(
i
)
name
:=
additionalPodsPrefix
+
"-"
+
strconv
.
Itoa
(
i
)
c
.
ReplicationControllers
(
ns
)
.
Delete
(
name
)
c
.
ReplicationControllers
(
ns
)
.
Delete
(
name
,
nil
)
}
}
})
})
}
}
...
...
test/e2e/resource_quota.go
View file @
96c84303
...
@@ -258,7 +258,7 @@ var _ = framework.KubeDescribe("ResourceQuota", func() {
...
@@ -258,7 +258,7 @@ var _ = framework.KubeDescribe("ResourceQuota", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Deleting a ReplicationController"
)
By
(
"Deleting a ReplicationController"
)
err
=
f
.
Client
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Delete
(
replicationController
.
Name
)
err
=
f
.
Client
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Delete
(
replicationController
.
Name
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Ensuring resource quota status released usage"
)
By
(
"Ensuring resource quota status released usage"
)
...
...
test/e2e/service.go
View file @
96c84303
...
@@ -1970,7 +1970,7 @@ func (t *ServiceTestFixture) Cleanup() []error {
...
@@ -1970,7 +1970,7 @@ func (t *ServiceTestFixture) Cleanup() []error {
// TODO(mikedanese): Wait.
// TODO(mikedanese): Wait.
// Then, delete the RC altogether.
// Then, delete the RC altogether.
if
err
:=
t
.
Client
.
ReplicationControllers
(
t
.
Namespace
)
.
Delete
(
rcName
);
err
!=
nil
{
if
err
:=
t
.
Client
.
ReplicationControllers
(
t
.
Namespace
)
.
Delete
(
rcName
,
nil
);
err
!=
nil
{
errs
=
append
(
errs
,
err
)
errs
=
append
(
errs
,
err
)
}
}
}
}
...
...
test/e2e/serviceloadbalancers.go
View file @
96c84303
...
@@ -136,7 +136,7 @@ func (h *haproxyControllerTester) start(namespace string) (err error) {
...
@@ -136,7 +136,7 @@ func (h *haproxyControllerTester) start(namespace string) (err error) {
}
}
func
(
h
*
haproxyControllerTester
)
stop
()
error
{
func
(
h
*
haproxyControllerTester
)
stop
()
error
{
return
h
.
client
.
ReplicationControllers
(
h
.
rcNamespace
)
.
Delete
(
h
.
rcName
)
return
h
.
client
.
ReplicationControllers
(
h
.
rcNamespace
)
.
Delete
(
h
.
rcName
,
nil
)
}
}
func
(
h
*
haproxyControllerTester
)
lookup
(
ingressKey
string
)
string
{
func
(
h
*
haproxyControllerTester
)
lookup
(
ingressKey
string
)
string
{
...
...
test/integration/framework/master_utils.go
View file @
96c84303
...
@@ -351,7 +351,7 @@ func StartPods(namespace string, numPods int, host string, restClient *client.Cl
...
@@ -351,7 +351,7 @@ func StartPods(namespace string, numPods int, host string, restClient *client.Cl
}
else
{
}
else
{
// Delete the rc, otherwise when we restart master components for the next benchmark
// Delete the rc, otherwise when we restart master components for the next benchmark
// the rc controller will race with the pods controller in the rc manager.
// the rc controller will race with the pods controller in the rc manager.
return
restClient
.
ReplicationControllers
(
namespace
)
.
Delete
(
rc
.
Name
)
return
restClient
.
ReplicationControllers
(
namespace
)
.
Delete
(
rc
.
Name
,
nil
)
}
}
}
}
...
...
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