mirror of https://github.com/k3s-io/k3s
Migrate to IsControlledBy from meta/v1 package
parent
042b5642b9
commit
32b78aebf2
|
@ -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 := metav1.GetControllerOf(pod); controllerRef != nil && controllerRef.UID == ds.UID {
|
||||
if metav1.IsControlledBy(pod, ds) {
|
||||
continue
|
||||
}
|
||||
pods = append(pods, pod)
|
||||
|
|
|
@ -579,8 +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 := metav1.GetControllerOf(rs)
|
||||
if controllerRef != nil && controllerRef.UID == deployment.UID {
|
||||
if metav1.IsControlledBy(rs, deployment) {
|
||||
owned = append(owned, rs)
|
||||
}
|
||||
}
|
||||
|
@ -603,8 +602,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 := metav1.GetControllerOf(rs)
|
||||
if controllerRef != nil && controllerRef.UID == deployment.UID {
|
||||
if metav1.IsControlledBy(rs, deployment) {
|
||||
filtered = append(filtered, rs)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 && metav1.GetControllerOf(adopted).UID != test.parent.GetUID() {
|
||||
if !test.err && !metav1.IsControlledBy(adopted, test.parent) {
|
||||
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 && metav1.GetControllerOf(adopted).UID != test.parent.GetUID() {
|
||||
if !test.err && !metav1.IsControlledBy(adopted, test.parent) {
|
||||
t.Errorf("%s: adoption failed", test.name)
|
||||
}
|
||||
if test.err && err == nil {
|
||||
|
@ -1211,8 +1211,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
|
|||
if found == nil {
|
||||
return true, nil, errors.NewNotFound(apps.Resource("controllerrevisions"), test.revision.Name)
|
||||
}
|
||||
if foundParent := metav1.GetControllerOf(test.revision); foundParent == nil ||
|
||||
foundParent.UID != test.parent.GetUID() {
|
||||
if !metav1.IsControlledBy(test.revision, test.parent) {
|
||||
return true, nil, errors.NewInvalid(
|
||||
test.revision.GroupVersionKind().GroupKind(), test.revision.Name, nil)
|
||||
}
|
||||
|
@ -1258,7 +1257,7 @@ func TestRealHistory_ReleaseControllerRevision(t *testing.T) {
|
|||
if adopted == nil {
|
||||
return
|
||||
}
|
||||
if owner := metav1.GetControllerOf(adopted); owner != nil && owner.UID == test.parent.GetUID() {
|
||||
if metav1.IsControlledBy(adopted, test.parent) {
|
||||
t.Errorf("%s: release failed", test.name)
|
||||
}
|
||||
}
|
||||
|
@ -1386,7 +1385,7 @@ func TestFakeHistory_ReleaseControllerRevision(t *testing.T) {
|
|||
if adopted == nil {
|
||||
return
|
||||
}
|
||||
if owner := metav1.GetControllerOf(adopted); owner != nil && owner.UID == test.parent.GetUID() {
|
||||
if metav1.IsControlledBy(adopted, test.parent) {
|
||||
t.Errorf("%s: release failed", test.name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,11 +271,10 @@ 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 := metav1.GetControllerOf(&history); controllerRef == nil || controllerRef.UID != ds.UID {
|
||||
continue
|
||||
// Only add history that belongs to the DaemonSet
|
||||
if metav1.IsControlledBy(&history, ds) {
|
||||
result = append(result, &history)
|
||||
}
|
||||
result = append(result, &history)
|
||||
}
|
||||
return ds, result, nil
|
||||
}
|
||||
|
|
|
@ -630,7 +630,7 @@ func checkDaemonPodOnNodes(f *framework.Framework, ds *extensions.DaemonSet, nod
|
|||
|
||||
nodesToPodCount := make(map[string]int)
|
||||
for _, pod := range pods {
|
||||
if controllerRef := metav1.GetControllerOf(&pod); controllerRef == nil || controllerRef.UID != ds.UID {
|
||||
if !metav1.IsControlledBy(&pod, ds) {
|
||||
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 := metav1.GetControllerOf(&pod); controllerRef == nil || controllerRef.UID != ds.UID {
|
||||
if !metav1.IsControlledBy(&pod, ds) {
|
||||
continue
|
||||
}
|
||||
podImage := pod.Spec.Containers[0].Image
|
||||
|
|
Loading…
Reference in New Issue