Upgrade go-agentx to v0.3.0, containing my ordering fix

This commit is contained in:
Pim van Pelt
2025-11-21 10:08:23 +01:00
parent a0d5c61643
commit b6d2e3b629
6 changed files with 27 additions and 23 deletions

16
debian/changelog vendored
View File

@@ -1,18 +1,30 @@
govpp-snmp-agentx (1.1.7-1) bookworm; urgency=medium govpp-snmp-agentx (1.2.0-1) bookworm; urgency=medium
* Update go-agentx dependency from 0.2.1 to 0.3.0 to fix compilation issues
* Adapt to breaking changes in go-agentx Session API (now requires nameOID, name, handler)
* Update Client configuration to use dial options (WithTimeout, WithReconnectInterval)
* Remove access to unexported Session.Handler field (API change)
* NOTE: This version fixes compilation broken in 1.1.6-1 and 1.1.7-1
-- Pim van Pelt <pim@ipng.ch> Wed, 20 Nov 2024 00:00:00 +0000
govpp-snmp-agentx (1.1.7-1) bookworm; urgency=critical
* Refactor VPPClient constructor to use idiomatic Go patterns * Refactor VPPClient constructor to use idiomatic Go patterns
* Remove redundant NewVPPClient() constructor function * Remove redundant NewVPPClient() constructor function
* Update all code to use direct struct initialization (&VPPClient{}) * Update all code to use direct struct initialization (&VPPClient{})
* Improve code maintainability and follow Go best practices * Improve code maintainability and follow Go best practices
* WARNING: This version is BROKEN due to go-agentx 0.2.1 incompatibility
-- Pim van Pelt <pim@ipng.ch> Fri, 15 Nov 2024 00:00:00 +0000 -- Pim van Pelt <pim@ipng.ch> Fri, 15 Nov 2024 00:00:00 +0000
govpp-snmp-agentx (1.1.6-1) bookworm; urgency=medium govpp-snmp-agentx (1.1.6-1) bookworm; urgency=critical
* Replace forked go-agentx dependency with upstream github.com/posteo/go-agentx * Replace forked go-agentx dependency with upstream github.com/posteo/go-agentx
* Remove local src/go-agentx/ directory and use official upstream package * Remove local src/go-agentx/ directory and use official upstream package
* Upgrade to go-agentx v0.2.1 from official GitHub repository * Upgrade to go-agentx v0.2.1 from official GitHub repository
* Improve dependency management and reduce maintenance overhead * Improve dependency management and reduce maintenance overhead
* WARNING: This version is BROKEN due to go-agentx 0.2.1 incompatibility
-- Pim van Pelt <pim@ipng.ch> Fri, 08 Nov 2024 00:00:00 +0000 -- Pim van Pelt <pim@ipng.ch> Fri, 08 Nov 2024 00:00:00 +0000

View File

@@ -31,12 +31,13 @@ func StartAgentXRoutine(interfaceMIB *ifmib.InterfaceMIB) error {
logger.Debugf("Connecting to AgentX at %s://%s", network, address) logger.Debugf("Connecting to AgentX at %s://%s", network, address)
client, err := agentx.Dial(network, address) client, err := agentx.Dial(network, address,
agentx.WithTimeout(1*time.Minute),
agentx.WithReconnectInterval(1*time.Second),
)
if err != nil { if err != nil {
return err return err
} }
client.Timeout = 1 * time.Minute
client.ReconnectInterval = 1 * time.Second
// Register the interface MIB with the AgentX client // Register the interface MIB with the AgentX client
if err := interfaceMIB.RegisterWithClient(client); err != nil { if err := interfaceMIB.RegisterWithClient(client); err != nil {

View File

@@ -3,7 +3,7 @@ module govpp-snmp-agentx
go 1.23.8 go 1.23.8
require ( require (
github.com/posteo/go-agentx v0.2.1 github.com/posteo/go-agentx v0.3.0
go.fd.io/govpp v0.12.0 go.fd.io/govpp v0.12.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )

View File

@@ -18,12 +18,11 @@ github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posteo/go-agentx v0.2.1 h1:HO0zO/+GosL0RYEodu7KNH9OF/rL5bJbhXNP1z3hkT8= github.com/posteo/go-agentx v0.3.0 h1:Mqu0qzPHxbyZF3+fKwN2vjW49t6TPPgivjjplcuouNw=
github.com/posteo/go-agentx v0.2.1/go.mod h1:EUR75CfAEDstQn3WqCs26Ti64EsggaSXDk2dgxPQ5TI= github.com/posteo/go-agentx v0.3.0/go.mod h1:YCWL7bzLlpSNeU9vnfEg1pdlllDs1v2mz+pRcg21CUg=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.fd.io/govpp v0.12.0 h1:5HnMzsKHSFdxglsFyEhR0g+CzncWiLYXG2NDYgNUrnE= go.fd.io/govpp v0.12.0 h1:5HnMzsKHSFdxglsFyEhR0g+CzncWiLYXG2NDYgNUrnE=

View File

@@ -178,13 +178,9 @@ func (m *InterfaceMIB) UpdateStats(interfaceStats *api.InterfaceStats) {
m.addInterfaceToMIB(&iface) m.addInterfaceToMIB(&iface)
} }
// Update both sessions with the new handler // Note: With go-agentx 0.3.0, handlers are set during session creation and cannot be changed
if m.ifEntrySession != nil {
m.ifEntrySession.Handler = m.handler
}
if m.ifXTableSession != nil { if m.ifXTableSession != nil {
m.ifXTableSession.Handler = m.handler logger.Printf("Updated IF-MIB data for %d interfaces", len(m.stats))
logger.Printf("Updated session handlers with new IF-MIB data for %d interfaces", len(m.stats))
} }
logger.Debugf("IF-MIB now contains %d interfaces", len(m.stats)) logger.Debugf("IF-MIB now contains %d interfaces", len(m.stats))
@@ -460,13 +456,13 @@ func (m *InterfaceMIB) RegisterWithClient(client *agentx.Client) error {
m.mutex.Lock() m.mutex.Lock()
defer m.mutex.Unlock() defer m.mutex.Unlock()
// Create separate sessions for each MIB // Create separate sessions for each MIB with the handler
ifEntrySession, err := client.Session() ifEntrySession, err := client.Session(value.MustParseOID(ifEntryOID), "ifEntry", m.handler)
if err != nil { if err != nil {
return fmt.Errorf("failed to create ifEntry session: %v", err) return fmt.Errorf("failed to create ifEntry session: %v", err)
} }
ifXTableSession, err := client.Session() ifXTableSession, err := client.Session(value.MustParseOID(ifXTableOID), "ifXTable", m.handler)
if err != nil { if err != nil {
return fmt.Errorf("failed to create ifXTable session: %v", err) return fmt.Errorf("failed to create ifXTable session: %v", err)
} }
@@ -474,10 +470,6 @@ func (m *InterfaceMIB) RegisterWithClient(client *agentx.Client) error {
m.ifEntrySession = ifEntrySession m.ifEntrySession = ifEntrySession
m.ifXTableSession = ifXTableSession m.ifXTableSession = ifXTableSession
// Set handlers for both sessions
ifEntrySession.Handler = m.handler
ifXTableSession.Handler = m.handler
// Register the classic ifEntry // Register the classic ifEntry
err = ifEntrySession.Register(127, value.MustParseOID(ifEntryOID)) err = ifEntrySession.Register(127, value.MustParseOID(ifEntryOID))
if err != nil { if err != nil {

View File

@@ -16,7 +16,7 @@ import (
"govpp-snmp-agentx/vpp" "govpp-snmp-agentx/vpp"
) )
const Version = "1.1.7-1" const Version = "1.2.0-1"
func main() { func main() {
debug := flag.Bool("debug", false, "Enable debug logging") debug := flag.Bool("debug", false, "Enable debug logging")