Skip to content

feat/refactor: Project Overhaul - Modernization, Robustness and v2-preview - #282

Open
SckyzO wants to merge 9 commits into
ClusterLabs:mainfrom
SckyzO:v2-preview
Open

feat/refactor: Project Overhaul - Modernization, Robustness and v2-preview#282
SckyzO wants to merge 9 commits into
ClusterLabs:mainfrom
SckyzO:v2-preview

Conversation

@SckyzO

@SckyzO SckyzO commented Jan 3, 2026

Copy link
Copy Markdown

Summary

This PR introduces a significant overhaul of the ha_cluster_exporter to bring it up to modern Go standards and improve its production reliability. It focuses on three main pillars: Robustness, Modularity, and Modernization. It also integrates critical bug fixes from pending upstream PRs.

Key Changes

1. Robustness & Reliability

  • Execution Timeouts: All external command executions (crm_mon, corosync, etc.) now use context.WithTimeout. This prevents the exporter from hanging indefinitely if a system tool becomes unresponsive. Default timeout is 10s, configurable via --collector.timeout.
  • Graceful Failure: The exporter no longer crashes if a collector's binary is missing at startup. It now logs a warning and continues, allowing functional collectors to serve metrics. Failing collectors report a success=0 metric.
  • Timezone Fix (PR Fix localtime parsing for config_last_change metric #280): Integrated fix for config_last_change metric parsing. It now correctly uses time.Local instead of forcing UTC, ensuring accurate timestamps in environments with local time settings.

2. Modularity

  • Selectable Collectors: Added flags to enable/disable specific collectors (e.g., --no-collector.drbd). This reduces resource usage and noise for clusters only using specific components.
  • Full Configuration Support: All new flags, including timeouts and collector toggles, are fully supported in the YAML configuration file.

3. Modernization & Architecture

  • Standard Go Layout: Restructured the project into standard cmd/ and internal/ directories following community best practices.
  • Go 1.24+: Updated the project to Go 1.24 and toolchain 1.24.11.
  • Structured Logging (slog): Migrated from go-kit/log to the standard library log/slog for modern, structured logging. Included a compatibility adapter for the Prometheus exporter-toolkit.
  • Standard Errors: Replaced the deprecated pkg/errors dependency with native Go error wrapping (fmt.Errorf with %w).
  • Clean CLI: Removed several long-deprecated flags (--address, --port, etc.) to simplify the codebase.

4. Tooling & DX

  • Dockerfile: Added a modern multi-stage Dockerfile using Alpine and Go 1.24.11.
  • Makefile: Optimized build targets and added make docker, make lint and improved promu integration.
  • Unit Tests: Fully updated and stabilized the test suite. Forced UTC in Pacemaker tests to ensure deterministic results across different development machines.

Breaking Changes

  • Project structure has changed (internal logic moved to internal/).
  • Removed deprecated flags: --address, --port, --log-level, --enable-timestamps.
  • Minimum Go version is now 1.24.

@SckyzO

SckyzO commented Feb 9, 2026

Copy link
Copy Markdown
Author

Hello @stefanotorresi

What do you think of my PR ?

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.

1 participant