Skip to content

Commit

Permalink
fix(circular dependency): bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
manojks1999 committed Feb 8, 2025
1 parent 45585af commit 0c26b8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/managers/pluginmanager/pluginmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ func (p *PluginManager) Start(ctx context.Context) error {
g, ctx := errgroup.WithContext(ctx)

// run conntrack GC
ct, err := conntrack.New(p.cfg)
ct, err := conntrack.New()
if err != nil {
return errors.Wrap(err, "failed to get conntrack instance")
}
ct.SetConfig(p.cfg)

Check failure on line 145 in pkg/managers/pluginmanager/pluginmanager.go

View workflow job for this annotation

GitHub Actions / Lint (windows, amd64)

ct.SetConfig undefined (type *conntrack.Conntrack has no field or method SetConfig)) (typecheck)

Check failure on line 145 in pkg/managers/pluginmanager/pluginmanager.go

View workflow job for this annotation

GitHub Actions / Lint (windows, amd64)

ct.SetConfig undefined (type *conntrack.Conntrack has no field or method SetConfig) (typecheck)

Check failure on line 145 in pkg/managers/pluginmanager/pluginmanager.go

View workflow job for this annotation

GitHub Actions / Lint (windows, arm64)

ct.SetConfig undefined (type *conntrack.Conntrack has no field or method SetConfig)) (typecheck)

Check failure on line 145 in pkg/managers/pluginmanager/pluginmanager.go

View workflow job for this annotation

GitHub Actions / Lint (windows, arm64)

ct.SetConfig undefined (type *conntrack.Conntrack has no field or method SetConfig) (typecheck)
g.Go(func() error {
return errors.Wrapf(ct.Run(ctx), "failed to run conntrack GC")
})
Expand Down
8 changes: 6 additions & 2 deletions pkg/plugin/conntrack/conntrack_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Init() error {
}

// New creates a new Conntrack instance
func New(cfg *config.Config) (*Conntrack, error) {
func New() (*Conntrack, error) {
objs := &conntrackObjects{}
err := loadConntrackObjects(objs, &ebpf.CollectionOptions{
Maps: ebpf.MapOptions{
Expand All @@ -64,11 +64,15 @@ func New(cfg *config.Config) (*Conntrack, error) {
gcFrequency: defaultGCFrequency,
objs: objs,
ctMap: objs.RetinaConntrack,
cfg: cfg,
}
return ct, nil
}

// SetConfig sets the config after initialization
func (ct *Conntrack) SetConfig(cfg *config.Config) {
ct.cfg = cfg
}

// Build dynamic header path
func BuildDynamicHeaderPath() string {
// Get absolute path to this file during runtime.
Expand Down
1 change: 0 additions & 1 deletion pkg/plugin/conntrack/types_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type Conntrack struct {
objs *conntrackObjects
ctMap *ebpf.Map
gcFrequency time.Duration
isRunning bool
cfg *config.Config
}

Expand Down

0 comments on commit 0c26b8b

Please sign in to comment.