datadope-io / skydive

An open source real-time network topology and protocols analyzer
https://skydive.network
Apache License 2.0
1 stars 0 forks source link

proccon: unable to convert net info data #22

Closed adrianlzt closed 3 years ago

adrianlzt commented 3 years ago

Investigating the excesive consmuption of memory of probe proccon, I have seen also an increasing number of errors like:

Unable to convert map[10.27.43.28:1521:map[CreatedAt:1.621876515e+12 Revision:662 UpdatedAt:1.621939212e+12]] (map[string]interface {}) to *NetworkInfo

The data types used:

type NetworkInfo map[string]ProcInfo

type ProcInfo struct {
  CreatedAt int64
  UpdatedAt int64
  Revision  int64
}

The code generating that error:

  func (p *Probe) updateNetworkMetadata(field interface{}, newData NetworkInfo, nodeRevision int64) (ret bool) {
    currentDataPtr, ok := field.(*NetworkInfo)
    if !ok {
      logging.GetLogger().Warningf("Unable to convert %v (%T) to *NetworkInfo", field, field)
      return false
    }

field interface comes from:

    errTCPConn := p.graph.UpdateMetadata(node, MetadataTCPConnKey, func(field interface{}) bool {
      return p.updateNetworkMetadata(field, tcpConnStruct, node.Revision)
    })
adrianlzt commented 3 years ago

The problem is triggered by an update to the node.

Once the node is working correctly, if we do (the ID is a others Software node):

skydive client node update 3a90f19b-1981-4c0b-42f6-a48b4bc57f8c --add 'foo=bar'

Then, next data reaching proccon will produce the error:

Unable to convert map[192.168.1.35:22:map[CreatedAt:1.62246082e+12 Revision:9 UpdatedAt:1.62246086e+12] [2a01:e0a:234:3830:f88:a851:a16a:6bef]:22:map[CreatedAt:1.62246082e+12 Revision:9 UpdatedAt:1.62246086e+12]] (map[string]interface {}) to *NetworkInfo
adrianlzt commented 3 years ago

Error comes from function patchMethod in graffiti/api/server/server.go.

To apply a JSON patch, that function marshal the Metadata to JSON, apply the patch and then unmarshal to go data types, but loosing in the way all original go data types.