Migrate to GetControllerOf from meta/v1 package

pull/6/head
Mikhail Mazurskiy 2017-08-02 19:41:33 +10:00
parent 5490273951
commit b28a83a4cf
No known key found for this signature in database
GPG Key ID: 93551ECC96E2F568
30 changed files with 77 additions and 109 deletions

View File

@ -31,19 +31,6 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors" 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 { type BaseControllerRefManager struct {
Controller metav1.Object Controller metav1.Object
Selector labels.Selector Selector labels.Selector
@ -78,7 +65,7 @@ func (m *BaseControllerRefManager) CanAdopt() error {
// //
// No reconciliation will be attempted if the controller is being deleted. // 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) { 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 != nil {
if controllerRef.UID != m.Controller.GetUID() { if controllerRef.UID != m.Controller.GetUID() {
// Owned by someone else. Ignore. // Owned by someone else. Ignore.

View File

@ -19,7 +19,6 @@ go_library(
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/util/metrics:go_default_library", "//pkg/util/metrics:go_default_library",
"//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/robfig/cron:go_default_library", "//vendor/github.com/robfig/cron:go_default_library",
@ -54,7 +53,6 @@ go_test(
deps = [ deps = [
"//pkg/api/install:go_default_library", "//pkg/api/install:go_default_library",
"//pkg/apis/batch/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/v1:go_default_library",
"//vendor/k8s.io/api/batch/v2alpha1:go_default_library", "//vendor/k8s.io/api/batch/v2alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library",

View File

@ -32,7 +32,6 @@ import (
// For the cronjob controller to do conversions. // For the cronjob controller to do conversions.
_ "k8s.io/kubernetes/pkg/api/install" _ "k8s.io/kubernetes/pkg/api/install"
_ "k8s.io/kubernetes/pkg/apis/batch/install" _ "k8s.io/kubernetes/pkg/apis/batch/install"
"k8s.io/kubernetes/pkg/controller"
) )
// schedule is hourly on the hour // schedule is hourly on the hour
@ -295,7 +294,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
} }
for i := range jc.Jobs { for i := range jc.Jobs {
job := &jc.Jobs[i] job := &jc.Jobs[i]
controllerRef := controller.GetControllerOf(job) controllerRef := metav1.GetControllerOf(job)
if controllerRef == nil { if controllerRef == nil {
t.Errorf("%s: expected job to have ControllerRef: %#v", name, job) t.Errorf("%s: expected job to have ControllerRef: %#v", name, job)
} else { } else {

View File

@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
ref "k8s.io/client-go/tools/reference" ref "k8s.io/client-go/tools/reference"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/controller"
) )
// Utilities for dealing with Jobs and CronJobs and time. // 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 // getParentUIDFromJob extracts UID of job's parent and whether it was found
func getParentUIDFromJob(j batchv1.Job) (types.UID, bool) { func getParentUIDFromJob(j batchv1.Job) (types.UID, bool) {
controllerRef := controller.GetControllerOf(&j) controllerRef := metav1.GetControllerOf(&j)
if controllerRef == nil { if controllerRef == nil {
return types.UID(""), false return types.UID(""), false

View File

@ -320,7 +320,7 @@ func (dsc *DaemonSetsController) addHistory(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) ds := dsc.resolveControllerRef(history.Namespace, controllerRef)
if ds == nil { if ds == nil {
return return
@ -352,8 +352,8 @@ func (dsc *DaemonSetsController) updateHistory(old, cur interface{}) {
return return
} }
curControllerRef := controller.GetControllerOf(curHistory) curControllerRef := metav1.GetControllerOf(curHistory)
oldControllerRef := controller.GetControllerOf(oldHistory) oldControllerRef := metav1.GetControllerOf(oldHistory)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return
@ -435,7 +435,7 @@ func (dsc *DaemonSetsController) addPod(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) ds := dsc.resolveControllerRef(pod.Namespace, controllerRef)
if ds == nil { if ds == nil {
return return
@ -478,8 +478,8 @@ func (dsc *DaemonSetsController) updatePod(old, cur interface{}) {
changedToReady := !podutil.IsPodReady(oldPod) && podutil.IsPodReady(curPod) changedToReady := !podutil.IsPodReady(oldPod) && podutil.IsPodReady(curPod)
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels) labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
curControllerRef := controller.GetControllerOf(curPod) curControllerRef := metav1.GetControllerOf(curPod)
oldControllerRef := controller.GetControllerOf(oldPod) oldControllerRef := metav1.GetControllerOf(oldPod)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return 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 // ignore pods that belong to the daemonset when taking into account whether
// a daemonset should bind to a node. // 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 continue
} }
pods = append(pods, pod) pods = append(pods, pod)

View File

@ -205,7 +205,7 @@ func (dc *DeploymentController) addReplicaSet(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) d := dc.resolveControllerRef(rs.Namespace, controllerRef)
if d == nil { if d == nil {
return return
@ -260,8 +260,8 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
return return
} }
curControllerRef := controller.GetControllerOf(curRS) curControllerRef := metav1.GetControllerOf(curRS)
oldControllerRef := controller.GetControllerOf(oldRS) oldControllerRef := metav1.GetControllerOf(oldRS)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return
@ -409,7 +409,7 @@ func (dc *DeploymentController) getDeploymentForPod(pod *v1.Pod) *extensions.Dep
// Find the owning replica set // Find the owning replica set
var rs *extensions.ReplicaSet var rs *extensions.ReplicaSet
var err error var err error
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
// No controller owns this Pod. // No controller owns this Pod.
return nil return nil
@ -425,7 +425,7 @@ func (dc *DeploymentController) getDeploymentForPod(pod *v1.Pod) *extensions.Dep
} }
// Now find the Deployment that owns that ReplicaSet. // Now find the Deployment that owns that ReplicaSet.
controllerRef = controller.GetControllerOf(rs) controllerRef = metav1.GetControllerOf(rs)
if controllerRef == nil { if controllerRef == nil {
return nil return nil
} }
@ -542,7 +542,7 @@ func (dc *DeploymentController) getPodMapForDeployment(d *extensions.Deployment,
for _, pod := range pods { for _, pod := range pods {
// Do not ignore inactive Pods because Recreate Deployments need to verify that no // Do not ignore inactive Pods because Recreate Deployments need to verify that no
// Pods from older versions are running before spinning up new Pods. // Pods from older versions are running before spinning up new Pods.
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
continue continue
} }

View File

@ -579,7 +579,7 @@ func ListReplicaSets(deployment *extensions.Deployment, getRSList RsListFunc) ([
// Only include those whose ControllerRef matches the Deployment. // Only include those whose ControllerRef matches the Deployment.
owned := make([]*extensions.ReplicaSet, 0, len(all)) owned := make([]*extensions.ReplicaSet, 0, len(all))
for _, rs := range all { for _, rs := range all {
controllerRef := controller.GetControllerOf(rs) controllerRef := metav1.GetControllerOf(rs)
if controllerRef != nil && controllerRef.UID == deployment.UID { if controllerRef != nil && controllerRef.UID == deployment.UID {
owned = append(owned, rs) owned = append(owned, rs)
} }
@ -603,7 +603,7 @@ func ListReplicaSetsInternal(deployment *internalextensions.Deployment, getRSLis
// Only include those whose ControllerRef matches the Deployment. // Only include those whose ControllerRef matches the Deployment.
filtered := make([]*internalextensions.ReplicaSet, 0, len(all)) filtered := make([]*internalextensions.ReplicaSet, 0, len(all))
for _, rs := range all { for _, rs := range all {
controllerRef := controller.GetControllerOf(rs) controllerRef := metav1.GetControllerOf(rs)
if controllerRef != nil && controllerRef.UID == deployment.UID { if controllerRef != nil && controllerRef.UID == deployment.UID {
filtered = append(filtered, rs) 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))} owned := &v1.PodList{Items: make([]v1.Pod, 0, len(all.Items))}
for i := range all.Items { for i := range all.Items {
pod := &all.Items[i] pod := &all.Items[i]
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef != nil && rsMap[controllerRef.UID] { if controllerRef != nil && rsMap[controllerRef.UID] {
owned.Items = append(owned.Items, *pod) owned.Items = append(owned.Items, *pod)
} }

View File

@ -184,7 +184,7 @@ var (
// getPodReplicaSets finds replicasets which have no matching deployments. // getPodReplicaSets finds replicasets which have no matching deployments.
func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndScale, error) { func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndScale, error) {
var casSlice []controllerAndScale var casSlice []controllerAndScale
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return nil, nil return nil, nil
} }
@ -199,7 +199,7 @@ func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndS
if rs.UID != controllerRef.UID { if rs.UID != controllerRef.UID {
return nil, nil return nil, nil
} }
controllerRef = controller.GetControllerOf(rs) controllerRef = metav1.GetControllerOf(rs)
if controllerRef != nil && controllerRef.Kind == controllerKindDep.Kind { if controllerRef != nil && controllerRef.Kind == controllerKindDep.Kind {
// Skip RS if it's controlled by a Deployment. // Skip RS if it's controlled by a Deployment.
return nil, nil return nil, nil
@ -211,7 +211,7 @@ func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndS
// getPodStatefulSet returns the statefulset managing the given pod. // getPodStatefulSet returns the statefulset managing the given pod.
func (dc *DisruptionController) getPodStatefulSets(pod *v1.Pod) ([]controllerAndScale, error) { func (dc *DisruptionController) getPodStatefulSets(pod *v1.Pod) ([]controllerAndScale, error) {
var casSlice []controllerAndScale var casSlice []controllerAndScale
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return nil, 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. // getPodDeployments finds deployments for any replicasets which are being managed by deployments.
func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndScale, error) { func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndScale, error) {
var casSlice []controllerAndScale var casSlice []controllerAndScale
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return nil, nil return nil, nil
} }
@ -249,7 +249,7 @@ func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndS
if rs.UID != controllerRef.UID { if rs.UID != controllerRef.UID {
return nil, nil return nil, nil
} }
controllerRef = controller.GetControllerOf(rs) controllerRef = metav1.GetControllerOf(rs)
if controllerRef == nil { if controllerRef == nil {
return nil, 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) { func (dc *DisruptionController) getPodReplicationControllers(pod *v1.Pod) ([]controllerAndScale, error) {
var casSlice []controllerAndScale var casSlice []controllerAndScale
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return nil, nil return nil, nil
} }

View File

@ -37,7 +37,6 @@ go_library(
tags = ["automanaged"], tags = ["automanaged"],
deps = [ deps = [
"//pkg/client/retry:go_default_library", "//pkg/client/retry:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/util/hash:go_default_library", "//pkg/util/hash:go_default_library",
"//vendor/k8s.io/api/apps/v1beta1:go_default_library", "//vendor/k8s.io/api/apps/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library", "//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",

View File

@ -27,7 +27,6 @@ import (
appsinformers "k8s.io/client-go/informers/apps/v1beta1" appsinformers "k8s.io/client-go/informers/apps/v1beta1"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
appslisters "k8s.io/client-go/listers/apps/v1beta1" appslisters "k8s.io/client-go/listers/apps/v1beta1"
"k8s.io/kubernetes/pkg/controller"
hashutil "k8s.io/kubernetes/pkg/util/hash" hashutil "k8s.io/kubernetes/pkg/util/hash"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
@ -225,7 +224,7 @@ func (rh *realHistory) ListControllerRevisions(parent metav1.Object, selector la
} }
var owned []*apps.ControllerRevision var owned []*apps.ControllerRevision
for i := range history { for i := range history {
ref := controller.GetControllerOf(history[i]) ref := metav1.GetControllerOf(history[i])
if ref == nil || ref.UID == parent.GetUID() { if ref == nil || ref.UID == parent.GetUID() {
owned = append(owned, history[i]) 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) { 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 // 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) 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 // 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 var owned []*apps.ControllerRevision
for i := range history { for i := range history {
ref := controller.GetControllerOf(history[i]) ref := metav1.GetControllerOf(history[i])
if ref == nil || ref.UID == parent.GetUID() { if ref == nil || ref.UID == parent.GetUID() {
owned = append(owned, history[i]) 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) { func (fh *fakeHistory) AdoptControllerRevision(parent metav1.Object, parentKind schema.GroupVersionKind, revision *apps.ControllerRevision) (*apps.ControllerRevision, error) {
blockOwnerDeletion := true blockOwnerDeletion := true
isController := 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) return nil, fmt.Errorf("attempt to adopt revision owned by %v", owner)
} }
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(revision) key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(revision)

View File

@ -992,7 +992,7 @@ func TestRealHistory_AdoptControllerRevision(t *testing.T) {
if !test.err && err != nil { if !test.err && err != nil {
t.Errorf("%s: %s", test.name, err) 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) t.Errorf("%s: adoption failed", test.name)
} }
if test.err && err == nil { if test.err && err == nil {
@ -1103,7 +1103,7 @@ func TestFakeHistory_AdoptControllerRevision(t *testing.T) {
if !test.err && err != nil { if !test.err && err != nil {
t.Errorf("%s: %s", test.name, err) 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) t.Errorf("%s: adoption failed", test.name)
} }
if test.err && err == nil { if test.err && err == nil {
@ -1211,7 +1211,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if found == nil { if found == nil {
return true, nil, errors.NewNotFound(apps.Resource("controllerrevisions"), test.revision.Name) 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() { foundParent.UID != test.parent.GetUID() {
return true, nil, errors.NewInvalid( return true, nil, errors.NewInvalid(
test.revision.GroupVersionKind().GroupKind(), test.revision.Name, nil) test.revision.GroupVersionKind().GroupKind(), test.revision.Name, nil)
@ -1258,7 +1258,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
if adopted == nil { if adopted == nil {
return 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) t.Errorf("%s: release failed", test.name)
} }
} }
@ -1386,7 +1386,7 @@ func TestFakeHistory_ReleaseControllerRevision(t *testing.T) {
if adopted == nil { if adopted == nil {
return 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) t.Errorf("%s: release failed", test.name)
} }
} }

View File

@ -193,7 +193,7 @@ func (jm *JobController) addPod(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) job := jm.resolveControllerRef(pod.Namespace, controllerRef)
if job == nil { if job == nil {
return return
@ -238,8 +238,8 @@ func (jm *JobController) updatePod(old, cur interface{}) {
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels) labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
curControllerRef := controller.GetControllerOf(curPod) curControllerRef := metav1.GetControllerOf(curPod)
oldControllerRef := controller.GetControllerOf(oldPod) oldControllerRef := metav1.GetControllerOf(oldPod)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return

View File

@ -236,7 +236,7 @@ func (rsc *ReplicaSetController) addPod(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) rs := rsc.resolveControllerRef(pod.Namespace, controllerRef)
if rs == nil { if rs == nil {
return return
@ -292,8 +292,8 @@ func (rsc *ReplicaSetController) updatePod(old, cur interface{}) {
return return
} }
curControllerRef := controller.GetControllerOf(curPod) curControllerRef := metav1.GetControllerOf(curPod)
oldControllerRef := controller.GetControllerOf(oldPod) oldControllerRef := metav1.GetControllerOf(oldPod)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return

View File

@ -231,7 +231,7 @@ func (rm *ReplicationManager) addPod(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) rc := rm.resolveControllerRef(pod.Namespace, controllerRef)
if rc == nil { if rc == nil {
return return
@ -287,8 +287,8 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
return return
} }
curControllerRef := controller.GetControllerOf(curPod) curControllerRef := metav1.GetControllerOf(curPod)
oldControllerRef := controller.GetControllerOf(oldPod) oldControllerRef := metav1.GetControllerOf(oldPod)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return

View File

@ -170,7 +170,7 @@ func (ssc *StatefulSetController) addPod(obj interface{}) {
} }
// If it has a ControllerRef, that's all that matters. // 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) set := ssc.resolveControllerRef(pod.Namespace, controllerRef)
if set == nil { if set == nil {
return return
@ -204,8 +204,8 @@ func (ssc *StatefulSetController) updatePod(old, cur interface{}) {
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels) labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
curControllerRef := controller.GetControllerOf(curPod) curControllerRef := metav1.GetControllerOf(curPod)
oldControllerRef := controller.GetControllerOf(oldPod) oldControllerRef := metav1.GetControllerOf(oldPod)
controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef) controllerRefChanged := !reflect.DeepEqual(curControllerRef, oldControllerRef)
if controllerRefChanged && oldControllerRef != nil { if controllerRefChanged && oldControllerRef != nil {
// The ControllerRef was changed. Sync the old controller, if any. // 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 { if controllerRef == nil {
// No controller should care about orphans being deleted. // No controller should care about orphans being deleted.
return return
@ -316,7 +316,7 @@ func (ssc *StatefulSetController) adoptOrphanRevisions(set *apps.StatefulSet) er
} }
hasOrphans := false hasOrphans := false
for i := range revisions { for i := range revisions {
if controller.GetControllerOf(revisions[i]) == nil { if metav1.GetControllerOf(revisions[i]) == nil {
hasOrphans = true hasOrphans = true
break break
} }

View File

@ -31,7 +31,6 @@ import (
apps "k8s.io/api/apps/v1beta1" apps "k8s.io/api/apps/v1beta1"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
podutil "k8s.io/kubernetes/pkg/api/v1/pod" podutil "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/history" "k8s.io/kubernetes/pkg/controller/history"
) )
@ -252,7 +251,7 @@ func TestOverlappingStatefulSets(t *testing.T) {
func TestNewPodControllerRef(t *testing.T) { func TestNewPodControllerRef(t *testing.T) {
set := newStatefulSet(1) set := newStatefulSet(1)
pod := newStatefulSetPod(set, 0) pod := newStatefulSetPod(set, 0)
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
t.Fatalf("No ControllerRef found on new pod") t.Fatalf("No ControllerRef found on new pod")
} }

View File

@ -135,7 +135,6 @@ go_library(
"//pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion:go_default_library", "//pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion:go_default_library",
"//pkg/client/retry:go_default_library", "//pkg/client/retry:go_default_library",
"//pkg/client/unversioned:go_default_library", "//pkg/client/unversioned:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/daemon:go_default_library", "//pkg/controller/daemon:go_default_library",
"//pkg/controller/deployment/util:go_default_library", "//pkg/controller/deployment/util:go_default_library",
"//pkg/credentialprovider:go_default_library", "//pkg/credentialprovider:go_default_library",

View File

@ -79,7 +79,6 @@ go_library(
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion:go_default_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/clientset_generated/internalclientset/typed/rbac/internalversion:go_default_library",
"//pkg/client/unversioned:go_default_library", "//pkg/client/unversioned:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/kubectl:go_default_library", "//pkg/kubectl:go_default_library",
"//pkg/kubectl/cmd/auth:go_default_library", "//pkg/kubectl/cmd/auth:go_default_library",
"//pkg/kubectl/cmd/config:go_default_library", "//pkg/kubectl/cmd/config:go_default_library",

View File

@ -42,7 +42,6 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates" "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" 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) { func (o *DrainOptions) getPodController(pod api.Pod) (*metav1.OwnerReference, error) {
controllerRef := controller.GetControllerOf(&pod) controllerRef := metav1.GetControllerOf(&pod)
if controllerRef == nil { if controllerRef == nil {
return nil, nil return nil, nil
} }

View File

@ -37,7 +37,6 @@ import (
"k8s.io/kubernetes/pkg/apis/apps" "k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
sliceutil "k8s.io/kubernetes/pkg/kubectl/util/slice" sliceutil "k8s.io/kubernetes/pkg/kubectl/util/slice"
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion" printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
@ -273,7 +272,7 @@ func controlledHistories(c externalclientset.Interface, namespace, name string)
for i := range historyList.Items { for i := range historyList.Items {
history := historyList.Items[i] history := historyList.Items[i]
// Skip history that doesn't belong to the DaemonSet // 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 continue
} }
result = append(result, &history) result = append(result, &history)

View File

@ -81,7 +81,6 @@ go_library(
"//pkg/apis/storage/util:go_default_library", "//pkg/apis/storage/util:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library", "//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset/typed/core/internalversion: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/controller/deployment/util:go_default_library",
"//pkg/fieldpath:go_default_library", "//pkg/fieldpath:go_default_library",
"//pkg/printers:go_default_library", "//pkg/printers:go_default_library",

View File

@ -70,7 +70,6 @@ import (
storageutil "k8s.io/kubernetes/pkg/apis/storage/util" storageutil "k8s.io/kubernetes/pkg/apis/storage/util"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
coreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" 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" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/fieldpath" "k8s.io/kubernetes/pkg/fieldpath"
"k8s.io/kubernetes/pkg/printers" "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 { 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 fmt.Sprintf("%s/%s", controllerRef.Kind, controllerRef.Name)
} }
return "" return ""
@ -2923,7 +2922,7 @@ func getPodStatusForController(c coreclient.PodInterface, selector labels.Select
return return
} }
for _, pod := range rcPods.Items { for _, pod := range rcPods.Items {
controllerRef := controller.GetControllerOf(&pod) controllerRef := metav1.GetControllerOf(&pod)
// Skip pods that are orphans or owned by other controllers. // Skip pods that are orphans or owned by other controllers.
if controllerRef == nil || controllerRef.UID != uid { if controllerRef == nil || controllerRef.UID != uid {
continue continue

View File

@ -55,7 +55,6 @@ import (
"k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/rbac"
"k8s.io/kubernetes/pkg/apis/storage" "k8s.io/kubernetes/pkg/apis/storage"
storageutil "k8s.io/kubernetes/pkg/apis/storage/util" storageutil "k8s.io/kubernetes/pkg/apis/storage/util"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/printers" "k8s.io/kubernetes/pkg/printers"
"k8s.io/kubernetes/pkg/util/node" "k8s.io/kubernetes/pkg/util/node"
) )
@ -1770,7 +1769,7 @@ func printControllerRevision(obj *apps.ControllerRevision, options printers.Prin
Object: runtime.RawExtension{Object: obj}, Object: runtime.RawExtension{Object: obj},
} }
controllerRef := controller.GetControllerOf(obj) controllerRef := metav1.GetControllerOf(obj)
controllerName := "<none>" controllerName := "<none>"
if controllerRef != nil { if controllerRef != nil {
withKind := true withKind := true

View File

@ -23,7 +23,6 @@ go_library(
"//pkg/api:go_default_library", "//pkg/api:go_default_library",
"//pkg/api/v1/pod:go_default_library", "//pkg/api/v1/pod:go_default_library",
"//pkg/client/retry:go_default_library", "//pkg/client/retry:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/printers:go_default_library", "//pkg/printers:go_default_library",
"//pkg/util/version:go_default_library", "//pkg/util/version:go_default_library",
"//test/e2e/apps:go_default_library", "//test/e2e/apps:go_default_library",

View File

@ -21,7 +21,7 @@ import (
"time" "time"
"k8s.io/api/core/v1" "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" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apiextensionstestserver "k8s.io/apiextensions-apiserver/test/integration/testserver" apiextensionstestserver "k8s.io/apiextensions-apiserver/test/integration/testserver"
@ -33,7 +33,6 @@ import (
"k8s.io/apiserver/pkg/storage/names" "k8s.io/apiserver/pkg/storage/names"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/metrics" "k8s.io/kubernetes/test/e2e/metrics"
@ -498,7 +497,7 @@ var _ = SIGDescribe("Garbage collector", func() {
framework.Failf("Failed to list ReplicaSet %v", err) framework.Failf("Failed to list ReplicaSet %v", err)
} }
for _, replicaSet := range rs.Items { 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) framework.Failf("Found ReplicaSet with non nil ownerRef %v", replicaSet)
} }
} }

View File

@ -630,7 +630,7 @@ func checkDaemonPodOnNodes(f *framework.Framework, ds *extensions.DaemonSet, nod
nodesToPodCount := make(map[string]int) nodesToPodCount := make(map[string]int)
for _, pod := range pods { 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 continue
} }
if pod.DeletionTimestamp != nil { if pod.DeletionTimestamp != nil {
@ -726,7 +726,7 @@ func checkDaemonPodsImageAndAvailability(c clientset.Interface, ds *extensions.D
unavailablePods := 0 unavailablePods := 0
allImagesUpdated := true allImagesUpdated := true
for _, pod := range pods { 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 continue
} }
podImage := pod.Spec.Containers[0].Image 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) pods := listDaemonPods(c, ns, label)
for _, pod := range pods.Items { for _, pod := range pods.Items {
// This pod is orphaned only when controller ref is cleared // 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 return false, nil
} }
} }
@ -792,7 +792,7 @@ func checkDaemonSetHistoryOrphaned(c clientset.Interface, ns string, label map[s
histories := listDaemonHistories(c, ns, label) histories := listDaemonHistories(c, ns, label)
for _, history := range histories.Items { for _, history := range histories.Items {
// This history is orphaned only when controller ref is cleared // 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 return false, nil
} }
} }
@ -805,7 +805,7 @@ func checkDaemonSetPodsAdopted(c clientset.Interface, ns string, dsUID types.UID
pods := listDaemonPods(c, ns, label) pods := listDaemonPods(c, ns, label)
for _, pod := range pods.Items { for _, pod := range pods.Items {
// This pod is adopted only when its controller ref is update // 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 return false, nil
} }
} }
@ -818,7 +818,7 @@ func checkDaemonSetHistoryAdopted(c clientset.Interface, ns string, dsUID types.
histories := listDaemonHistories(c, ns, label) histories := listDaemonHistories(c, ns, label)
for _, history := range histories.Items { for _, history := range histories.Items {
// This history is adopted only when its controller ref is update // 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 return false, nil
} }
} }

View File

@ -38,7 +38,6 @@ import (
extensionsclient "k8s.io/client-go/kubernetes/typed/extensions/v1beta1" extensionsclient "k8s.io/client-go/kubernetes/typed/extensions/v1beta1"
extensionsinternal "k8s.io/kubernetes/pkg/apis/extensions" extensionsinternal "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/controller"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
utilpointer "k8s.io/kubernetes/pkg/util/pointer" utilpointer "k8s.io/kubernetes/pkg/util/pointer"
@ -1380,7 +1379,7 @@ func checkDeploymentReplicaSetsControllerRef(c clientset.Interface, ns string, u
rsList := listDeploymentReplicaSets(c, ns, label) rsList := listDeploymentReplicaSets(c, ns, label)
for _, rs := range rsList.Items { for _, rs := range rsList.Items {
// This rs is adopted only when its controller ref is update // 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) 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) rsList := listDeploymentReplicaSets(c, ns, label)
for _, rs := range rsList.Items { for _, rs := range rsList.Items {
// This rs is orphaned only when controller ref is cleared // 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 return false, nil
} }
} }

View File

@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
batchinternal "k8s.io/kubernetes/pkg/apis/batch" batchinternal "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
@ -135,7 +134,7 @@ var _ = SIGDescribe("Job", func() {
By("Checking that the Job readopts the Pod") By("Checking that the Job readopts the Pod")
Expect(framework.WaitForPodCondition(f.ClientSet, pod.Namespace, pod.Name, "adopted", framework.JobTimeout, Expect(framework.WaitForPodCondition(f.ClientSet, pod.Namespace, pod.Name, "adopted", framework.JobTimeout,
func(pod *v1.Pod) (bool, error) { func(pod *v1.Pod) (bool, error) {
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return false, nil return false, nil
} }
@ -154,7 +153,7 @@ var _ = SIGDescribe("Job", func() {
By("Checking that the Job releases the Pod") By("Checking that the Job releases the Pod")
Expect(framework.WaitForPodCondition(f.ClientSet, pod.Namespace, pod.Name, "released", framework.JobTimeout, Expect(framework.WaitForPodCondition(f.ClientSet, pod.Namespace, pod.Name, "released", framework.JobTimeout,
func(pod *v1.Pod) (bool, error) { func(pod *v1.Pod) (bool, error) {
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef != nil { if controllerRef != nil {
return false, nil return false, nil
} }

View File

@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
) )
@ -145,7 +144,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By("Checking that stateful set pods are created with ControllerRef") By("Checking that stateful set pods are created with ControllerRef")
pod := pods.Items[0] pod := pods.Items[0]
controllerRef := controller.GetControllerOf(&pod) controllerRef := metav1.GetControllerOf(&pod)
Expect(controllerRef).ToNot(BeNil()) Expect(controllerRef).ToNot(BeNil())
Expect(controllerRef.Kind).To(Equal(ss.Kind)) Expect(controllerRef.Kind).To(Equal(ss.Kind))
Expect(controllerRef.Name).To(Equal(ss.Name)) Expect(controllerRef.Name).To(Equal(ss.Name))
@ -159,7 +158,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By("Checking that the stateful set readopts the pod") By("Checking that the stateful set readopts the pod")
Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "adopted", framework.StatefulSetTimeout, Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "adopted", framework.StatefulSetTimeout,
func(pod *v1.Pod) (bool, error) { func(pod *v1.Pod) (bool, error) {
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return false, nil return false, nil
} }
@ -179,7 +178,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By("Checking that the stateful set releases the pod") By("Checking that the stateful set releases the pod")
Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "released", framework.StatefulSetTimeout, Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "released", framework.StatefulSetTimeout,
func(pod *v1.Pod) (bool, error) { func(pod *v1.Pod) (bool, error) {
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef != nil { if controllerRef != nil {
return false, nil return false, nil
} }
@ -196,7 +195,7 @@ var _ = SIGDescribe("StatefulSet", func() {
By("Checking that the stateful set readopts the pod") By("Checking that the stateful set readopts the pod")
Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "adopted", framework.StatefulSetTimeout, Expect(framework.WaitForPodCondition(c, pod.Namespace, pod.Name, "adopted", framework.StatefulSetTimeout,
func(pod *v1.Pod) (bool, error) { func(pod *v1.Pod) (bool, error) {
controllerRef := controller.GetControllerOf(pod) controllerRef := metav1.GetControllerOf(pod)
if controllerRef == nil { if controllerRef == nil {
return false, nil return false, nil
} }

View File

@ -653,7 +653,7 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN
notReady++ notReady++
badPods = append(badPods, pod) badPods = append(badPods, pod)
default: 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) Logf("Pod %s is Failed, but it's not controlled by a controller", pod.ObjectMeta.Name)
badPods = append(badPods, pod) badPods = append(badPods, pod)
} }