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

log all missing CRDs when detecting if dependency is missing #1127

Open
KevFan opened this issue Jan 20, 2025 · 0 comments
Open

log all missing CRDs when detecting if dependency is missing #1127

KevFan opened this issue Jan 20, 2025 · 0 comments
Labels
kind/enhancement New feature or request size/small

Comments

@KevFan
Copy link
Contributor

KevFan commented Jan 20, 2025

Description

Highlighted in #994 (comment), we should log all missing CRDs/errors when determining a dependency is missing or not at once instead of sequentially. We should also potentially report the error in the CR status as while missing CRD is an inference that an dependency is missing, this may not always be the case such:

  • Only dependent CRD version is missing
  • Error is CRD detection logic

Places to be updated include:

  • func IsAuthorinoOperatorInstalled(restMapper meta.RESTMapper, logger logr.Logger) (bool, error) {
    if ok, err := utils.IsCRDInstalled(restMapper, kuadrantv1beta1.AuthorinoGroupKind.Group, kuadrantv1beta1.AuthorinoGroupKind.Kind, authorinooperatorv1beta1.GroupVersion.Version); !ok || err != nil {
    logger.V(1).Error(err, "Authorino Operator CRD was not installed", "group", kuadrantv1beta1.AuthorinoGroupKind.Group, "kind", kuadrantv1beta1.AuthorinoGroupKind.Kind, "version", authorinooperatorv1beta1.GroupVersion.Version)
    return false, err
    }
    if ok, err := utils.IsCRDInstalled(restMapper, AuthConfigGroupKind.Group, AuthConfigGroupKind.Kind, authorinov1beta3.GroupVersion.Version); !ok || err != nil {
    logger.V(1).Error(err, "Authorino Operator CRD was not installed", "group", AuthConfigGroupKind.Group, "kind", AuthConfigGroupKind.Kind, "version", authorinov1beta3.GroupVersion.Version)
    return false, err
    }
    return true, nil
    }
  • func IsCertManagerInstalled(restMapper meta.RESTMapper, logger logr.Logger) (bool, error) {
    if ok, err := utils.IsCRDInstalled(restMapper, certmanager.GroupName, certmanv1.CertificateKind, certmanv1.SchemeGroupVersion.Version); !ok || err != nil {
    logger.V(1).Error(err, "CertManager CRD was not installed", "group", certmanager.GroupName, "kind", certmanv1.CertificateKind, "version", certmanv1.SchemeGroupVersion.Version)
    return false, err
    }
    if ok, err := utils.IsCRDInstalled(restMapper, certmanager.GroupName, certmanv1.IssuerKind, certmanv1.SchemeGroupVersion.Version); !ok || err != nil {
    logger.V(1).Error(err, "CertManager CRD was not installed", "group", certmanager.GroupName, "kind", certmanv1.IssuerKind, "version", certmanv1.SchemeGroupVersion.Version)
    return false, err
    }
    if ok, err := utils.IsCRDInstalled(restMapper, certmanager.GroupName, certmanv1.ClusterIssuerKind, certmanv1.SchemeGroupVersion.Version); !ok || err != nil {
    logger.V(1).Error(err, "CertManager CRD was not installed", "group", certmanager.GroupName, "kind", certmanv1.ClusterIssuerKind, "version", certmanv1.SchemeGroupVersion.Version)
    return false, err
    }
    return true, nil
    }
  • func IsIstioInstalled(restMapper meta.RESTMapper) (bool, error) {
    ok, err := IsWASMPluginInstalled(restMapper)
    if err != nil {
    return false, err
    }
    if !ok {
    return false, nil
    }
    ok, err = IsEnvoyFilterInstalled(restMapper)
    if err != nil {
    return false, err
    }
    if !ok {
    return false, nil
    }
    // Istio found
    return true, nil
    }
  • func IsEnvoyGatewayInstalled(restMapper meta.RESTMapper) (bool, error) {
    ok, err := IsEnvoyExtensionPolicyInstalled(restMapper)
    if err != nil {
    return false, err
    }
    if !ok {
    return false, nil
    }
    ok, err = IsEnvoyPatchPolicyInstalled(restMapper)
    if err != nil {
    return false, err
    }
    if !ok {
    return false, nil
    }
    // EnvoyGateway found
    return true, nil
    }
  • Possibly others. Looks through https://github.com/Kuadrant/kuadrant-operator/blob/main/controllers/state_of_the_world.go for functions where more than 1 CRD is checked for determining if a dependency is installed or not
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request size/small
Projects
Status: No status
Development

No branches or pull requests

1 participant