Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@flemzord
Copy link
Member

@flemzord flemzord commented Oct 6, 2025

Summary

This PR removes the Analytics CRD and all related code, as it has never been used in production.

Motivation

The Analytics CRD was introduced but never actually implemented or utilized. Removing this unused code:

  • Reduces maintenance burden
  • Simplifies the codebase
  • Eliminates confusion for developers
  • Reduces the number of CRDs to manage

Changes

Removed Files

  • api/formance.com/v1beta1/analytics_types.go - Analytics CRD type definitions
  • internal/resources/analytics/init.go - Analytics reconciler (empty implementation)
  • config/crd/bases/formance.com_analytics.yaml - CRD manifest
  • config/rbac/formance.com_analytics_*.yaml - RBAC roles (editor/viewer)
  • config/samples/formance.com_v1beta1_analytics.yaml - Sample configuration
  • helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_analytics.formance.com.yaml - Helm CRD template

Code Changes

  • internal/resources/all.go: Removed Analytics package import
  • internal/resources/ledgers/init.go: Removed Analytics watch dependency
  • internal/resources/ledgers/deployments.go: Removed Analytics-based EMIT_LOGS environment variable logic
  • api/formance.com/v1beta1/zz_generated.deepcopy.go: Regenerated without Analytics types
  • config/rbac/role.yaml: Regenerated RBAC manifest

Testing

Compilation

go build -o bin/manager ./cmd/main.go  # ✅ Success

Manifests Generation

make generate && make manifests  # ✅ Success

Breaking Changes

⚠️ CRD Removal: The Analytics CRD will be removed.

Impact Assessment: None expected, as this CRD was never used in production. No existing Analytics resources should exist in any environment.

Migration Notes

If for any reason Analytics resources exist in a cluster (highly unlikely):

  1. List any existing Analytics resources: kubectl get analytics --all-namespaces
  2. Delete them before upgrading: kubectl delete analytics --all --all-namespaces
  3. The CRD will be automatically removed when the operator is upgraded

Benefits

Reduced complexity: One less CRD to maintain
Cleaner codebase: Removed ~700 lines of unused code
Better clarity: No confusion about unused features
Easier maintenance: Fewer resources to manage and update

@flemzord flemzord requested a review from a team as a code owner October 6, 2025 11:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 6, 2025

Walkthrough

This change removes the v1beta1 Analytics CRD and its generated deepcopy methods, deletes the analytics module initializer and its resource import, removes Ledger’s watch dependency on Analytics, and removes the Ledger code that injected EMIT_LOGS based on Analytics readiness.

Changes

Cohort / File(s) Summary
Remove Analytics CRD types
api/formance.com/v1beta1/analytics_types.go
Deleted Analytics, AnalyticsSpec, AnalyticsStatus, AnalyticsList, related methods, kubebuilder markers, and scheme registration.
Remove Analytics deepcopy methods
api/formance.com/v1beta1/zz_generated.deepcopy.go
Deleted DeepCopy/DeepCopyInto/DeepCopyObject for Analytics, AnalyticsList, AnalyticsSpec, AnalyticsStatus; other types unchanged.
Remove analytics resource module
internal/resources/analytics/init.go, internal/resources/all.go
Deleted analytics module initializer and removed analytics import from aggregated resources registry.
Ledger: drop Analytics coupling
internal/resources/ledgers/deployments.go, internal/resources/ledgers/init.go
Removed EMIT_LOGS env injection conditioned on Analytics readiness and removed Ledger watch dependency on v1beta1.Analytics.
PROJECT file
PROJECT
Removed public API resource declaration for kind Analytics (group: formance.com, version: v1beta1).
Docs
docs/09-Configuration reference/02-Custom Resource Definitions.md
Removed Analytics module documentation and related type/field tables.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Operator
  participant LedgerReconciler as Ledger Reconciler
  participant Builder as Ledger Deployment Builder
  participant K8s as Kubernetes API

  rect rgb(245,245,255)
  note over LedgerReconciler,Builder: Previous (with Analytics dependency)
  Operator->>LedgerReconciler: Reconcile Ledger
  LedgerReconciler->>Builder: createLedgerContainerFull(...)
  Builder->>K8s: Check Analytics dependency status
  alt Analytics ready
    Builder->>Builder: Append env EMIT_LOGS=true
  else Not ready/absent
    Builder->>Builder: No EMIT_LOGS
  end
  Builder-->>LedgerReconciler: Deployment spec
  end

  rect rgb(245,255,245)
  note over LedgerReconciler,Builder: Now (Analytics removed)
  Operator->>LedgerReconciler: Reconcile Ledger
  LedgerReconciler->>Builder: createLedgerContainerFull(...)
  note right of Builder: No Analytics check<br/>No EMIT_LOGS injection
  Builder-->>LedgerReconciler: Deployment spec
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibbled the vines where Analytics grew,
Snip-snap, the tendrils—gone from view.
Ledger hops lighter, fewer checks to do,
No logs to emit when carrots are few.
Ears up, I commit—clean paths, swift throughput. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title succinctly captures the main change of removing the unused Analytics CRD without extraneous detail, using clear and concise language that aligns directly with the changeset.
Description Check ✅ Passed The pull request description clearly outlines the removal of the Analytics CRD and all related code, detailing motivations, file and code changes, testing steps, breaking changes, and migration notes, directly reflecting the actual changes in the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-unused-analytics-crd

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 39e5280 and d43dca0.

⛔ Files ignored due to path filters (9)
  • config/crd/bases/formance.com_analytics.yaml is excluded by !**/*.yaml
  • config/crd/kustomization.yaml is excluded by !**/*.yaml
  • config/rbac/formance.com_analytics_editor_role.yaml is excluded by !**/*.yaml
  • config/rbac/formance.com_analytics_viewer_role.yaml is excluded by !**/*.yaml
  • config/rbac/role.yaml is excluded by !**/*.yaml
  • config/samples/formance.com_v1beta1_analytics.yaml is excluded by !**/*.yaml
  • config/samples/kustomization.yaml is excluded by !**/*.yaml
  • helm/crds/templates/crds/apiextensions.k8s.io_v1_customresourcedefinition_analytics.formance.com.yaml is excluded by !**/*.yaml
  • helm/operator/templates/gen/rbac.authorization.k8s.io_v1_clusterrole_formance-manager-role.yaml is excluded by !**/gen/**, !**/*.yaml, !**/gen/**
📒 Files selected for processing (8)
  • PROJECT (0 hunks)
  • api/formance.com/v1beta1/analytics_types.go (0 hunks)
  • api/formance.com/v1beta1/zz_generated.deepcopy.go (0 hunks)
  • docs/09-Configuration reference/02-Custom Resource Definitions.md (0 hunks)
  • internal/resources/all.go (0 hunks)
  • internal/resources/analytics/init.go (0 hunks)
  • internal/resources/ledgers/deployments.go (0 hunks)
  • internal/resources/ledgers/init.go (0 hunks)
💤 Files with no reviewable changes (8)
  • internal/resources/analytics/init.go
  • docs/09-Configuration reference/02-Custom Resource Definitions.md
  • PROJECT
  • api/formance.com/v1beta1/analytics_types.go
  • internal/resources/ledgers/init.go
  • internal/resources/ledgers/deployments.go
  • internal/resources/all.go
  • api/formance.com/v1beta1/zz_generated.deepcopy.go

Comment @coderabbitai help to get the list of available commands and usage tips.

gfyrag
gfyrag previously approved these changes Oct 6, 2025
@flemzord flemzord changed the title Remove unused Analytics CRD feat: Remove unused Analytics CRD Oct 6, 2025
@flemzord flemzord force-pushed the remove-unused-analytics-crd branch from 39e5280 to b2166ab Compare October 6, 2025 12:02
Remove the Analytics CRD and all related code as it has never been used.

Changes:
- Remove Analytics CRD types and generated code
- Remove Analytics resource reconciler
- Remove Analytics CRD manifests and RBAC roles
- Remove Analytics sample configuration
- Remove Analytics Helm CRD template
- Remove Analytics watch dependency from Ledger
- Remove Analytics-based EMIT_LOGS environment variable logic from Ledger
- Update generated deepcopy code
- Update RBAC role manifests

The Analytics CRD was introduced but never actually implemented or used
in production. This cleanup reduces maintenance burden and simplifies
the codebase.
@flemzord flemzord force-pushed the remove-unused-analytics-crd branch from b2166ab to d43dca0 Compare October 6, 2025 12:04
@flemzord flemzord enabled auto-merge (squash) October 6, 2025 12:17
@flemzord flemzord requested a review from gfyrag October 6, 2025 12:17
@flemzord flemzord merged commit 4063c02 into main Oct 6, 2025
6 checks passed
@flemzord flemzord deleted the remove-unused-analytics-crd branch October 6, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants