Skip to content

fix: skip NoRows error logs for Argo CD status updates of unmanaged apps (#7095) - #7098

Open
prakash100198 wants to merge 1 commit into
developfrom
fix/argo-unmanaged-app-norows-logs-oss
Open

prakash100198 wants to merge 1 commit into
developfrom
fix/argo-unmanaged-app-norows-logs-oss

Conversation

@prakash100198

@prakash100198 prakash100198 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #7095

Enterprise counterpart (identical diff): https://github.com/devtron-labs/devtron-enterprise/pull/3453

Argo CD sends a status event for every application it manages, including ones Devtron doesn't manage (no CD pipeline and no installed chart with that name). Devtron correctly skips those updates, but it logged two error-level entries for every one of them:

error while fetching installed app by GitOps app name   error: pg: no rows in result set
no installed apps found                                  err: pg: no rows in result set

On clusters with Argo CD apps outside Devtron, this fills the orchestrator log with false errors on every sync or refresh.

Cause: for an unmanaged app, the installed-app lookup by GitOps app name returns pg.ErrNoRows, which is the expected result. InstalledAppReadService.GetInstalledAppByGitOpsAppName logged every lookup error at error level. The APPLICATION_STATUS_UPDATE handler then logged the same pg.ErrNoRows at error level again before returning.

Fix:

  • pkg/appStore/installedApp/read/InstalledAppReadService.go: GetInstalledAppByGitOpsAppName no longer logs pg.ErrNoRows (matched with errors.Is). It still returns (nil, err) unchanged, so every caller keeps its own no-rows handling. Other lookup errors (DB connection failure, multiple rows, …) are still logged at error level.
  • pkg/eventProcessor/in/DeployedApplicationEventProcessorService.go: the status update handler matches no rows with errors.Is and logs a debug line with the app name, then skips the update as before.

Behaviour that does not change:

  • Managed apps (Devtron CD pipelines deployed via Argo CD, and charts installed via Argo CD) are processed exactly as before.
  • A failing installed-app lookup still logs at error level, and the event is still dropped.
  • The other caller of GetInstalledAppByGitOpsAppName, external Argo CD app link validation (ValidateIfAcdAppAlreadyLinked), already treats no rows as "not linked". Its API responses are unchanged; it only stops logging the same false error.

How Has This Been Tested?

New unit test pkg/appStore/installedApp/read/InstalledAppReadService_test.go for GetInstalledAppByGitOpsAppName:

  • Installed app found: mapped result returned, no error log
  • pg.ErrNoRows, and pg.ErrNoRows wrapped with %w: error returned unchanged, no error log
  • DB connection failure and pg.ErrMultiRows: error returned unchanged, error log with the app name

On develop the same test fails only on the two no-rows cases.

End to end: a develop build and a build with this change ran against the same seeded Postgres and a local NATS. Argo CD ApplicationDetail events were published to APPLICATION_STATUS_UPDATE, and the link validation API (POST /orchestrator/app/cd-pipeline/validate-link-request) was called.

  • Unmanaged Argo CD app, 3 consecutive status updates: 2 error logs per event on develop, 1 debug line with this change
  • Name of an uninstalled chart (installed_apps.active=false), of a chart on an inactive environment, and of a deleted CD pipeline: same result as above
  • Managed chart deployed via Argo CD (Progressing → Healthy): version history moves to Succeeded, timelines and app status written. Identical on both builds.
  • Managed Devtron app CD pipeline (Argo CD): workflow runner moves to Succeeded and the deployment success event is handled. Identical on both builds.
  • installed_apps lookup failing (table made unavailable): error logs and early return. Identical on both builds.
  • Malformed payload, and event without an application: identical on both builds
  • Link validation for an unmanaged app, an app already installed as a chart, an app already linked to a pipeline, and a failing lookup: identical API responses on both builds; the unmanaged case logs one error fewer

Across all cases, the only log differences are the two removed error lines and the added debug line, and the final database state is identical.

The tests above ran on the enterprise build, which contains these two files with the identical diff and the identical test file. This branch was not compiled locally.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

Argo CD status updates for applications not managed by Devtron no longer produce error logs in the orchestrator.

🤖 Generated with Claude Code

Argo CD status events for applications with no Devtron CD pipeline or
installed chart logged two error-level pg.ErrNoRows entries per update.
No rows is the expected lookup result there, so log it at debug level
and keep error logging for real lookup failures.

Fixes #7095

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bito-code-review

Copy link
Copy Markdown

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews. To trigger review, type /review in the comment and save. You can change the settings here, or contact the agent instance creator at shivam@devtron.ai.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant