refactor: drop MetricsConfig from ToolchainStatus type#1245
Conversation
also, remove all calls to `ForceSynchronization()` from the tests Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRemoved metrics fields from CRDs and the ToolchainConfig metrics API, updated tests to use map[string]int for metric assertions and removed related test cases, and bumped internal toolchain module versions in go.mod. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/metrics/metrics.go (1)
37-40: Validate activation/domain key format before callingWithLabelValues.Using
strings.Split(key, ",")...can pass an invalid label count and panic, which obscures the test failure cause. Parse and validate the composite key before asserting the gauge.Suggested patch
func (a *MetricAssertion) HaveUsersPerActivationsAndDomain(expected map[string]int) *MetricAssertion { for key, count := range expected { - metricscommontest.AssertMetricsGaugeEquals(a.t, count, metrics.UserSignupsPerActivationAndDomainGaugeVec.WithLabelValues(strings.Split(key, ",")...), "invalid gauge value for key '%v'", key) + activation, domain, found := strings.Cut(key, ",") + require.Truef(a.t, found && activation != "" && domain != "" && !strings.Contains(domain, ","), "invalid key format '%s': expected '<activation>,<domain>'", key) + metricscommontest.AssertMetricsGaugeEquals(a.t, count, metrics.UserSignupsPerActivationAndDomainGaugeVec.WithLabelValues(activation, domain), "invalid gauge value for key '%v'", key) } return a }As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/metrics/metrics.go` around lines 37 - 40, In HaveUsersPerActivationsAndDomain, validate and parse the composite key before calling metrics.UserSignupsPerActivationAndDomainGaugeVec.WithLabelValues: split the key using strings.SplitN(key, ",", 2), trim spaces, ensure you get the exact number of labels expected (e.g., 2 parts: activation and domain), and if not, call a test failure (t.Fatalf/t.Errorf) with a clear message referencing the offending key; only then pass the validated parts to WithLabelValues and call metricscommontest.AssertMetricsGaugeEquals.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@go.mod`:
- Line 6: The go.mod currently pins a personal-fork or PR ref (e.g., the module
line "github.com/codeready-toolchain/toolchain-common
v0.0.0-20260225205316-85e4bef507f2" and associated replace directives
referencing refs/pull/500/head and refs/pull/520/head) which ties the build to
open upstream PR commits; remove or replace these temporary replace directives
and module pins with either the canonical released module version or wait and
update to the upstream PR merge commit, or explicitly document these
replacements as development-only in a comment and developer-facing README;
ensure any replace lines referencing those PR refs are reverted so CI/builds do
not depend on unstable PR refs.
---
Nitpick comments:
In `@test/metrics/metrics.go`:
- Around line 37-40: In HaveUsersPerActivationsAndDomain, validate and parse the
composite key before calling
metrics.UserSignupsPerActivationAndDomainGaugeVec.WithLabelValues: split the key
using strings.SplitN(key, ",", 2), trim spaces, ensure you get the exact number
of labels expected (e.g., 2 parts: activation and domain), and if not, call a
test failure (t.Fatalf/t.Errorf) with a clear message referencing the offending
key; only then pass the validated parts to WithLabelValues and call
metricscommontest.AssertMetricsGaugeEquals.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bdc6fa97-a780-4436-b98f-1d6b25ffd99d
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (9)
config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yamlconfig/crd/bases/toolchain.dev.openshift.com_toolchainstatuses.yamlcontrollers/masteruserrecord/masteruserrecord_controller_test.gocontrollers/toolchainconfig/configuration.gocontrollers/toolchainconfig/configuration_test.gocontrollers/usersignup/usersignup_controller_test.gogo.modpkg/metrics/metrics_test.gotest/metrics/metrics.go
💤 Files with no reviewable changes (4)
- controllers/toolchainconfig/configuration_test.go
- controllers/toolchainconfig/configuration.go
- config/crd/bases/toolchain.dev.openshift.com_toolchainstatuses.yaml
- config/crd/bases/toolchain.dev.openshift.com_toolchainconfigs.yaml
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MatousJobanek, rajivnathan, xcoulon The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Co-authored-by: Rajiv Senthilnathan <rsenthil@redhat.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
controllers/masteruserrecord/masteruserrecord_controller_test.go (1)
289-292:⚠️ Potential issue | 🟠 MajorFix gofmt failure at Line 289 before merge.
Line 289 indentation is not gofmt-compliant, and CI is already failing on this exact line.
Proposed formatting fix
-mur := murtest.NewMasterUserRecord(t, "john", + mur := murtest.NewMasterUserRecord(t, "john", murtest.WithOwnerLabel("john-123"), murtest.StatusUserAccount(commontest.MemberClusterName), murtest.Finalizer("finalizer.toolchain.dev.openshift.com"))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@controllers/masteruserrecord/masteruserrecord_controller_test.go` around lines 289 - 292, The test instantiation of mur := murtest.NewMasterUserRecord(...) is misindented causing gofmt to fail; reformat the call so the continuation lines are aligned (each argument indented with a tab) or simply run gofmt/gofmt -w on the file to fix indentation for the NewMasterUserRecord call and its option lines (murtest.WithOwnerLabel, murtest.StatusUserAccount, murtest.Finalizer) so the arguments line up correctly under murtest.NewMasterUserRecord.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@controllers/masteruserrecord/masteruserrecord_controller_test.go`:
- Around line 289-292: The test instantiation of mur :=
murtest.NewMasterUserRecord(...) is misindented causing gofmt to fail; reformat
the call so the continuation lines are aligned (each argument indented with a
tab) or simply run gofmt/gofmt -w on the file to fix indentation for the
NewMasterUserRecord call and its option lines (murtest.WithOwnerLabel,
murtest.StatusUserAccount, murtest.Finalizer) so the arguments line up correctly
under murtest.NewMasterUserRecord.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cb74ba0a-970e-4c4a-b632-06c574697a7b
📒 Files selected for processing (1)
controllers/masteruserrecord/masteruserrecord_controller_test.go
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
|


also, remove all calls to
ForceSynchronization()from the testssee also:
and also:
Signed-off-by: Xavier Coulon xcoulon@redhat.com
Summary by CodeRabbit
Bug Fixes
Chores
Tests