[registry] Fix unordered completion logs during concurrent model generation - #1051
[registry] Fix unordered completion logs during concurrent model generation#1051KumarNirupam1 wants to merge 6 commits into
Conversation
Signed-off-by: Kumar Nirupam <kumar.nirupam24@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request refactors logging statements in registry/model.go to combine multiple log calls into single formatted log statements using fmt.Sprintf inside Log.Info. The reviewer suggests using Log.Infof directly instead of nesting fmt.Sprintf inside Log.Info to make the code more idiomatic in Go.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@YASHMAHAKAL @aabidsofi19 kindly review |
There was a problem hiding this comment.
Pull request overview
This PR fixes confusing, interleaved completion output during concurrent mesheryctl registry generate runs by ensuring each model’s “completion” message is emitted as a single log line (so goroutines can’t split related messages across multiple lines on stdout).
Changes:
- Consolidated the two-line “Current model …” + “Extracted … components …” completion logs into a single
Log.Info(...)call in the spreadsheet-driven generation path. - Applied the same single-line completion logging pattern in the Meshery registrant generation path, including the “no change in components” case.
|
Yay! @KumarNirupam1 be sure to demo this on this week's meeting. |
okay 👍 |
Maanvi212006
left a comment
There was a problem hiding this comment.
Verified this locally, not just from reading the diff.
- Wrote a quick script simulating 20 concurrent goroutines logging completions — old way (two separate calls) gave 120 interleaved/mismatched lines across 50 trials, new way (one combined call) gave 0. Fix works.
- Tests pass, build is clean.
Two things to flag:
- No test covers this specific fix — add one that checks for split lines under concurrent load.
- +1 to Gemini's suggestion — use
Log.Infof(...)instead ofLog.Info(fmt.Sprintf(...)).
Otherwise good fix, correctly scoped.
Signed-off-by: Kumar Nirupam <kumar.nirupam24@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change consolidates model-generation logs into single formatted messages. A concurrent test verifies one complete log line per model with the extracted-component count. ChangesModel-generation logging
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Hi @Maanvi212006, thanks for the review.
It passes, including with -race.
The full end-to-end concurrent run needs real spreadsheets/ArtifactHub/registrant APIs plus networkaccess, so that level of test isn't feasible in meshkit's unit tests. Once this PR is merged andmeshery bumps meshkit, I'll add the E2E test in the meshery repo for meshery/meshery#11036, asmentioned in the PR description. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@registry/model_generation_test.go`:
- Around line 287-290: Capture the existing package logger in origLog before
assigning the test logger in the setup around Log and SetupLogger. Keep the
deferred cleanup restoring origLog after the test so later tests retain the
logger state that existed before this test.
- Around line 299-326: Update the test around the concurrent logging block to
exercise the production paths in registry/model.go rather than emitting
completion messages directly from the test goroutines. Assert exactly one
complete log line for each model and its corresponding componentCounts[i] value,
and cover both ArtifactHub/GitHub and Meshery paths, including the no-change
branch near the existing production logic; alternatively, test the shared
formatter used by those paths.
🪄 Autofix (Beta)
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: b8898115-2d0d-477f-adc7-dc855cbc39a7
📒 Files selected for processing (2)
registry/model.goregistry/model_generation_test.go
Signed-off-by: Kumar Nirupam <kumar.nirupam24@gmail.com>

Description
Fixes #1050
Relates to meshery/meshery#11036
When
mesheryctl registry generateruns over many models, the terminal output can show mismatched log lines — for example:The model name on the first line does not match the model in the second line. This was reported in meshery/meshery#11036, but the root cause is in meshkit, not mesheryctl.
What was going wrong
InvokeGenerationFromSheetWithOptionsprocesses up to 20 models in parallel (semaphore.NewWeighted(20)). On each successful completion, the code logged two separate lines:Current model: <name>Extracted N components for <display name> (<name>)Those log calls run inside concurrent goroutines with no synchronization on stdout. When many models finish around the same time, the lines get interleaved and no longer belong to the same model.
The same two-line pattern existed in
GenerateDefsForCoreRegistrant(the meshery registrant path), including the "no change in components" case.Generation itself was fine — this is a logging/UX issue only.
What I changed
In
registry/model.go, I merged each two-line completion log into one log line usingLog.Info(fmt.Sprintf(...)):ArtifactHub / GitHub path (
InvokeGenerationFromSheetWithOptions):Current model: jenkins-operator — extracted 11 components for Jenkins Operator (jenkins-operator)Meshery registrant path (
GenerateDefsForCoreRegistrant):Same format for extracted components, plus a single line for the no-change case:
Current model: <name> — no change in components for <display name> (<name>)Single-line logs like
Model already exists: ...were left unchanged.No new helper functions, no concurrency changes, no changes to generation logic or file paths.
Why this approach
Combining model name and component count into one
Log.Infocall means each completion is one write to stdout. That prevents goroutines from splitting "Current model" and "extracted" across different lines. Keeping the change inline matches the existingLog.Info(fmt.Sprintf(...))style already used elsewhere in this file.Testing
Ran locally:
go test ./registry/... -count=1 -v go build ./...All registry tests passed.
Note: A single-model run (e.g.
--model flyte) usually will not show this bug — it needs multiple models completing in parallel.Notes for Reviewers
registry/model.gochangedSigned commits
Summary by CodeRabbit
Bug Fixes
Tests