Skip to content
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

fix the NRI_PLUGIN_NAME env value when launching a pre-installed plugin #42

Merged
merged 2 commits into from
May 23, 2023

Conversation

Iceber
Copy link
Member

@Iceber Iceber commented May 18, 2023

The environment variable NRI_PLUGIN_NAME actually represents name in the plugin

nri/pkg/stub/stub.go

Lines 273 to 280 in 8329599

func New(p interface{}, opts ...Option) (Stub, error) {
stub := &stub{
plugin: p,
name: os.Getenv(api.PluginNameEnvVar),
idx: os.Getenv(api.PluginIdxEnvVar),
socketPath: api.DefaultSocketPath,
dialer: func(p string) (stdnet.Conn, error) { return stdnet.Dial("unix", p) },
doneC: make(chan struct{}),

nri/pkg/stub/stub.go

Lines 450 to 452 in 8329599

func (stub *stub) Name() string {
return stub.idx + "-" + stub.name
}

so if we pass plugin name(< idx >-< base name >), the log will print out 'plugin name' with duplicate idx.

time="2023-05-18T13:39:43+08:00" level=info msg="Subscribing plugin 03-03-logger (03-logger) for events RunPodSandbox,StopPodSandbox,RemovePodSandbox,CreateContainer,PostCreateContainer,StartContainer,PostStartContainer,UpdateContainer,PostUpdateContainer,StopContainer,RemoveContainer"
time="2023-05-18T13:39:43+08:00" level=info msg="Started plugin 03-03-logger..."

Note that there are some differences between the plugin name variable/field in plugin and adaptation.

adaptation plugin
base name stub.name
idx stub.idx
plugin name(idx + "-" name) stub.Name() -> stub.idx + "-" + stub.name

@Iceber
Copy link
Member Author

Iceber commented May 18, 2023

/cc @klihub PTAL, Thanks

@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: +0.50 🎉

Comparison is base (2a8b655) 63.83% compared to head (ed9096d) 64.33%.

❗ Current head ed9096d differs from pull request most recent head 4a4cea6. Consider uploading reports for the commit 4a4cea6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
+ Coverage   63.83%   64.33%   +0.50%     
==========================================
  Files           9        9              
  Lines        1800     1800              
==========================================
+ Hits         1149     1158       +9     
+ Misses        500      492       -8     
+ Partials      151      150       -1     
Impacted Files Coverage Δ
pkg/adaptation/plugin.go 48.59% <0.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@klihub klihub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@mikebrow mikebrow merged commit f9e231f into containerd:main May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants