windows: Use runtime event topic constants

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-07-20 18:33:16 +02:00
parent 5c8e0efb63
commit b2d9db2e17
No known key found for this signature in database
GPG Key ID: 40CF16616B361216
2 changed files with 47 additions and 40 deletions

View File

@ -194,12 +194,13 @@ func (r *windowsRuntime) Delete(ctx context.Context, t runtime.Task) (*runtime.E
wt.cleanup() wt.cleanup()
r.tasks.Delete(ctx, t) r.tasks.Delete(ctx, t)
r.emitter.Post(events.WithTopic(ctx, "/tasks/delete"), &eventsapi.TaskDelete{ r.emitter.Post(events.WithTopic(ctx, runtime.TaskDeleteEventTopic),
ContainerID: wt.id, &eventsapi.TaskDelete{
Pid: wt.pid, ContainerID: wt.id,
ExitStatus: rtExit.Status, Pid: wt.pid,
ExitedAt: rtExit.Timestamp, ExitStatus: rtExit.Status,
}) ExitedAt: rtExit.Timestamp,
})
if needServicing { if needServicing {
ns, _ := namespaces.Namespace(ctx) ns, _ := namespaces.Namespace(ctx)
@ -311,18 +312,19 @@ func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, spec
}) })
} }
r.emitter.Post(events.WithTopic(ctx, "/tasks/create"), &eventsapi.TaskCreate{ r.emitter.Post(events.WithTopic(ctx, runtime.TaskCreateEventTopic),
ContainerID: id, &eventsapi.TaskCreate{
IO: &eventsapi.TaskIO{ ContainerID: id,
Stdin: io.Stdin, IO: &eventsapi.TaskIO{
Stdout: io.Stdout, Stdin: io.Stdin,
Stderr: io.Stderr, Stdout: io.Stdout,
Terminal: io.Terminal, Stderr: io.Stderr,
}, Terminal: io.Terminal,
Pid: t.pid, },
Rootfs: rootfs, Pid: t.pid,
// TODO: what should be in Bundle for windows? Rootfs: rootfs,
}) // TODO: what should be in Bundle for windows?
})
return t, nil return t, nil
} }

View File

@ -112,10 +112,11 @@ func (t *task) Start(ctx context.Context) error {
return err return err
} }
t.emitter.Post(events.WithTopic(ctx, "/tasks/start"), &eventsapi.TaskStart{ t.emitter.Post(events.WithTopic(ctx, runtime.TaskStartEventTopic),
ContainerID: t.id, &eventsapi.TaskStart{
Pid: t.pid, ContainerID: t.id,
}) Pid: t.pid,
})
return nil return nil
} }
@ -129,9 +130,10 @@ func (t *task) Pause(ctx context.Context) error {
t.Unlock() t.Unlock()
} }
if err == nil { if err == nil {
t.emitter.Post(events.WithTopic(ctx, "/tasks/paused"), &eventsapi.TaskPaused{ t.emitter.Post(events.WithTopic(ctx, runtime.TaskPausedEventTopic),
ContainerID: t.id, &eventsapi.TaskPaused{
}) ContainerID: t.id,
})
} }
return errors.Wrap(err, "hcsshim failed to pause task") return errors.Wrap(err, "hcsshim failed to pause task")
} }
@ -148,9 +150,10 @@ func (t *task) Resume(ctx context.Context) error {
t.Unlock() t.Unlock()
} }
if err == nil { if err == nil {
t.emitter.Post(events.WithTopic(ctx, "/tasks/resumed"), &eventsapi.TaskResumed{ t.emitter.Post(events.WithTopic(ctx, runtime.TaskResumedEventTopic),
ContainerID: t.id, &eventsapi.TaskResumed{
}) ContainerID: t.id,
})
} }
return errors.Wrap(err, "hcsshim failed to resume task") return errors.Wrap(err, "hcsshim failed to resume task")
} }
@ -192,11 +195,12 @@ func (t *task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runt
return nil, err return nil, err
} }
t.emitter.Post(events.WithTopic(ctx, "/tasks/exec-added"), &eventsapi.TaskExecAdded{ t.emitter.Post(events.WithTopic(ctx, runtime.TaskExecAddedEventTopic),
ContainerID: t.id, &eventsapi.TaskExecAdded{
ExecID: id, ContainerID: t.id,
Pid: p.Pid(), ExecID: id,
}) Pid: p.Pid(),
})
return p, nil return p, nil
} }
@ -354,13 +358,14 @@ func (t *task) newProcess(ctx context.Context, id string, conf *hcsshim.ProcessC
} }
wp.exitCode = uint32(ec) wp.exitCode = uint32(ec)
t.emitter.Post(events.WithTopic(ctx, "/tasks/exit"), &eventsapi.TaskExit{ t.emitter.Post(events.WithTopic(ctx, runtime.TaskExitEventTopic),
ContainerID: t.id, &eventsapi.TaskExit{
ID: id, ContainerID: t.id,
Pid: pid, ID: id,
ExitStatus: wp.exitCode, Pid: pid,
ExitedAt: wp.exitTime, ExitStatus: wp.exitCode,
}) ExitedAt: wp.exitTime,
})
close(wp.exitCh) close(wp.exitCh)
// Ensure io's are closed // Ensure io's are closed