containerd / nri

Node Resource Interface
Apache License 2.0
220 stars 58 forks source link

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

Closed Iceber closed 1 year ago

Iceber commented 1 year ago

The environment variable NRI_PLUGIN_NAME actually represents name in the plugin https://github.com/containerd/nri/blob/83295992ed466e5589a1a83ba3ad2bd6b6feb199/pkg/stub/stub.go#L273-L280 https://github.com/containerd/nri/blob/83295992ed466e5589a1a83ba3ad2bd6b6feb199/pkg/stub/stub.go#L450-L452

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 commented 1 year ago

/cc @klihub PTAL, Thanks

codecov-commenter commented 1 year ago

Codecov Report

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

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

:exclamation: 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 ```diff @@ 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](https://app.codecov.io/gh/containerd/nri/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containerd) | Coverage Δ | | |---|---|---| | [pkg/adaptation/plugin.go](https://app.codecov.io/gh/containerd/nri/pull/42?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containerd#diff-cGtnL2FkYXB0YXRpb24vcGx1Z2luLmdv) | `48.59% <0.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/containerd/nri/pull/42/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=containerd)

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