Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ilyam8
Copy link
Member

@ilyam8 ilyam8 commented Nov 21, 2025

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

    • Route vnode dynamic configs through the same execution path as collectors in manager.run().
    • Prevents vnode configs from being ignored when sequential execution is enabled.
  • Refactors

    • Added dyncfgQueuedExec and dyncfgSeqExec to centralize prefix-based routing.
    • Updated dyncfgConfig and manager.run to use these helpers.

Written for commit 898a820. Summary will update automatically on new commits.

Copy link
Contributor

Copilot AI left a 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 dyncfgExec function to centralize the routing logic based on ID prefix
  • Removed duplicate switch statements from manager.go that 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 dyncfgExec function calls dyncfgCollectorExec or dyncfgVnodeExec, which will send certain commands back to the m.dyncfgCh channel. When this function is called from the channel handler in manager.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.

@ilyam8 ilyam8 marked this pull request as draft November 21, 2025 13:47
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

@ilyam8 ilyam8 marked this pull request as ready for review November 21, 2025 14:02
Copy link
Contributor

Copilot AI left a 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.

@ilyam8 ilyam8 merged commit e5b1e5a into netdata:master Nov 21, 2025
213 of 236 checks passed
@ilyam8 ilyam8 deleted the fix-go.d-vnode-dyncfg branch November 21, 2025 14:09
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

stelfrag pushed a commit to stelfrag/netdata that referenced this pull request Nov 21, 2025
@stelfrag stelfrag mentioned this pull request Nov 21, 2025
Ferroin pushed a commit that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection area/go collectors/go.d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants