Add logging to debug CI config local file fetch failures

What does this MR do and why?

Add logging to debug CI config local file fetch failures

This adds structured logging to help debug intermittent 'Local file .gitlab-ci.yml does not exist!' errors that seem to be occurring in distributed Gitaly/Praefect setups.

Logging Strategy

Based on discussion in the RFH, this MR implements feature-flag-gated logging following the pattern used by expanded_ai_logging:

  • Failure signals (always logged at warn level):

    • Missing blobs from Gitaly response
    • GRPC errors during blob fetch
    • Nil content when validating local file
  • Verbose tracing (gated by ci_config_local_file_verbose_logging feature flag):

    • Request details before fetching blobs
    • Successful response details

This allows operators to selectively enable detailed logging for specific projects experiencing the issue, without adding noise to all instances.

Related to: #336789

Changelog: other

References

How to set up and validate locally

  1. Enable verbose logging for a specific project:

    Feature.enable(:ci_config_local_file_verbose_logging, Project.find(123))
  2. Create a pipeline with local includes and check log/application.log:

    • With flag disabled: only warn logs appear for failures (missing blobs, GRPC errors, nil content)
    • With flag enabled: info logs appear for all request/response cycles
  3. To enable globally (e.g., for debugging on a specific instance):

    Feature.enable(:ci_config_local_file_verbose_logging)
  4. To disable:

    Feature.disable(:ci_config_local_file_verbose_logging)

Example log output

When a local file is missing (always logged):

{
  "severity": "WARN",
  "message": "CI config: Blobs fetched from Gitaly - missing paths detected",
  "project_id": 123,
  "sha": "abc123",
  "missing_paths": [".gitlab-ci.yml"],
  "missing_count": 1,
  "repository_storage": "default",
  "gitaly_storage_name": "default"
}

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sahil Sharma

Merge request reports

Loading