diff --git a/internal/controller/catalog/catalog_controller.go b/internal/controller/catalog/catalog_controller.go index 62d0d748f..91f2c809d 100644 --- a/internal/controller/catalog/catalog_controller.go +++ b/internal/controller/catalog/catalog_controller.go @@ -393,28 +393,38 @@ func (r *CatalogReconciler) setStatus() lifecycle.Conditioner { gitRepo := &sourcev1.GitRepository{} gitRepo.SetName(sourcer.getGitRepoName()) gitRepo.SetNamespace(catalog.Namespace) - ready, msg := sourcer.objectReadiness(ctx, gitRepo) + ready, msg, err := sourcer.objectReadiness(ctx, gitRepo) + if err != nil { + // check if there was a not found error in getting GitRepository + if apierrors.IsNotFound(err) && source.SecretName != nil { + // if not found, then check if it is related to secret error + _, secretErr := sourcer.getSourceSecret(ctx) + if secretErr != nil { + msg = msg + "; " + secretErr.Error() + } + } + } allInventoryReady = append(allInventoryReady, ready) sourcer.setInventory(sourcev1.GitRepositoryKind, gitRepo.Name, msg, ready) artifactGen := &sourcev2.ArtifactGenerator{} artifactGen.SetName(sourcer.getGeneratorName()) artifactGen.SetNamespace(catalog.Namespace) - ready, msg = sourcer.objectReadiness(ctx, artifactGen) + ready, msg, _ = sourcer.objectReadiness(ctx, artifactGen) allInventoryReady = append(allInventoryReady, ready) sourcer.setInventory(sourcev2.ArtifactGeneratorKind, artifactGen.Name, msg, ready) extArtifact := &sourcev1.ExternalArtifact{} extArtifact.SetName(sourcer.getArtifactName()) extArtifact.SetNamespace(catalog.Namespace) - ready, msg = sourcer.objectReadiness(ctx, extArtifact) + ready, msg, _ = sourcer.objectReadiness(ctx, extArtifact) allInventoryReady = append(allInventoryReady, ready) sourcer.setInventory(sourcev1.ExternalArtifactKind, extArtifact.Name, msg, ready) kustomization := &kustomizev1.Kustomization{} kustomization.SetName(sourcer.getKustomizationName()) kustomization.SetNamespace(catalog.Namespace) - ready, msg = sourcer.objectReadiness(ctx, kustomization) + ready, msg, _ = sourcer.objectReadiness(ctx, kustomization) allInventoryReady = append(allInventoryReady, ready) sourcer.setInventory(kustomizev1.KustomizationKind, kustomization.Name, msg, ready) } diff --git a/internal/controller/catalog/source.go b/internal/controller/catalog/source.go index 212214a85..867b71837 100644 --- a/internal/controller/catalog/source.go +++ b/internal/controller/catalog/source.go @@ -515,10 +515,10 @@ func (s *source) findPluginDefinition(manifestBytes []byte, name string) (spec * // objectReadiness - checks the Ready condition of a catalog object (GitRepository, ArtifactGenerator, ExternalArtifact, Kustomization) // if not Ready, then the controller adds the Catalog object to requeue -func (s *source) objectReadiness(ctx context.Context, obj client.Object) (ready metav1.ConditionStatus, msg string) { +func (s *source) objectReadiness(ctx context.Context, obj client.Object) (ready metav1.ConditionStatus, msg string, err error) { ready = metav1.ConditionFalse key := client.ObjectKeyFromObject(obj) - if err := s.Get(ctx, key, obj); err != nil { + if err = s.Get(ctx, key, obj); err != nil { s.log.Error(err, "failed to get object", "key", key) msg = err.Error() return @@ -527,7 +527,7 @@ func (s *source) objectReadiness(ctx context.Context, obj client.Object) (ready kind := obj.GetObjectKind().GroupVersionKind().Kind cObj, ok := obj.(lifecycle.CatalogObject) if !ok { - err := fmt.Errorf("failed to assert catalog object kind %s - %s/%s", kind, key.Namespace, key.Name) + err = fmt.Errorf("failed to assert catalog object kind %s - %s/%s", kind, key.Namespace, key.Name) s.log.Error(err, "failed to assert catalog object", "key", key) msg = err.Error() return