-
Notifications
You must be signed in to change notification settings - Fork 6.3k
fix(go.d): fix dyncfg vnodes configs #21332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR attempts to refactor the dynamic configuration function routing logic by consolidating duplicate switch statements into a single dyncfgExec function. However, the refactoring introduces a critical bug that causes an infinite loop for most dynamic configuration commands.
Key intended changes:
- Created a new
dyncfgExecfunction to centralize the routing logic based on ID prefix - Removed duplicate switch statements from
manager.gothat routed between collector and vnode handlers - Simplified the channel message handling in the manager's run loop
Critical Issue:
The refactoring incorrectly routes functions received from the m.dyncfgCh channel to *Exec methods instead of *SeqExec methods. The *Exec methods send non-immediate commands back to the channel, creating an infinite loop for commands like Enable, Disable, Get, Restart, Add, Remove, and Update.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/go/plugin/go.d/agent/jobmgr/manager.go |
Simplified channel handling in the run loop by replacing switch statement and sequential execution calls with dyncfgExec |
src/go/plugin/go.d/agent/jobmgr/dyncfg.go |
Added new dyncfgExec function to route functions based on ID prefix, but incorrectly routes to async execution methods |
Comments suppressed due to low confidence (1)
src/go/plugin/go.d/agent/jobmgr/dyncfg.go:45
- The
dyncfgExecfunction callsdyncfgCollectorExecordyncfgVnodeExec, which will send certain commands back to them.dyncfgChchannel. When this function is called from the channel handler inmanager.go(lines 164, 175), it creates an infinite loop for commands like Enable, Disable, Get, Restart, Add, Remove, and Update.
The original code correctly called dyncfgCollectorSeqExec and dyncfgVnodeSeqExec when processing functions from the channel, which execute commands directly without re-queuing them.
This function should route to the sequential execution methods (*SeqExec) instead of the async execution methods (*Exec):
func (m *Manager) dyncfgExec(fn functions.Function) {
id := fn.Args[0]
switch {
case strings.HasPrefix(id, m.dyncfgCollectorPrefixValue()):
m.dyncfgCollectorSeqExec(fn)
case strings.HasPrefix(id, m.dyncfgVnodePrefixValue()):
m.dyncfgVnodeSeqExec(fn)
default:
m.dyncfgApi.SendCodef(fn, 503, "unknown function '%s' (%s).", fn.Name, id)
}
}func (m *Manager) dyncfgExec(fn functions.Function) {
id := fn.Args[0]
switch {
case strings.HasPrefix(id, m.dyncfgCollectorPrefixValue()):
m.dyncfgCollectorExec(fn)
case strings.HasPrefix(id, m.dyncfgVnodePrefixValue()):
m.dyncfgVnodeExec(fn)
default:
m.dyncfgApi.SendCodef(fn, 503, "unknown function '%s' (%s).", fn.Name, id)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="src/go/plugin/go.d/agent/jobmgr/manager.go">
<violation number="1" location="src/go/plugin/go.d/agent/jobmgr/manager.go:164">
Re-dispatching to m.dyncfgExec inside the channel consumer requeues the same function onto m.dyncfgCh, which blocks forever and wedges dynamic config handling.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
(cherry picked from commit e5b1e5a)
(cherry picked from commit e5b1e5a)
Summary
Test Plan
Additional Information
For users: How does this change affect me?
Summary by cubic
Fixes dynamic config handling for vnode functions in the go.d agent. Vnode configs now execute correctly in both sequential and non-sequential paths.
Bug Fixes
Refactors
Written for commit 898a820. Summary will update automatically on new commits.