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
b28a83a4
Unverified
Commit
b28a83a4
authored
Aug 02, 2017
by
Mikhail Mazurskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to GetControllerOf from meta/v1 package
parent
54902739
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
77 additions
and
109 deletions
+77
-109
controller_ref_manager.go
pkg/controller/controller_ref_manager.go
+1
-14
BUILD
pkg/controller/cronjob/BUILD
+0
-2
cronjob_controller_test.go
pkg/controller/cronjob/cronjob_controller_test.go
+1
-2
utils.go
pkg/controller/cronjob/utils.go
+1
-2
daemon_controller.go
pkg/controller/daemon/daemon_controller.go
+9
-9
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+7
-7
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+3
-3
disruption.go
pkg/controller/disruption/disruption.go
+6
-6
BUILD
pkg/controller/history/BUILD
+0
-1
controller_history.go
pkg/controller/history/controller_history.go
+4
-5
controller_history_test.go
pkg/controller/history/controller_history_test.go
+5
-5
job_controller.go
pkg/controller/job/job_controller.go
+4
-4
replica_set.go
pkg/controller/replicaset/replica_set.go
+4
-4
replication_controller.go
pkg/controller/replication/replication_controller.go
+4
-4
stateful_set.go
pkg/controller/statefulset/stateful_set.go
+5
-5
stateful_set_utils_test.go
pkg/controller/statefulset/stateful_set_utils_test.go
+1
-2
BUILD
pkg/kubectl/BUILD
+0
-1
BUILD
pkg/kubectl/cmd/BUILD
+0
-1
drain.go
pkg/kubectl/cmd/drain.go
+1
-2
history.go
pkg/kubectl/history.go
+1
-2
BUILD
pkg/printers/internalversion/BUILD
+0
-1
describe.go
pkg/printers/internalversion/describe.go
+2
-3
printers.go
pkg/printers/internalversion/printers.go
+1
-2
BUILD
test/e2e/apimachinery/BUILD
+0
-1
garbage_collector.go
test/e2e/apimachinery/garbage_collector.go
+2
-3
daemon_set.go
test/e2e/apps/daemon_set.go
+6
-6
deployment.go
test/e2e/apps/deployment.go
+2
-3
job.go
test/e2e/apps/job.go
+2
-3
statefulset.go
test/e2e/apps/statefulset.go
+4
-5
util.go
test/e2e/framework/util.go
+1
-1
No files found.
pkg/controller/controller_ref_manager.go
View file @
b28a83a4
...
...
@@ -31,19 +31,6 @@ import (
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
)
// GetControllerOf returns the controllerRef if controllee has a controller,
// otherwise returns nil.
func
GetControllerOf
(
controllee
metav1
.
Object
)
*
metav1
.
OwnerReference
{
ownerRefs
:=
controllee
.
GetOwnerReferences
()
for
i
:=
range
ownerRefs
{
owner
:=
&
ownerRefs
[
i
]
if
owner
.
Controller
!=
nil
&&
*
owner
.
Controller
==
true
{
return
owner
}
}
return
nil
}
type
BaseControllerRefManager
struct
{
Controller
metav1
.
Object
Selector
labels
.
Selector
...
...
@@ -78,7 +65,7 @@ func (m *BaseControllerRefManager) CanAdopt() error {
//
// No reconciliation will be attempted if the controller is being deleted.
func
(
m
*
BaseControllerRefManager
)
ClaimObject
(
obj
metav1
.
Object
,
match
func
(
metav1
.
Object
)
bool
,
adopt
,
release
func
(
metav1
.
Object
)
error
)
(
bool
,
error
)
{
controllerRef
:=
GetControllerOf
(
obj
)
controllerRef
:=
metav1
.
GetControllerOf
(
obj
)
if
controllerRef
!=
nil
{
if
controllerRef
.
UID
!=
m
.
Controller
.
GetUID
()
{
// Owned by someone else. Ignore.
...
...
pkg/controller/cronjob/BUILD
View file @
b28a83a4
...
...
@@ -19,7 +19,6 @@ go_library(
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/util/metrics:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/robfig/cron:go_default_library",
...
...
@@ -54,7 +53,6 @@ go_test(
deps = [
"//pkg/api/install:go_default_library",
"//pkg/apis/batch/install:go_default_library",
"//pkg/controller:go_default_library",
"//vendor/k8s.io/api/batch/v1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
...
pkg/controller/cronjob/cronjob_controller_test.go
View file @
b28a83a4
...
...
@@ -32,7 +32,6 @@ import (
// For the cronjob controller to do conversions.
_
"k8s.io/kubernetes/pkg/api/install"
_
"k8s.io/kubernetes/pkg/apis/batch/install"
"k8s.io/kubernetes/pkg/controller"
)
// schedule is hourly on the hour
...
...
@@ -295,7 +294,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
}
for
i
:=
range
jc
.
Jobs
{
job
:=
&
jc
.
Jobs
[
i
]
controllerRef
:=
controller
.
GetControllerOf
(
job
)
controllerRef
:=
metav1
.
GetControllerOf
(
job
)
if
controllerRef
==
nil
{
t
.
Errorf
(
"%s: expected job to have ControllerRef: %#v"
,
name
,
job
)
}
else
{
...
...
pkg/controller/cronjob/utils.go
View file @
b28a83a4
...
...
@@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/types"
ref
"k8s.io/client-go/tools/reference"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/controller"
)
// Utilities for dealing with Jobs and CronJobs and time.
...
...
@@ -61,7 +60,7 @@ func deleteFromActiveList(sj *batchv2alpha1.CronJob, uid types.UID) {
// getParentUIDFromJob extracts UID of job's parent and whether it was found
func
getParentUIDFromJob
(
j
batchv1
.
Job
)
(
types
.
UID
,
bool
)
{
controllerRef
:=
controller
.
GetControllerOf
(
&
j
)
controllerRef
:=
metav1
.
GetControllerOf
(
&
j
)
if
controllerRef
==
nil
{
return
types
.
UID
(
""
),
false
...
...
pkg/controller/daemon/daemon_controller.go
View file @
b28a83a4
...
...
@@ -320,7 +320,7 @@ func (dsc *DaemonSetsController) addHistory(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
history
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
history
);
controllerRef
!=
nil
{
ds
:=
dsc
.
resolveControllerRef
(
history
.
Namespace
,
controllerRef
)
if
ds
==
nil
{
return
...
...
@@ -352,8 +352,8 @@ func (dsc *DaemonSetsController) updateHistory(old, cur interface{}) {
return
}
curControllerRef
:=
controller
.
GetControllerOf
(
curHistory
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldHistory
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curHistory
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldHistory
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -411,7 +411,7 @@ func (dsc *DaemonSetsController) deleteHistory(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
history
)
controllerRef
:=
metav1
.
GetControllerOf
(
history
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
@@ -435,7 +435,7 @@ func (dsc *DaemonSetsController) addPod(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
ds
:=
dsc
.
resolveControllerRef
(
pod
.
Namespace
,
controllerRef
)
if
ds
==
nil
{
return
...
...
@@ -478,8 +478,8 @@ func (dsc *DaemonSetsController) updatePod(old, cur interface{}) {
changedToReady
:=
!
podutil
.
IsPodReady
(
oldPod
)
&&
podutil
.
IsPodReady
(
curPod
)
labelChanged
:=
!
reflect
.
DeepEqual
(
curPod
.
Labels
,
oldPod
.
Labels
)
curControllerRef
:=
controller
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldPod
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldPod
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -539,7 +539,7 @@ func (dsc *DaemonSetsController) deletePod(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
@@ -1068,7 +1068,7 @@ func (dsc *DaemonSetsController) simulate(newPod *v1.Pod, node *v1.Node, ds *ext
}
// ignore pods that belong to the daemonset when taking into account whether
// a daemonset should bind to a node.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
&&
controllerRef
.
UID
==
ds
.
UID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
&&
controllerRef
.
UID
==
ds
.
UID
{
continue
}
pods
=
append
(
pods
,
pod
)
...
...
pkg/controller/deployment/deployment_controller.go
View file @
b28a83a4
...
...
@@ -205,7 +205,7 @@ func (dc *DeploymentController) addReplicaSet(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
rs
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
rs
);
controllerRef
!=
nil
{
d
:=
dc
.
resolveControllerRef
(
rs
.
Namespace
,
controllerRef
)
if
d
==
nil
{
return
...
...
@@ -260,8 +260,8 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
return
}
curControllerRef
:=
controller
.
GetControllerOf
(
curRS
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldRS
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curRS
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldRS
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -319,7 +319,7 @@ func (dc *DeploymentController) deleteReplicaSet(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
rs
)
controllerRef
:=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
@@ -409,7 +409,7 @@ func (dc *DeploymentController) getDeploymentForPod(pod *v1.Pod) *extensions.Dep
// Find the owning replica set
var
rs
*
extensions
.
ReplicaSet
var
err
error
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller owns this Pod.
return
nil
...
...
@@ -425,7 +425,7 @@ func (dc *DeploymentController) getDeploymentForPod(pod *v1.Pod) *extensions.Dep
}
// Now find the Deployment that owns that ReplicaSet.
controllerRef
=
controller
.
GetControllerOf
(
rs
)
controllerRef
=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
==
nil
{
return
nil
}
...
...
@@ -542,7 +542,7 @@ func (dc *DeploymentController) getPodMapForDeployment(d *extensions.Deployment,
for
_
,
pod
:=
range
pods
{
// Do not ignore inactive Pods because Recreate Deployments need to verify that no
// Pods from older versions are running before spinning up new Pods.
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
continue
}
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
b28a83a4
...
...
@@ -579,7 +579,7 @@ func ListReplicaSets(deployment *extensions.Deployment, getRSList RsListFunc) ([
// Only include those whose ControllerRef matches the Deployment.
owned
:=
make
([]
*
extensions
.
ReplicaSet
,
0
,
len
(
all
))
for
_
,
rs
:=
range
all
{
controllerRef
:=
controller
.
GetControllerOf
(
rs
)
controllerRef
:=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
!=
nil
&&
controllerRef
.
UID
==
deployment
.
UID
{
owned
=
append
(
owned
,
rs
)
}
...
...
@@ -603,7 +603,7 @@ func ListReplicaSetsInternal(deployment *internalextensions.Deployment, getRSLis
// Only include those whose ControllerRef matches the Deployment.
filtered
:=
make
([]
*
internalextensions
.
ReplicaSet
,
0
,
len
(
all
))
for
_
,
rs
:=
range
all
{
controllerRef
:=
controller
.
GetControllerOf
(
rs
)
controllerRef
:=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
!=
nil
&&
controllerRef
.
UID
==
deployment
.
UID
{
filtered
=
append
(
filtered
,
rs
)
}
...
...
@@ -637,7 +637,7 @@ func ListPods(deployment *extensions.Deployment, rsList []*extensions.ReplicaSet
owned
:=
&
v1
.
PodList
{
Items
:
make
([]
v1
.
Pod
,
0
,
len
(
all
.
Items
))}
for
i
:=
range
all
.
Items
{
pod
:=
&
all
.
Items
[
i
]
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
!=
nil
&&
rsMap
[
controllerRef
.
UID
]
{
owned
.
Items
=
append
(
owned
.
Items
,
*
pod
)
}
...
...
pkg/controller/disruption/disruption.go
View file @
b28a83a4
...
...
@@ -184,7 +184,7 @@ var (
// getPodReplicaSets finds replicasets which have no matching deployments.
func
(
dc
*
DisruptionController
)
getPodReplicaSets
(
pod
*
v1
.
Pod
)
([]
controllerAndScale
,
error
)
{
var
casSlice
[]
controllerAndScale
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
@@ -199,7 +199,7 @@ func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndS
if
rs
.
UID
!=
controllerRef
.
UID
{
return
nil
,
nil
}
controllerRef
=
controller
.
GetControllerOf
(
rs
)
controllerRef
=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
!=
nil
&&
controllerRef
.
Kind
==
controllerKindDep
.
Kind
{
// Skip RS if it's controlled by a Deployment.
return
nil
,
nil
...
...
@@ -211,7 +211,7 @@ func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndS
// getPodStatefulSet returns the statefulset managing the given pod.
func
(
dc
*
DisruptionController
)
getPodStatefulSets
(
pod
*
v1
.
Pod
)
([]
controllerAndScale
,
error
)
{
var
casSlice
[]
controllerAndScale
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
@@ -234,7 +234,7 @@ func (dc *DisruptionController) getPodStatefulSets(pod *v1.Pod) ([]controllerAnd
// getPodDeployments finds deployments for any replicasets which are being managed by deployments.
func
(
dc
*
DisruptionController
)
getPodDeployments
(
pod
*
v1
.
Pod
)
([]
controllerAndScale
,
error
)
{
var
casSlice
[]
controllerAndScale
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
@@ -249,7 +249,7 @@ func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndS
if
rs
.
UID
!=
controllerRef
.
UID
{
return
nil
,
nil
}
controllerRef
=
controller
.
GetControllerOf
(
rs
)
controllerRef
=
metav1
.
GetControllerOf
(
rs
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
@@ -270,7 +270,7 @@ func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndS
func
(
dc
*
DisruptionController
)
getPodReplicationControllers
(
pod
*
v1
.
Pod
)
([]
controllerAndScale
,
error
)
{
var
casSlice
[]
controllerAndScale
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
pkg/controller/history/BUILD
View file @
b28a83a4
...
...
@@ -37,7 +37,6 @@ go_library(
tags = ["automanaged"],
deps = [
"//pkg/client/retry:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/util/hash:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
...
...
pkg/controller/history/controller_history.go
View file @
b28a83a4
...
...
@@ -27,7 +27,6 @@ import (
appsinformers
"k8s.io/client-go/informers/apps/v1beta1"
clientset
"k8s.io/client-go/kubernetes"
appslisters
"k8s.io/client-go/listers/apps/v1beta1"
"k8s.io/kubernetes/pkg/controller"
hashutil
"k8s.io/kubernetes/pkg/util/hash"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
...
...
@@ -225,7 +224,7 @@ func (rh *realHistory) ListControllerRevisions(parent metav1.Object, selector la
}
var
owned
[]
*
apps
.
ControllerRevision
for
i
:=
range
history
{
ref
:=
controller
.
GetControllerOf
(
history
[
i
])
ref
:=
metav1
.
GetControllerOf
(
history
[
i
])
if
ref
==
nil
||
ref
.
UID
==
parent
.
GetUID
()
{
owned
=
append
(
owned
,
history
[
i
])
}
...
...
@@ -302,7 +301,7 @@ func (rh *realHistory) DeleteControllerRevision(revision *apps.ControllerRevisio
func
(
rh
*
realHistory
)
AdoptControllerRevision
(
parent
metav1
.
Object
,
parentKind
schema
.
GroupVersionKind
,
revision
*
apps
.
ControllerRevision
)
(
*
apps
.
ControllerRevision
,
error
)
{
// Return an error if the parent does not own the revision
if
owner
:=
controller
.
GetControllerOf
(
revision
);
owner
!=
nil
{
if
owner
:=
metav1
.
GetControllerOf
(
revision
);
owner
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"attempt to adopt revision owned by %v"
,
owner
)
}
// Use strategic merge patch to add an owner reference indicating a controller ref
...
...
@@ -346,7 +345,7 @@ func (fh *fakeHistory) ListControllerRevisions(parent metav1.Object, selector la
var
owned
[]
*
apps
.
ControllerRevision
for
i
:=
range
history
{
ref
:=
controller
.
GetControllerOf
(
history
[
i
])
ref
:=
metav1
.
GetControllerOf
(
history
[
i
])
if
ref
==
nil
||
ref
.
UID
==
parent
.
GetUID
()
{
owned
=
append
(
owned
,
history
[
i
])
}
...
...
@@ -431,7 +430,7 @@ func (fh *fakeHistory) UpdateControllerRevision(revision *apps.ControllerRevisio
func
(
fh
*
fakeHistory
)
AdoptControllerRevision
(
parent
metav1
.
Object
,
parentKind
schema
.
GroupVersionKind
,
revision
*
apps
.
ControllerRevision
)
(
*
apps
.
ControllerRevision
,
error
)
{
blockOwnerDeletion
:=
true
isController
:=
true
if
owner
:=
controller
.
GetControllerOf
(
revision
);
owner
!=
nil
{
if
owner
:=
metav1
.
GetControllerOf
(
revision
);
owner
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"attempt to adopt revision owned by %v"
,
owner
)
}
key
,
err
:=
cache
.
DeletionHandlingMetaNamespaceKeyFunc
(
revision
)
...
...
pkg/controller/history/controller_history_test.go
View file @
b28a83a4
...
...
@@ -992,7 +992,7 @@ func TestRealHistory_AdoptControllerRevision(t *testing.T) {
if
!
test
.
err
&&
err
!=
nil
{
t
.
Errorf
(
"%s: %s"
,
test
.
name
,
err
)
}
if
!
test
.
err
&&
controller
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
()
{
if
!
test
.
err
&&
metav1
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
()
{
t
.
Errorf
(
"%s: adoption failed"
,
test
.
name
)
}
if
test
.
err
&&
err
==
nil
{
...
...
@@ -1103,7 +1103,7 @@ func TestFakeHistory_AdoptControllerRevision(t *testing.T) {
if
!
test
.
err
&&
err
!=
nil
{
t
.
Errorf
(
"%s: %s"
,
test
.
name
,
err
)
}
if
!
test
.
err
&&
controller
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
()
{
if
!
test
.
err
&&
metav1
.
GetControllerOf
(
adopted
)
.
UID
!=
test
.
parent
.
GetUID
()
{
t
.
Errorf
(
"%s: adoption failed"
,
test
.
name
)
}
if
test
.
err
&&
err
==
nil
{
...
...
@@ -1211,7 +1211,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if
found
==
nil
{
return
true
,
nil
,
errors
.
NewNotFound
(
apps
.
Resource
(
"controllerrevisions"
),
test
.
revision
.
Name
)
}
if
foundParent
:=
controller
.
GetControllerOf
(
test
.
revision
);
foundParent
==
nil
||
if
foundParent
:=
metav1
.
GetControllerOf
(
test
.
revision
);
foundParent
==
nil
||
foundParent
.
UID
!=
test
.
parent
.
GetUID
()
{
return
true
,
nil
,
errors
.
NewInvalid
(
test
.
revision
.
GroupVersionKind
()
.
GroupKind
(),
test
.
revision
.
Name
,
nil
)
...
...
@@ -1258,7 +1258,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if
adopted
==
nil
{
return
}
if
owner
:=
controller
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
()
{
if
owner
:=
metav1
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
()
{
t
.
Errorf
(
"%s: release failed"
,
test
.
name
)
}
}
...
...
@@ -1386,7 +1386,7 @@ func TestFakeHistory_ReleaseControllerRevision(t *testing.T) {
if
adopted
==
nil
{
return
}
if
owner
:=
controller
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
()
{
if
owner
:=
metav1
.
GetControllerOf
(
adopted
);
owner
!=
nil
&&
owner
.
UID
==
test
.
parent
.
GetUID
()
{
t
.
Errorf
(
"%s: release failed"
,
test
.
name
)
}
}
...
...
pkg/controller/job/job_controller.go
View file @
b28a83a4
...
...
@@ -193,7 +193,7 @@ func (jm *JobController) addPod(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
job
:=
jm
.
resolveControllerRef
(
pod
.
Namespace
,
controllerRef
)
if
job
==
nil
{
return
...
...
@@ -238,8 +238,8 @@ func (jm *JobController) updatePod(old, cur interface{}) {
labelChanged
:=
!
reflect
.
DeepEqual
(
curPod
.
Labels
,
oldPod
.
Labels
)
curControllerRef
:=
controller
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldPod
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldPod
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -289,7 +289,7 @@ func (jm *JobController) deletePod(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
pkg/controller/replicaset/replica_set.go
View file @
b28a83a4
...
...
@@ -236,7 +236,7 @@ func (rsc *ReplicaSetController) addPod(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
rs
:=
rsc
.
resolveControllerRef
(
pod
.
Namespace
,
controllerRef
)
if
rs
==
nil
{
return
...
...
@@ -292,8 +292,8 @@ func (rsc *ReplicaSetController) updatePod(old, cur interface{}) {
return
}
curControllerRef
:=
controller
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldPod
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldPod
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -362,7 +362,7 @@ func (rsc *ReplicaSetController) deletePod(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
pkg/controller/replication/replication_controller.go
View file @
b28a83a4
...
...
@@ -231,7 +231,7 @@ func (rm *ReplicationManager) addPod(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
rc
:=
rm
.
resolveControllerRef
(
pod
.
Namespace
,
controllerRef
)
if
rc
==
nil
{
return
...
...
@@ -287,8 +287,8 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
return
}
curControllerRef
:=
controller
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldPod
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldPod
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -357,7 +357,7 @@ func (rm *ReplicationManager) deletePod(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
pkg/controller/statefulset/stateful_set.go
View file @
b28a83a4
...
...
@@ -170,7 +170,7 @@ func (ssc *StatefulSetController) addPod(obj interface{}) {
}
// If it has a ControllerRef, that's all that matters.
if
controllerRef
:=
controller
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
pod
);
controllerRef
!=
nil
{
set
:=
ssc
.
resolveControllerRef
(
pod
.
Namespace
,
controllerRef
)
if
set
==
nil
{
return
...
...
@@ -204,8 +204,8 @@ func (ssc *StatefulSetController) updatePod(old, cur interface{}) {
labelChanged
:=
!
reflect
.
DeepEqual
(
curPod
.
Labels
,
oldPod
.
Labels
)
curControllerRef
:=
controller
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
controller
.
GetControllerOf
(
oldPod
)
curControllerRef
:=
metav1
.
GetControllerOf
(
curPod
)
oldControllerRef
:=
metav1
.
GetControllerOf
(
oldPod
)
controllerRefChanged
:=
!
reflect
.
DeepEqual
(
curControllerRef
,
oldControllerRef
)
if
controllerRefChanged
&&
oldControllerRef
!=
nil
{
// The ControllerRef was changed. Sync the old controller, if any.
...
...
@@ -260,7 +260,7 @@ func (ssc *StatefulSetController) deletePod(obj interface{}) {
}
}
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
// No controller should care about orphans being deleted.
return
...
...
@@ -316,7 +316,7 @@ func (ssc *StatefulSetController) adoptOrphanRevisions(set *apps.StatefulSet) er
}
hasOrphans
:=
false
for
i
:=
range
revisions
{
if
controller
.
GetControllerOf
(
revisions
[
i
])
==
nil
{
if
metav1
.
GetControllerOf
(
revisions
[
i
])
==
nil
{
hasOrphans
=
true
break
}
...
...
pkg/controller/statefulset/stateful_set_utils_test.go
View file @
b28a83a4
...
...
@@ -31,7 +31,6 @@ import (
apps
"k8s.io/api/apps/v1beta1"
"k8s.io/api/core/v1"
podutil
"k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/history"
)
...
...
@@ -252,7 +251,7 @@ func TestOverlappingStatefulSets(t *testing.T) {
func
TestNewPodControllerRef
(
t
*
testing
.
T
)
{
set
:=
newStatefulSet
(
1
)
pod
:=
newStatefulSetPod
(
set
,
0
)
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
t
.
Fatalf
(
"No ControllerRef found on new pod"
)
}
...
...
pkg/kubectl/BUILD
View file @
b28a83a4
...
...
@@ -135,7 +135,6 @@ go_library(
"//pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion:go_default_library",
"//pkg/client/retry:go_default_library",
"//pkg/client/unversioned:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/daemon:go_default_library",
"//pkg/controller/deployment/util:go_default_library",
"//pkg/credentialprovider:go_default_library",
...
...
pkg/kubectl/cmd/BUILD
View file @
b28a83a4
...
...
@@ -79,7 +79,6 @@ go_library(
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion:go_default_library",
"//pkg/client/unversioned:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/kubectl:go_default_library",
"//pkg/kubectl/cmd/auth:go_default_library",
"//pkg/kubectl/cmd/config:go_default_library",
...
...
pkg/kubectl/cmd/drain.go
View file @
b28a83a4
...
...
@@ -42,7 +42,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
...
...
@@ -286,7 +285,7 @@ func (o *DrainOptions) getController(namespace string, controllerRef *metav1.Own
}
func
(
o
*
DrainOptions
)
getPodController
(
pod
api
.
Pod
)
(
*
metav1
.
OwnerReference
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
)
if
controllerRef
==
nil
{
return
nil
,
nil
}
...
...
pkg/kubectl/history.go
View file @
b28a83a4
...
...
@@ -37,7 +37,6 @@ import (
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
sliceutil
"k8s.io/kubernetes/pkg/kubectl/util/slice"
printersinternal
"k8s.io/kubernetes/pkg/printers/internalversion"
...
...
@@ -273,7 +272,7 @@ func controlledHistories(c externalclientset.Interface, namespace, name string)
for
i
:=
range
historyList
.
Items
{
history
:=
historyList
.
Items
[
i
]
// Skip history that doesn't belong to the DaemonSet
if
controllerRef
:=
controller
.
GetControllerOf
(
&
history
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
history
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
continue
}
result
=
append
(
result
,
&
history
)
...
...
pkg/printers/internalversion/BUILD
View file @
b28a83a4
...
...
@@ -81,7 +81,6 @@ go_library(
"//pkg/apis/storage/util:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/deployment/util:go_default_library",
"//pkg/fieldpath:go_default_library",
"//pkg/printers:go_default_library",
...
...
pkg/printers/internalversion/describe.go
View file @
b28a83a4
...
...
@@ -70,7 +70,6 @@ import (
storageutil
"k8s.io/kubernetes/pkg/apis/storage/util"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
coreclient
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/controller"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/fieldpath"
"k8s.io/kubernetes/pkg/printers"
...
...
@@ -675,7 +674,7 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
}
func
printController
(
controllee
metav1
.
Object
)
string
{
if
controllerRef
:=
controller
.
GetControllerOf
(
controllee
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
controllee
);
controllerRef
!=
nil
{
return
fmt
.
Sprintf
(
"%s/%s"
,
controllerRef
.
Kind
,
controllerRef
.
Name
)
}
return
""
...
...
@@ -2923,7 +2922,7 @@ func getPodStatusForController(c coreclient.PodInterface, selector labels.Select
return
}
for
_
,
pod
:=
range
rcPods
.
Items
{
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
)
// Skip pods that are orphans or owned by other controllers.
if
controllerRef
==
nil
||
controllerRef
.
UID
!=
uid
{
continue
...
...
pkg/printers/internalversion/printers.go
View file @
b28a83a4
...
...
@@ -55,7 +55,6 @@ import (
"k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/apis/storage"
storageutil
"k8s.io/kubernetes/pkg/apis/storage/util"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/printers"
"k8s.io/kubernetes/pkg/util/node"
)
...
...
@@ -1770,7 +1769,7 @@ func printControllerRevision(obj *apps.ControllerRevision, options printers.Prin
Object
:
runtime
.
RawExtension
{
Object
:
obj
},
}
controllerRef
:=
controller
.
GetControllerOf
(
obj
)
controllerRef
:=
metav1
.
GetControllerOf
(
obj
)
controllerName
:=
"<none>"
if
controllerRef
!=
nil
{
withKind
:=
true
...
...
test/e2e/apimachinery/BUILD
View file @
b28a83a4
...
...
@@ -23,7 +23,6 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/api/v1/pod:go_default_library",
"//pkg/client/retry:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/printers:go_default_library",
"//pkg/util/version:go_default_library",
"//test/e2e/apps:go_default_library",
...
...
test/e2e/apimachinery/garbage_collector.go
View file @
b28a83a4
...
...
@@ -21,7 +21,7 @@ import (
"time"
"k8s.io/api/core/v1"
v1beta1
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/extensions/v1beta1"
apiextensionsv1beta1
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
apiextensionsclientset
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apiextensionstestserver
"k8s.io/apiextensions-apiserver/test/integration/testserver"
...
...
@@ -33,7 +33,6 @@ import (
"k8s.io/apiserver/pkg/storage/names"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/metrics"
...
...
@@ -498,7 +497,7 @@ var _ = SIGDescribe("Garbage collector", func() {
framework
.
Failf
(
"Failed to list ReplicaSet %v"
,
err
)
}
for
_
,
replicaSet
:=
range
rs
.
Items
{
if
controller
.
GetControllerOf
(
&
replicaSet
.
ObjectMeta
)
!=
nil
{
if
metav1
.
GetControllerOf
(
&
replicaSet
.
ObjectMeta
)
!=
nil
{
framework
.
Failf
(
"Found ReplicaSet with non nil ownerRef %v"
,
replicaSet
)
}
}
...
...
test/e2e/apps/daemon_set.go
View file @
b28a83a4
...
...
@@ -630,7 +630,7 @@ func checkDaemonPodOnNodes(f *framework.Framework, ds *extensions.DaemonSet, nod
nodesToPodCount
:=
make
(
map
[
string
]
int
)
for
_
,
pod
:=
range
pods
{
if
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
continue
}
if
pod
.
DeletionTimestamp
!=
nil
{
...
...
@@ -726,7 +726,7 @@ func checkDaemonPodsImageAndAvailability(c clientset.Interface, ds *extensions.D
unavailablePods
:=
0
allImagesUpdated
:=
true
for
_
,
pod
:=
range
pods
{
if
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
ds
.
UID
{
continue
}
podImage
:=
pod
.
Spec
.
Containers
[
0
]
.
Image
...
...
@@ -779,7 +779,7 @@ func checkDaemonSetPodsOrphaned(c clientset.Interface, ns string, label map[stri
pods
:=
listDaemonPods
(
c
,
ns
,
label
)
for
_
,
pod
:=
range
pods
.
Items
{
// This pod is orphaned only when controller ref is cleared
if
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
!=
nil
{
return
false
,
nil
}
}
...
...
@@ -792,7 +792,7 @@ func checkDaemonSetHistoryOrphaned(c clientset.Interface, ns string, label map[s
histories
:=
listDaemonHistories
(
c
,
ns
,
label
)
for
_
,
history
:=
range
histories
.
Items
{
// This history is orphaned only when controller ref is cleared
if
controllerRef
:=
controller
.
GetControllerOf
(
&
history
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
history
);
controllerRef
!=
nil
{
return
false
,
nil
}
}
...
...
@@ -805,7 +805,7 @@ func checkDaemonSetPodsAdopted(c clientset.Interface, ns string, dsUID types.UID
pods
:=
listDaemonPods
(
c
,
ns
,
label
)
for
_
,
pod
:=
range
pods
.
Items
{
// This pod is adopted only when its controller ref is update
if
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
dsUID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
dsUID
{
return
false
,
nil
}
}
...
...
@@ -818,7 +818,7 @@ func checkDaemonSetHistoryAdopted(c clientset.Interface, ns string, dsUID types.
histories
:=
listDaemonHistories
(
c
,
ns
,
label
)
for
_
,
history
:=
range
histories
.
Items
{
// This history is adopted only when its controller ref is update
if
controllerRef
:=
controller
.
GetControllerOf
(
&
history
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
dsUID
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
history
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
dsUID
{
return
false
,
nil
}
}
...
...
test/e2e/apps/deployment.go
View file @
b28a83a4
...
...
@@ -38,7 +38,6 @@ import (
extensionsclient
"k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
extensionsinternal
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/kubectl"
utilpointer
"k8s.io/kubernetes/pkg/util/pointer"
...
...
@@ -1380,7 +1379,7 @@ func checkDeploymentReplicaSetsControllerRef(c clientset.Interface, ns string, u
rsList
:=
listDeploymentReplicaSets
(
c
,
ns
,
label
)
for
_
,
rs
:=
range
rsList
.
Items
{
// This rs is adopted only when its controller ref is update
if
controllerRef
:=
controller
.
GetControllerOf
(
&
rs
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
uid
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
rs
);
controllerRef
==
nil
||
controllerRef
.
UID
!=
uid
{
return
fmt
.
Errorf
(
"ReplicaSet %s has unexpected controllerRef %v"
,
rs
.
Name
,
controllerRef
)
}
}
...
...
@@ -1392,7 +1391,7 @@ func waitDeploymentReplicaSetsOrphaned(c clientset.Interface, ns string, label m
rsList
:=
listDeploymentReplicaSets
(
c
,
ns
,
label
)
for
_
,
rs
:=
range
rsList
.
Items
{
// This rs is orphaned only when controller ref is cleared
if
controllerRef
:=
controller
.
GetControllerOf
(
&
rs
);
controllerRef
!=
nil
{
if
controllerRef
:=
metav1
.
GetControllerOf
(
&
rs
);
controllerRef
!=
nil
{
return
false
,
nil
}
}
...
...
test/e2e/apps/job.go
View file @
b28a83a4
...
...
@@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
batchinternal
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/test/e2e/framework"
...
...
@@ -135,7 +134,7 @@ var _ = SIGDescribe("Job", func() {
By
(
"Checking that the Job readopts the Pod"
)
Expect
(
framework
.
WaitForPodCondition
(
f
.
ClientSet
,
pod
.
Namespace
,
pod
.
Name
,
"adopted"
,
framework
.
JobTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
false
,
nil
}
...
...
@@ -154,7 +153,7 @@ var _ = SIGDescribe("Job", func() {
By
(
"Checking that the Job releases the Pod"
)
Expect
(
framework
.
WaitForPodCondition
(
f
.
ClientSet
,
pod
.
Namespace
,
pod
.
Name
,
"released"
,
framework
.
JobTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
!=
nil
{
return
false
,
nil
}
...
...
test/e2e/apps/statefulset.go
View file @
b28a83a4
...
...
@@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/test/e2e/framework"
)
...
...
@@ -145,7 +144,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Checking that stateful set pods are created with ControllerRef"
)
pod
:=
pods
.
Items
[
0
]
controllerRef
:=
controller
.
GetControllerOf
(
&
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
&
pod
)
Expect
(
controllerRef
)
.
ToNot
(
BeNil
())
Expect
(
controllerRef
.
Kind
)
.
To
(
Equal
(
ss
.
Kind
))
Expect
(
controllerRef
.
Name
)
.
To
(
Equal
(
ss
.
Name
))
...
...
@@ -159,7 +158,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Checking that the stateful set readopts the pod"
)
Expect
(
framework
.
WaitForPodCondition
(
c
,
pod
.
Namespace
,
pod
.
Name
,
"adopted"
,
framework
.
StatefulSetTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
false
,
nil
}
...
...
@@ -179,7 +178,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Checking that the stateful set releases the pod"
)
Expect
(
framework
.
WaitForPodCondition
(
c
,
pod
.
Namespace
,
pod
.
Name
,
"released"
,
framework
.
StatefulSetTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
!=
nil
{
return
false
,
nil
}
...
...
@@ -196,7 +195,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By
(
"Checking that the stateful set readopts the pod"
)
Expect
(
framework
.
WaitForPodCondition
(
c
,
pod
.
Namespace
,
pod
.
Name
,
"adopted"
,
framework
.
StatefulSetTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
controllerRef
:=
controller
.
GetControllerOf
(
pod
)
controllerRef
:=
metav1
.
GetControllerOf
(
pod
)
if
controllerRef
==
nil
{
return
false
,
nil
}
...
...
test/e2e/framework/util.go
View file @
b28a83a4
...
...
@@ -653,7 +653,7 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN
notReady
++
badPods
=
append
(
badPods
,
pod
)
default
:
if
controller
.
GetControllerOf
(
&
pod
)
==
nil
{
if
metav1
.
GetControllerOf
(
&
pod
)
==
nil
{
Logf
(
"Pod %s is Failed, but it's not controlled by a controller"
,
pod
.
ObjectMeta
.
Name
)
badPods
=
append
(
badPods
,
pod
)
}
...
...
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