Skip to content

Commit

Permalink
Merge pull request #10593 from chrischdi/pr-cp-10590
Browse files Browse the repository at this point in the history
[release-1.6] 馃悰 test: Ensure ownerRef assertions for all Kinds are evaluated
  • Loading branch information
k8s-ci-robot committed May 13, 2024
2 parents f39c480 + 88dcaa6 commit 48c0ac8
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, 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, assertFuncs ...map[
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 48c0ac8

Please sign in to comment.