Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge 214e40e into d3c6f93
Browse files Browse the repository at this point in the history
  • Loading branch information
scothis authored Apr 28, 2023
2 parents d3c6f93 + 214e40e commit 7cc3437
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions reconcilers/reconcilers.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ type ChildReconciler[Type, ChildType client.Object, ChildListType client.ObjectL
// ReflectChildStatusOnParent updates the reconciled resource's status with values from the
// child. Select types of error are passed, including:
// - apierrs.IsConflict
ReflectChildStatusOnParent func(parent Type, child ChildType, err error)
ReflectChildStatusOnParent func(ctx context.Context, parent Type, child ChildType, err error)

// HarmonizeImmutableFields allows fields that are immutable on the current
// object to be copied to the desired object in order to avoid creating
Expand Down Expand Up @@ -1128,13 +1128,13 @@ func (r *ChildReconciler[T, CT, CLT]) Reconcile(ctx context.Context, resource T)
return Result{}, err
}
log.Info("unable to reconcile child, not owned", "child", namespaceName(conflicted), "ownerRefs", conflicted.GetOwnerReferences())
r.ReflectChildStatusOnParent(resource, child, err)
r.ReflectChildStatusOnParent(ctx, resource, child, err)
return Result{}, nil
}
log.Error(err, "unable to reconcile child")
return Result{}, err
}
r.ReflectChildStatusOnParent(resource, child, err)
r.ReflectChildStatusOnParent(ctx, resource, child, err)

return Result{}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/reconcilers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ func TestChildReconciler(t *testing.T) {
MergeBeforeUpdate: func(current, desired *corev1.ConfigMap) {
current.Data = desired.Data
},
ReflectChildStatusOnParent: func(parent *resources.TestResource, child *corev1.ConfigMap, err error) {
ReflectChildStatusOnParent: func(ctx context.Context, parent *resources.TestResource, child *corev1.ConfigMap, err error) {
if err != nil {
if apierrs.IsAlreadyExists(err) {
name := err.(apierrs.APIStatus).Status().Details.Name
Expand Down Expand Up @@ -2474,7 +2474,7 @@ func TestChildReconciler_Unstructured(t *testing.T) {
MergeBeforeUpdate: func(current, desired *unstructured.Unstructured) {
current.Object["data"] = desired.Object["data"]
},
ReflectChildStatusOnParent: func(parent *unstructured.Unstructured, child *unstructured.Unstructured, err error) {
ReflectChildStatusOnParent: func(ctx context.Context, parent *unstructured.Unstructured, child *unstructured.Unstructured, err error) {
if err != nil {
if apierrs.IsAlreadyExists(err) {
name := err.(apierrs.APIStatus).Status().Details.Name
Expand Down
16 changes: 8 additions & 8 deletions reconcilers/reconcilers_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
},
},
Expand All @@ -391,7 +391,7 @@ func TestChildReconciler_validate(t *testing.T) {
// ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
},
},
Expand All @@ -403,7 +403,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
// ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
},
},
Expand All @@ -415,7 +415,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
// DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
},
shouldErr: `ChildReconciler "DesiredChild missing" must implement DesiredChild`,
Expand All @@ -440,7 +440,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
ListOptions: func(ctx context.Context, parent *corev1.ConfigMap) []client.ListOption { return []client.ListOption{} },
},
Expand All @@ -453,7 +453,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
Finalizer: "my-finalizer",
},
Expand All @@ -467,7 +467,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
SkipOwnerReference: true,
},
Expand All @@ -480,7 +480,7 @@ func TestChildReconciler_validate(t *testing.T) {
ChildType: &corev1.Pod{},
ChildListType: &corev1.PodList{},
DesiredChild: func(ctx context.Context, parent *corev1.ConfigMap) (*corev1.Pod, error) { return nil, nil },
ReflectChildStatusOnParent: func(parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
ReflectChildStatusOnParent: func(ctx context.Context, parent *corev1.ConfigMap, child *corev1.Pod, err error) {},
MergeBeforeUpdate: func(current, desired *corev1.Pod) {},
OurChild: func(parent *corev1.ConfigMap, child *corev1.Pod) bool { return false },
},
Expand Down

0 comments on commit 7cc3437

Please sign in to comment.