timflannagan / rukpak

Rukpak runs in a Kubernetes cluster and defines an API for installing cloud native bundle content
Apache License 2.0
0 stars 0 forks source link

improve NoKindMatchError matching #59

Closed github-actions[bot] closed 2 years ago

github-actions[bot] commented 2 years ago

An error that is bubbled up from the k8s.io/cli-runtime library

does not wrap meta.NoKindMatchError, so we need to fallback to

the use of string comparisons for now.

https://github.com/timflannagan/rukpak/blob/a980a1f29c5bed525fb266cd29aeb9e56cb03b38/internal/provisioner/plain/controllers/bundleinstance_controller.go#L445


    return objs, nil
}

type errRequiredResourceNotFound struct {
    error
}

func (err errRequiredResourceNotFound) Error() string {
    return fmt.Sprintf("required resource not found: %v", err.error)
}

func isResourceNotFoundErr(err error) bool {
    var agg utilerrors.Aggregate
    if errors.As(err, &agg) {
        for _, err := range agg.Errors() {
            return isResourceNotFoundErr(err)
        }
    }

    nkme := &meta.NoKindMatchError{}
    if errors.As(err, &nkme) {
        return true
    }
    if apierrors.IsNotFound(err) {
        return true
    }

    // TODO: improve NoKindMatchError matching
    //   An error that is bubbled up from the k8s.io/cli-runtime library
    //   does not wrap meta.NoKindMatchError, so we need to fallback to
    //   the use of string comparisons for now.
    return strings.Contains(err.Error(), "no matches for kind")
}

// SetupWithManager sets up the controller with the Manager.
func (r *BundleInstanceReconciler) SetupWithManager(mgr ctrl.Manager) error {
    controller, err := ctrl.NewControllerManagedBy(mgr).
github-actions[bot] commented 2 years ago

This issue has become stale because it has been open 60 days with no activity. The maintainers of this repo will remove this label during issue triage or it will be removed automatically after an update. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.

github-actions[bot] commented 2 years ago

Closed in 9759cb8e07c6a8b0947867c4a6549a1a8b4d5bac