Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.6] 🐛 test: Ensure ownerRef assertions for all Kinds are evaluated #10593

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading