From a270c8f825f0b81bc66b52b593629cbde325dd31 Mon Sep 17 00:00:00 2001 From: Yazdan Mohammadi Date: Fri, 6 Sep 2024 18:12:22 +0200 Subject: [PATCH 1/2] Keep the application if there is a diff error --- internal/pkg/argocd/argocd.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/pkg/argocd/argocd.go b/internal/pkg/argocd/argocd.go index d4b689f..c4ef803 100644 --- a/internal/pkg/argocd/argocd.go +++ b/internal/pkg/argocd/argocd.go @@ -521,7 +521,9 @@ func generateDiffOfAComponent(ctx context.Context, commentDiff bool, componentPa log.Debugf("Generating diff for component %s", componentPath) componentDiffResult.HasDiff, componentDiffResult.DiffElements, componentDiffResult.DiffError = generateArgocdAppDiff(ctx, commentDiff, app, detailedProject.Project, resources, argoSettings, diffOption) - if componentDiffResult.AppWasTemporarilyCreated { + // only delete the temprorary app object if it was created and there was no error on diff + // otherwise let's keep it for investigation + if componentDiffResult.AppWasTemporarilyCreated && componentDiffResult.DiffError == nil { // Delete the temporary app object _, err = ac.app.Delete(ctx, &application.ApplicationDeleteRequest{Name: &app.Name, AppNamespace: &app.Namespace}) if err != nil { From 443c47c9c6eb6fd1e2b76b6a8e3d1cb4531948d5 Mon Sep 17 00:00:00 2001 From: Yazdan Mohammadi Date: Fri, 6 Sep 2024 18:41:42 +0200 Subject: [PATCH 2/2] Update the template --- templates/argoCD-diff-pr-comment.gotmpl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/argoCD-diff-pr-comment.gotmpl b/templates/argoCD-diff-pr-comment.gotmpl index d6745b8..95b5b8e 100644 --- a/templates/argoCD-diff-pr-comment.gotmpl +++ b/templates/argoCD-diff-pr-comment.gotmpl @@ -4,8 +4,12 @@ Diff of ArgoCD applications: {{if $appDiffResult.DiffError }} -⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️ -``` +⚠️ ⚠️ **Error getting diff from ArgoCD** (`{{ $appDiffResult.ComponentPath }}`) ⚠️ ⚠️ +Please check the App Conditions of **[{{ $appDiffResult.ArgoCdAppName }}]({{ $appDiffResult.ArgoCdAppURL }})** for more details. +{{- if $appDiffResult.AppWasTemporarilyCreated }} +⚠️ For investigation we kept the temporary application, please make sure to clean it up later! ⚠️ +{{- end}} +``` {{ $appDiffResult.DiffError }} ```