Skip to content

fix/opv2-feedback - #315

Open
collinol wants to merge 3 commits into
mainfrom
fix/opv2-feedback
Open

fix/opv2-feedback#315
collinol wants to merge 3 commits into
mainfrom
fix/opv2-feedback

Conversation

@collinol

@collinol collinol commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

mapClickHouse now takes the full values map and is called from applyValueMappings alongside the other peer-of-global mappers

  • Reads install from both locations, subchart section winning: clickhouse.install, then global.clickhouse.install.
  • install: false → asserts external. Connection fields resolve per-field from global.clickhouse first (the app-facing connection), falling back to the top-level clickhouse: section. An empty value in the first source falls through to the second rather than counting as set.
  • install: true → returns early, leaving the spec empty so the defaulter makes it managed. This fixes the third row of the table I sent: previously install: true plus a global.clickhouse.host pointing at the chart's own ClickHouse would assert externalClickHouse at a service that won't exist post-cutover.
  • install: false with no connection anywhere → hard error naming the keys it looked for and telling you to set externalClickhouse explicitly.
  • install parsing is lenient on type (accepts false and "false"); anything uninterpretable is treated as unset rather than erroring, so a stringly-typed flag can't make a v1 object unservable — same principle as the existing comment in overrides.go:144.

Summary by CodeRabbit

  • Bug Fixes
    • Improved ClickHouse configuration conversion from both global and top-level settings.
    • Added clear precedence and fallback handling for connection fields and password secrets.
    • Correctly interprets installation flags, including string-form boolean values.
    • External ClickHouse configurations now report a helpful error when connection details are missing.
    • Added validation for invalid configuration values and expanded conversion coverage.

@collinol
collinol marked this pull request as ready for review August 5, 2026 19:26
@collinol
collinol requested a review from a team as a code owner August 5, 2026 19:26
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@collinol, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: da77a682-19ad-46dd-8a93-62d3a3be51ba

📥 Commits

Reviewing files that changed from the base of the PR and between 7a81151 and a4fcc62.

📒 Files selected for processing (1)
  • api/v1/weightsandbiases_conversion_mapping.go
📝 Walkthrough

Walkthrough

The ClickHouse conversion flow now reads global and top-level settings, applies global precedence with connection fallback, interprets install flags, and reports missing external connection data. Tests cover these source and install behaviors.

Changes

ClickHouse conversion

Layer / File(s) Summary
ClickHouse source resolution and install handling
api/v1/weightsandbiases_conversion_mapping.go
The top-level conversion invokes mapClickHouse. The mapper combines global and top-level ClickHouse values, applies connection fallback and password secret handling, parses install flags, and validates external configurations.
Conversion behavior coverage
api/v1/weightsandbiases_conversion_test.go
Tests cover top-level discovery, global precedence, boolean and string install values, missing external connections, and non-boolean fallback behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TopLevelConversion
  participant mapClickHouse
  participant global.clickhouse
  participant clickhouse
  TopLevelConversion->>mapClickHouse: map ClickHouse settings
  mapClickHouse->>global.clickhouse: read global values
  mapClickHouse->>clickhouse: read fallback values
  mapClickHouse-->>TopLevelConversion: converted spec or connection error
Loading

Possibly related PRs

  • wandb/operator#299: Introduced the ClickHouse v1-to-v2 conversion that this change extends.

Suggested reviewers: wnevis-cmyk

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title indicates a fix related to operator v2 feedback but does not identify the ClickHouse mapping changes. Use a specific title such as "Fix operator v2 ClickHouse value mapping".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/opv2-feedback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
api/v1/weightsandbiases_conversion_test.go (1)

2054-2074: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add explicit empty-value fallback coverage.

This test covers an omitted global user value. It does not cover a global field set to "". Add a case where global.clickhouse.host is empty and clickhouse.host is non-empty. Assert that the top-level value supplies host.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/v1/weightsandbiases_conversion_test.go` around lines 2054 - 2074, Add an
explicit empty-value fallback case to
TestConvertTo_ClickHouseGlobalWinsOverTopLevel by setting global.clickhouse.host
to an empty string and clickhouse.host to a non-empty value, then assert the
pending annotation uses the top-level host while preserving the existing
per-field precedence assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/v1/weightsandbiases_conversion_mapping.go`:
- Around line 674-682: Update firstClickHouseInstallFlag to reject numeric
scalar values before calling strconv.ParseBool, so only declared boolean
true/false values set the install flag. Preserve the existing handling for valid
booleans and add coverage confirming numeric values such as 0 and 1 leave the
flag unset.

In `@api/v1/weightsandbiases_conversion_test.go`:
- Around line 2009-2137: Move all added TestConvertTo_ClickHouse* cases into the
configured Ginkgo suite, replacing standalone testing.T functions with the
suite’s established Describe/It structure. Convert every Testify require
assertion to equivalent Gomega matchers and preserve the existing test scenarios
and expectations.

---

Nitpick comments:
In `@api/v1/weightsandbiases_conversion_test.go`:
- Around line 2054-2074: Add an explicit empty-value fallback case to
TestConvertTo_ClickHouseGlobalWinsOverTopLevel by setting global.clickhouse.host
to an empty string and clickhouse.host to a non-empty value, then assert the
pending annotation uses the top-level host while preserving the existing
per-field precedence assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fefd5cf-4e76-4b04-b1be-d4305655389c

📥 Commits

Reviewing files that changed from the base of the PR and between db6e8d9 and 7a81151.

📒 Files selected for processing (2)
  • api/v1/weightsandbiases_conversion_mapping.go
  • api/v1/weightsandbiases_conversion_test.go

Comment on lines +674 to +682
s, isScalar := scalarToString(raw)
if !isScalar {
continue
}
parsed, parseErr := strconv.ParseBool(s)
if parseErr != nil {
continue
}
return parsed, true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect which scalar types can reach strconv.ParseBool.
rg -n -C 8 '^func scalarToString\b|scalarToString\(' api/v1

# Inspect current install-flag coverage and numeric fixtures.
rg -n -C 4 'firstClickHouseInstallFlag|ClickHouseInstall.*NonBool|"install": (0|1)' \
  api/v1/weightsandbiases_conversion_test.go \
  api/v1/weightsandbiases_conversion_mapping.go

Repository: wandb/operator

Length of output: 9308


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- mapping excerpts ---\n'
sed -n '665,682p;882,910p' api/v1/weightsandbiases_conversion_mapping.go

printf '\n--- install non-bool test excerpt ---\n'
sed -n '2126,2165p' api/v1/weightsandbiases_conversion_test.go

printf '\n--- parser behavior probe ---\n'
python3 - <<'PY'
valid = {"true", "false", "1", "0"}
values = ["true", "false", "1", "0", "2", "nonsense"]
print("strconv.ParseBool accepted:", *values[:])
for s in values:
    print(f"{s!r}: {s in valid}")
PY

Repository: wandb/operator

Length of output: 243


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- mapping excerpts ---'
sed -n '665,682p;882,910p' api/v1/weightsandbiases_conversion_mapping.go

printf '%s\n' ''
printf '%s\n' '--- install non-bool test excerpt ---'
sed -n '2126,2165p' api/v1/weightsandbiases_conversion_test.go

printf '%s\n' ''
printf '%s\n' '--- parser behavior probe ---'
python3 - <<'PY'
valid = {"true", "false", "1", "0"}
values = ["true", "false", "1", "0", "2", "nonsense"]
print("strconv.ParseBool accepted:", ", ".join(values))
for s in values:
    print(f"{s!r}: {s in valid}")
PY

Repository: wandb/operator

Length of output: 2267


Reject numeric ClickHouse install scalars before parsing.

scalarToString renders JSON numbers as strings such as "0" and "1", so firstClickHouseInstallFlag can return install: 1 as enabled. Keep the declared behavior that only true/false set the flag, and add coverage for numeric values remaining unset.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/v1/weightsandbiases_conversion_mapping.go` around lines 674 - 682, Update
firstClickHouseInstallFlag to reject numeric scalar values before calling
strconv.ParseBool, so only declared boolean true/false values set the install
flag. Preserve the existing handling for valid booleans and add coverage
confirming numeric values such as 0 and 1 leave the flag unset.

Comment on lines +2009 to +2137
func TestConvertTo_ClickHouseTopLevelSectionConnection(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{
"install": false,
"host": "ch.example.com",
"database": "wandb",
"password": map[string]interface{}{
"valueFrom": map[string]interface{}{
"secretKeyRef": map[string]interface{}{
"name": "ch-secret",
"key": "password",
},
},
},
},
})
require.NoError(t, src.ConvertTo(dst))

conn := dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse
require.NotNil(t, conn, "install=false must assert an external clickhouse")
require.Equal(t, "ch-secret", conn.Password.Name)
require.Equal(t, "password", conn.Password.Key)

var pending map[string]string
require.NoError(t, json.Unmarshal([]byte(dst.Annotations[ClickHousePendingAnnotation]), &pending))
require.Equal(t, "ch.example.com", pending["host"])
require.Equal(t, "wandb", pending["database"])
}

// TestConvertTo_ClickHouseInstallFalseGlobalConnection: install lives in the
// subchart section while the connection lives under global.
func TestConvertTo_ClickHouseInstallFalseGlobalConnection(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{"install": false},
"global": map[string]interface{}{
"clickhouse": map[string]interface{}{"host": "ch.example.com"},
},
})
require.NoError(t, src.ConvertTo(dst))

require.NotNil(t, dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse)
}

// TestConvertTo_ClickHouseGlobalWinsOverTopLevel: global.clickhouse is the
// app-facing connection, so it takes precedence per field.
func TestConvertTo_ClickHouseGlobalWinsOverTopLevel(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{
"install": false,
"host": "subchart.example.com",
"user": "subchart-user",
},
"global": map[string]interface{}{
"clickhouse": map[string]interface{}{"host": "global.example.com"},
},
})
require.NoError(t, src.ConvertTo(dst))

var pending map[string]string
require.NoError(t, json.Unmarshal([]byte(dst.Annotations[ClickHousePendingAnnotation]), &pending))
require.Equal(t, "global.example.com", pending["host"], "global.clickhouse wins")
require.Equal(t, "subchart-user", pending["user"], "subchart fills what global omits")
}

// TestConvertTo_ClickHouseInstallTrueStaysManaged: v1 owned ClickHouse, so the
// spec is left empty for the defaulter even though a connection is present.
func TestConvertTo_ClickHouseInstallTrueStaysManaged(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{"install": true},
"global": map[string]interface{}{
"clickhouse": map[string]interface{}{
"host": "clickhouse.default.svc.cluster.local",
"user": "wandb",
},
},
})
require.NoError(t, src.ConvertTo(dst))

require.Empty(t, dst.Spec.ClickHouse,
"install=true must not assert external; the defaulter makes it managed")
require.NotContains(t, dst.Annotations, ClickHousePendingAnnotation)
}

// TestConvertTo_ClickHouseInstallFalseNoConnectionFails: falling through to the
// defaulter here would silently provision managed ClickHouse.
func TestConvertTo_ClickHouseInstallFalseNoConnectionFails(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{
"install": false,
"replicated": true,
},
})
err := src.ConvertTo(dst)
require.Error(t, err)
require.Contains(t, err.Error(), "install=false but no connection found")
}

// TestConvertTo_ClickHouseInstallStringBool: helm values are frequently
// stringly-typed; "false" must behave like false.
func TestConvertTo_ClickHouseInstallStringBool(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{
"install": "false",
"host": "ch.example.com",
},
})
require.NoError(t, src.ConvertTo(dst))

require.NotNil(t, dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse)
}

// TestConvertTo_ClickHouseInstallNonBoolIsUnset: an uninterpretable flag must
// not make a v1 object unservable; it falls back to connection presence.
func TestConvertTo_ClickHouseInstallNonBoolIsUnset(t *testing.T) {
dst := &appsv2.WeightsAndBiases{}
src := newV1(map[string]interface{}{
"clickhouse": map[string]interface{}{
"install": map[string]interface{}{"nested": "nonsense"},
},
})
require.NoError(t, src.ConvertTo(dst))
require.Empty(t, dst.Spec.ClickHouse)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the configured Ginkgo/Gomega suites and their setup patterns.
fd 'suite_test\.go$|go\.mod$' .
rg -n -C 3 'RunSpecs|RegisterFailHandler|ginkgo|gomega' \
  --glob '*.go' --glob 'go.mod'

Repository: wandb/operator

Length of output: 1110


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Changed file candidates:\n'
git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$|suite_test\.go$' || true

printf '\nFile stats:\n'
wc -l $(git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$|suite_test\.go$' || true) | tail -20

printf '\nImports and test style in weightsandбиases_conversion_test.go:\n'
file=$(git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$' | head -1)
if [ -n "${file:-}" ]; then
  sed -n '1,80p' "$file"
  printf '\nFunction declarations in file:\n'
  rg -n '^\s*func\s+Test|Describe|Context|It|When|Ginkgo|Gomega|require|assert' "$file" || true
fi

printf '\nRelevant suite_test.go examples:\n'
for f in internal/controller/common/common_suite_test.go internal/controller/suite_test.go internal/webhook/v2/webhook_suite_test.go; do
  if [ -f "$f" ]; then
    echo "--- $f"
    sed -n '1,140p' "$f"
  fi
done

Repository: wandb/operator

Length of output: 46687


Move the added ClickHouse conversion cases into a Ginkgo/Gomega suite.

TestConvertTo_ClickHouse* uses direct func Test... *testing.T functions and Testify require... assertions. Add the cases to the configured Ginkbo/Gomega suite and use Gomega assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/v1/weightsandbiases_conversion_test.go` around lines 2009 - 2137, Move
all added TestConvertTo_ClickHouse* cases into the configured Ginkgo suite,
replacing standalone testing.T functions with the suite’s established
Describe/It structure. Convert every Testify require assertion to equivalent
Gomega matchers and preserve the existing test scenarios and expectations.

Source: Coding guidelines

@w-b-hivemind

w-b-hivemind Bot commented Aug 6, 2026

Copy link
Copy Markdown

HiveMind Sessions

1 session · 31m · $5.86

Session Agent Duration Tokens Cost Lines
V1 To Operator V2 Migration Diagram
ba9040dd-877f-4464-8053-d8d9b926b8c1
claude 31m 72.4K $5.86 +308 -104
Total 31m 72.4K $5.86 +308 -104

View all sessions in HiveMind →

Run claude --resume ba9040dd-877f-4464-8053-d8d9b926b8c1 to pickup where you left off.

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