Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d80c43d

Browse files
committedJan 11, 2018
libcontainer: expose annotations in hooks
Annotations weren't passed to hooks. This patch fixes that by passing annotations to stdin for hooks. Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent 96086e5 commit d80c43d

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed
 

‎libcontainer/container_linux.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,13 @@ func (c *linuxContainer) start(process *Process, isInit bool) error {
308308
c.initProcessStartTime = state.InitProcessStartTime
309309

310310
if c.config.Hooks != nil {
311+
bundle, annotations := utils.Annotations(c.config.Labels)
311312
s := configs.HookState{
312-
Version: c.config.Version,
313-
ID: c.id,
314-
Pid: parent.pid(),
315-
Bundle: utils.SearchLabels(c.config.Labels, "bundle"),
313+
Version: c.config.Version,
314+
ID: c.id,
315+
Pid: parent.pid(),
316+
Bundle: bundle,
317+
Annotations: annotations,
316318
}
317319
for i, hook := range c.config.Hooks.Poststart {
318320
if err := hook.Run(s); err != nil {
@@ -1436,11 +1438,13 @@ func (c *linuxContainer) criuNotifications(resp *criurpc.CriuResp, process *Proc
14361438
}
14371439
case notify.GetScript() == "setup-namespaces":
14381440
if c.config.Hooks != nil {
1441+
bundle, annotations := utils.Annotations(c.config.Labels)
14391442
s := configs.HookState{
1440-
Version: c.config.Version,
1441-
ID: c.id,
1442-
Pid: int(notify.GetPid()),
1443-
Bundle: utils.SearchLabels(c.config.Labels, "bundle"),
1443+
Version: c.config.Version,
1444+
ID: c.id,
1445+
Pid: int(notify.GetPid()),
1446+
Bundle: bundle,
1447+
Annotations: annotations,
14441448
}
14451449
for i, hook := range c.config.Hooks.Prestart {
14461450
if err := hook.Run(s); err != nil {

‎libcontainer/process_linux.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ func (p *initProcess) start() error {
341341
}
342342

343343
if p.config.Config.Hooks != nil {
344+
bundle, annotations := utils.Annotations(p.container.config.Labels)
344345
s := configs.HookState{
345-
Version: p.container.config.Version,
346-
ID: p.container.id,
347-
Pid: p.pid(),
348-
Bundle: utils.SearchLabels(p.config.Config.Labels, "bundle"),
346+
Version: p.container.config.Version,
347+
ID: p.container.id,
348+
Pid: p.pid(),
349+
Bundle: bundle,
350+
Annotations: annotations,
349351
}
350352
for i, hook := range p.config.Config.Hooks.Prestart {
351353
if err := hook.Run(s); err != nil {
@@ -370,11 +372,13 @@ func (p *initProcess) start() error {
370372
}
371373
}
372374
if p.config.Config.Hooks != nil {
375+
bundle, annotations := utils.Annotations(p.container.config.Labels)
373376
s := configs.HookState{
374-
Version: p.container.config.Version,
375-
ID: p.container.id,
376-
Pid: p.pid(),
377-
Bundle: utils.SearchLabels(p.config.Config.Labels, "bundle"),
377+
Version: p.container.config.Version,
378+
ID: p.container.id,
379+
Pid: p.pid(),
380+
Bundle: bundle,
381+
Annotations: annotations,
378382
}
379383
for i, hook := range p.config.Config.Hooks.Prestart {
380384
if err := hook.Run(s); err != nil {

‎libcontainer/state_linux.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ func destroy(c *linuxContainer) error {
6363

6464
func runPoststopHooks(c *linuxContainer) error {
6565
if c.config.Hooks != nil {
66+
bundle, annotations := utils.Annotations(c.config.Labels)
6667
s := configs.HookState{
67-
Version: c.config.Version,
68-
ID: c.id,
69-
Bundle: utils.SearchLabels(c.config.Labels, "bundle"),
68+
Version: c.config.Version,
69+
ID: c.id,
70+
Bundle: bundle,
71+
Annotations: annotations,
7072
}
7173
for _, hook := range c.config.Hooks.Poststop {
7274
if err := hook.Run(s); err != nil {

0 commit comments

Comments
 (0)
Please sign in to comment.