ManageIQ / manageiq-pods

ManageIQ on Kubernetes and OpenShift
Apache License 2.0
50 stars 100 forks source link

Error handling for FindCatalogSourceByName #1044

Closed nasark closed 7 months ago

nasark commented 7 months ago

The FindCatalogSourceByName was returning an empty catalog source object if the catalog source was not found instead of returning nil i.e. (from debug logging)

{"result": {"metadata":{"creationTimestamp":null},"spec":{"sourceType":"","icon":{"base64data":"","mediatype":""}},"status":{}}}

This was nullifying the openshift checks we have in place for deploying the strimzi operator https://github.com/ManageIQ/manageiq-pods/blob/master/manageiq-operator/internal/controller/manageiq_controller.go#L529

In addition it was found that the following error is thrown if performing a client.Get() call on a resource for which the CRDs are not installed (instead of throwing errors.IsNotFound()):

failed to get restmapping: no matches for kind \"CatalogSource\" in group \"operators.coreos.com\"

This occurs when using plain k8s as the openshift CRDs (operators.coreos.com) are not installed

@miq-bot add_labels bug, quinteros/yes? @miq-bot assign @bdunne @miq-bot add_reviewer @Fryguy

Ref: https://github.com/ManageIQ/manageiq-pods/issues/1043

miq-bot commented 7 months ago

Checked commit https://github.com/nasark/manageiq-pods/commit/6bbdbe32fb7388a74d89aaef5cd8ae5c7961008e with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint 0 files checked, 0 offenses detected Everything looks fine. :star:

Fryguy commented 7 months ago

Backported to quinteros in commit 0b59f6762f7fc60d648ec23c83bacfbbb1bbb765.

commit 0b59f6762f7fc60d648ec23c83bacfbbb1bbb765
Author: Brandon Dunne <brandondunne@hotmail.com>
Date:   Tue Jan 30 16:32:25 2024 -0500

    Merge pull request #1044 from nasark/findcatalogsource_error_handling

    Error handling for FindCatalogSourceByName

    (cherry picked from commit 0d1c69b871f5deb3b7a2038a06f30d7b1fffb426)