-
Notifications
You must be signed in to change notification settings - Fork 949
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
refactor: refact the pouch hook plugin #2360
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2360 +/- ##
=========================================
+ Coverage 68.29% 68.5% +0.21%
=========================================
Files 265 275 +10
Lines 18211 18245 +34
=========================================
+ Hits 12437 12499 +62
+ Misses 4357 4324 -33
- Partials 1417 1422 +5
|
d9706d6
to
b430721
Compare
9b10a69
to
45576fd
Compare
@@ -21,7 +21,7 @@ type DaemonProvider interface { | |||
VolMgr() mgr.VolumeMgr | |||
NetMgr() mgr.NetworkMgr | |||
MetaStore() *meta.Store | |||
ContainerPlugin() plugins.ContainerPlugin | |||
ContainerPlugin() hookplugins.ContainerPlugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of DaemonProvider
interface should also expose other 3 three plugin? Provide the access method to construct other components. WDYT @rudyfly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is unnessary.
cri/v1alpha2/cri.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// call cri plugin to update create config | ||
if c.CriPlugin != nil { | ||
if err := c.CriPlugin.PreCreateContainer(createConfig, sandboxMeta); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you put this hook immediately before c.ContainerMgr.Create
? The changes of plugin would be overwrote by other code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idae.
daemon/daemon.go
Outdated
if err != nil { | ||
return errors.Wrapf(err, "load plugin at %s error", d.config.PluginPath) | ||
} | ||
//load daemon plugin if exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a space after two slash//
daemon/daemon.go
Outdated
} else if s != nil { | ||
return fmt.Errorf("not a daemon plugin at %s %q", d.config.PluginPath, s) | ||
} | ||
//load container plugin if exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a space after two slash//
docs/features/pouch_with_plugin.md
Outdated
} | ||
## Which plugins | ||
|
||
Currently pouch provides four plugins,they are: `container plugin`,`daemon plugin`,`volume plugin`,`cri plugin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently pouch provides four plugins,they are: `container plugin`,`daemon plugin`,`volume plugin`,`cri plugin` | |
Currently pouch-container provides four plugins,they are: `container plugin`,`daemon plugin`,`volume plugin`,`cri plugin`. |
docs/features/pouch_with_plugin.md
Outdated
|
||
define two plugin symbols which only print some logs at correspond point: | ||
* pre-volume-create volume point, at this point you can change the create volume's config as you want, add your default volume's options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* pre-volume-create volume point, at this point you can change the create volume's config as you want, add your default volume's options. | |
* pre-volume-create volume point, at this point you can change the volume's create config as you want, add your default volume's options. |
docs/features/pouch_with_plugin.md
Outdated
|
||
var ContainerPlugin ContPlugin | ||
* pre-create-container cri container point, at this point you can update the container config what it will be created, such as update the container's envs or labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* pre-create-container cri container point, at this point you can update the container config what it will be created, such as update the container's envs or labels. | |
* pre-create-container cri point, at this point you can update the container config to what it will be created, such as update the container's envs or labels. |
docs/features/pouch_with_plugin.md
Outdated
] | ||
} | ||
// PreStartHook copy config from /etc/pouch/config.json to /etc/sysconfig/pouch | ||
// and start plugin processes than daemon depended |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mismatched doc.
docs/features/pouch_with_plugin.md
Outdated
return nil | ||
} | ||
|
||
// PreStopHook stops plugin processes than start ed by PreStartHook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// PreStopHook stops plugin processes than start ed by PreStartHook. | |
// PreStopHook stops plugin processes than started by PreStartHook. |
7e5c839
to
d116b17
Compare
This failure case is strange
However, I can't find a button to restart this job. |
@@ -683,6 +686,12 @@ func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateConta | |||
sandboxConfig := r.GetSandboxConfig() | |||
podSandboxID := r.GetPodSandboxId() | |||
|
|||
// get sandbox | |||
sandbox, err := c.ContainerMgr.Get(ctx, podSandboxID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part of code related to the hookplugin? @rudyfly Just wish confirmation from you.
In addition, the codes added gets instance sandbox
, but this sandbox
is used in L741, about 50 lines of code away from here.
If you are not putting this code on purpose, I am wondering if we could locate the code just along with L741 to improve aggregation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see you are constructing sandboxMeta
for the hook plugin.
But also wish you could answer the second question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved them together, PTAL.
docs/features/pouch_with_plugin.md
Outdated
@@ -1,148 +1,159 @@ | |||
# PouchContainer with plugin | |||
# Pouch-container with plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to change the name of it?
I think the logo of this project is PouchContainer indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should pouchcontainer instead of pouch-container?
docs/features/pouch_with_plugin.md
Outdated
// PostUpdate called after update method successful, | ||
// the method accepts the rootfs path and envs of container | ||
PostUpdate(string, []string) error | ||
} []() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove []()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
92c4014
to
a40d852
Compare
hookplugins/CriPlugin.go
Outdated
// CriPlugin defines places where a plugin will be triggered in CRI api lifecycle | ||
type CriPlugin interface { | ||
// PreCreateContainer defines plugin point where receives a container create request, in this plugin point user | ||
// could the container's config in cri interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// could the container's config in cri interface. | |
// could update the container's config in cri interface. |
or something else? :)
a40d852
to
2e633ce
Compare
Refact the pouch hook plugin, add plugins code into binary when building, instead of hook_plugin.so. Add the Cri plugin. More detail you can see: `docs/features/pouch_with_plugin.md` Signed-off-by: Rudy Zhang <[email protected]>
2e633ce
to
e2f48e9
Compare
LGTM |
Ⅰ. Describe what this PR did
Refact the pouch hook plugin, add plugins code into binary when
building, instead of hook_plugin.so.
Add the Cri plugin.
More detail you can see:
docs/features/pouch_with_plugin.md
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
NONE
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang [email protected]