Skip to content

Commit

Permalink
Merge pull request #10592 from k8s-infra-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-10590-to-release-1.7

[release-1.7] 🐛 test: Ensure all ownerRef assertions for some Kind are evaluated
  • Loading branch information
k8s-ci-robot authored May 13, 2024
2 parents e226702 + aac1100 commit a5898a2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/framework/ownerreference_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func ValidateOwnerReferencesResilience(ctx context.Context, proxy ClusterProxy,
}

func AssertOwnerReferences(namespace, kubeconfigPath string, ownerGraphFilterFunction clusterctlcluster.GetOwnerGraphFilterFunction, assertFuncs ...map[string]func(reference []metav1.OwnerReference) error) {
allAssertFuncs := map[string]func(reference []metav1.OwnerReference) error{}
allAssertFuncs := map[string][]func(reference []metav1.OwnerReference) error{}
for _, m := range assertFuncs {
for k, v := range m {
allAssertFuncs[k] = v
allAssertFuncs[k] = append(allAssertFuncs[k], v)
}
}
Eventually(func() error {
Expand All @@ -125,8 +125,10 @@ func AssertOwnerReferences(namespace, kubeconfigPath string, ownerGraphFilterFun
allErrs = append(allErrs, fmt.Errorf("kind %s does not have an associated ownerRef assertion function", v.Object.Kind))
continue
}
if err := allAssertFuncs[v.Object.Kind](v.Owners); err != nil {
allErrs = append(allErrs, errors.Wrapf(err, "Unexpected ownerReferences for %s/%s", v.Object.Kind, v.Object.Name))
for _, f := range allAssertFuncs[v.Object.Kind] {
if err := f(v.Owners); err != nil {
allErrs = append(allErrs, errors.Wrapf(err, "Unexpected ownerReferences for %s/%s", v.Object.Kind, v.Object.Name))
}
}
}
return kerrors.NewAggregate(allErrs)
Expand Down Expand Up @@ -308,7 +310,6 @@ var DockerInfraOwnerReferenceAssertions = map[string]func([]metav1.OwnerReferenc
dockerMachineKind: func(owners []metav1.OwnerReference) error {
// The DockerMachine must be owned and controlled by a Machine or a DockerMachinePool.
return HasOneOfExactOwners(owners, []metav1.OwnerReference{machineController}, []metav1.OwnerReference{machineController, dockerMachinePoolController})

},
dockerMachineTemplateKind: func(owners []metav1.OwnerReference) error {
// Base DockerMachineTemplates referenced in a ClusterClass must be owned by the ClusterClass.
Expand Down

0 comments on commit a5898a2

Please sign in to comment.